Send without Account

POST /messages

While it is simpler to send from a single Account, sometimes that is not possible. In that case, you may use this endpoint to allow TextUs to determine the most appropriate Account from which to send the message. You may do this by providing either a from number that corresponds to a Phone Number on an Account, or with an email for a TextUs User that belongs to an Account.

Examples

Sending a Message from a Phone Number

If you provide a from phone number that belongs to a messaging Account, we will send the message from that Account.

A Message can be sent to multiple recipients at the same time by listing each recipient number in the to field.

Request

POST /messages

Body

{
  "from": "+13035551111",
  "to": "+13035551234",
  "body": "New phone who dis?"
}
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X POST /messages
    -d '{
  "from": "+13035551111",
  "to": "+13035551234",
  "body": "New phone who dis?"
}'

Response

Status

201

Response Type

Message

Example Body

{
  "@type": "Message",
  "id": "/messages/QNDkpL",
  "@context": "/contexts/Message.jsonld",
  "direction": "out",
  "body": "Chuck Norris doesn't use web standards as the web will conform to him.",
  "formattedBody": "<div>Chuck Norris doesn't use web standards as the web will conform to him.</div>",
  "displayTimestamp": "2018-07-24T20:59:32.156Z",
  "timelinePosition": "2018-07-24T20:59:32.156Z",
  "deliveryState": "delivered",
  "conversation": "/conversations/kY1QwY",
  "sender": "/users/hikvlD",
  "attachments": {
    "@context": "/contexts/hydra:Collection.jsonld",
    "@type": "hydra:Collection",
    "id": "/messages/joZqVWd/attachments",
    "members": [],
    "totalItems": 0
  },
  "friendlyStateDescription": "Message Delivered",
  "retryAllowed": false,
  "retry": null,
  "latestEventAt": "2018-07-24T20:59:32.156Z",
  "flags": [],
  "source": "textus"
}

Sending a Message from a User

If you provide a TextUs User’s email instead of a from number, we will attempt to determine the best account from which to send the message:

  • If the User has only a single messaging Account, that Account will be used.
  • If the User has multiple Accounts:
    • We will look for an Accounts with existing Conversations with the to number:
      • If there are none:
        • If the User has specified a “Default Messaging Account” in their profile, that will be used.
        • Otherwise, the request will respond with an error.
      • If there is 1, the Account with the existing Conversation will be used.
      • If there are more than one:
        • If the User is Assigned to any of the Conversations, it will pick the one with the latest activity.
        • Otherwise, if the User has participated (sent a message) in any of the Conversations, it will pick the one with the latest activity.
        • Finally, if there are multiple Conversations, the Account to choose is ambiguous, and rather than sending the Message from an arbitrary Account, the request will respond with an error.

A Message can be sent to multiple recipients at the same time by listing each recipient number in the to field.

Request

POST /messages

Body

{
  "email": "chuck@textus.example",
  "to": "+13035551234",
  "body": "New phone who dis?"
}
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X POST /messages
    -d '{
  "email": "chuck@textus.example",
  "to": "+13035551234",
  "body": "New phone who dis?"
}'

Response

Status

201

Response Type

Message

Example Body

{
  "@type": "Message",
  "id": "/messages/QNDkpL",
  "@context": "/contexts/Message.jsonld",
  "direction": "out",
  "body": "Chuck Norris doesn't use web standards as the web will conform to him.",
  "formattedBody": "<div>Chuck Norris doesn't use web standards as the web will conform to him.</div>",
  "displayTimestamp": "2018-07-24T20:59:32.156Z",
  "timelinePosition": "2018-07-24T20:59:32.156Z",
  "deliveryState": "delivered",
  "conversation": "/conversations/kY1QwY",
  "sender": "/users/hikvlD",
  "attachments": {
    "@context": "/contexts/hydra:Collection.jsonld",
    "@type": "hydra:Collection",
    "id": "/messages/joZqVWd/attachments",
    "members": [],
    "totalItems": 0
  },
  "friendlyStateDescription": "Message Delivered",
  "retryAllowed": false,
  "retry": null,
  "latestEventAt": "2018-07-24T20:59:32.156Z",
  "flags": [],
  "source": "textus"
}

Sending an Message with an integration source

If you provide an integration name all in lower case, we will save it as the message source.

Request

POST /messages

Body

{
  "email": "chuck@textus.example",
  "to": "+13035551234",
  "body": "New phone who dis?",
  "source": "hubspot"
}
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X POST /messages
    -d '{
  "email": "chuck@textus.example",
  "to": "+13035551234",
  "body": "New phone who dis?",
  "source": "hubspot"
}'

Response

Status

201

Response Type

Message

Example Body

{
  "@type": "Message",
  "id": "/messages/QNDkpL",
  "@context": "/contexts/Message.jsonld",
  "direction": "out",
  "body": "Chuck Norris doesn't use web standards as the web will conform to him.",
  "formattedBody": "<div>Chuck Norris doesn't use web standards as the web will conform to him.</div>",
  "displayTimestamp": "2018-07-24T20:59:32.156Z",
  "timelinePosition": "2018-07-24T20:59:32.156Z",
  "deliveryState": "delivered",
  "conversation": "/conversations/kY1QwY",
  "sender": "/users/hikvlD",
  "attachments": {
    "@context": "/contexts/hydra:Collection.jsonld",
    "@type": "hydra:Collection",
    "id": "/messages/joZqVWd/attachments",
    "members": [],
    "totalItems": 0
  },
  "friendlyStateDescription": "Message Delivered",
  "retryAllowed": false,
  "retry": null,
  "latestEventAt": "2018-07-24T20:59:32.156Z",
  "flags": [],
  "source": "hubspot"
}

© 2024 TextUs