Skip to content

SMS

Queue an outgoing SMS

Use this method to queue SMS messages. Can be used to send the same message body to multiple recipients.

Schemas

Request

NameTypeDescription
bodyString(1..4096)The SMS body. Depending on the quantity and type of characters in the body, a single SMS may be split into multiple segments, incurring a charge for each.
expires_atString(format:date-time)An ISO8601 timestamp denoting when the message should be considered expired and abort sending. Expired messages will not refund the cost of processing the message, even if it is never sent.
fromString(format:e164)The sender number, or address that the message should originate from. If set to null or not present, a random number from the account will be used instead. Numbers may be in E.164 format (eg +17055551234), the preceding + will always be stripped internally.
idStringAny user-supplied id string, it need not be unique, however it will only be used for tagging purposes and is not generally available for lookup. Users may provide this id, or the response’s id for inquiries or support.
request_dlrBooleanWhether or not a DLR should be requested. Note: some carriers may not return a DLR.
toArray:String(format:e164)Array of recipient phone numbers in E.164 format. Note: Multiple recipient numbers will results in multiple messages

Response

NameTypeDescription
resultsArray:ObjectArray of result objects, one for each recipient
results[].directionStringDirection of the message, “OUTBOUND” for sent messages
results[].error_codeStringStatus code of the operation, “OK” for success or an error code.
results[].expires_atString(format:date-time)ISO8601 timestamp when the message expires
results[].fromString(format:e164)The sender phone number
results[].idStringUnique identifier for the message
results[].origin_idStringUser-supplied ID passed in the request
results[].partsArray:ObjectArray of message parts
results[].parts[].idStringUnique identifier for the message part
results[].schedule_atString(format:date-time)ISO8601 timestamp when the message is scheduled to be sent
results[].statusStringCurrent status of the message
results[].timestampString(format:date-time)ISO8601 timestamp of when the message was processed
results[].toString(format:e164)The recipient phone number
results[].typeStringThe message type, “SMS” for text messages

Examples

Successful request

Everything is correct and functioning as expected.

Request:

POST: https://sms.swift-api.com/v1/sms
Content-Type: application/json
Authorization: Bearer ABC123
{
"body": "Hello, World",
"expires_at": "2024-06-14T00:00:00.000000Z",
"from": "12003004000",
"id": "my-sms-id-1",
"request_dlr": true,
"to": [
"12003004001"
]
}

Response:

HTTP/1.1 200
Content-Type: application/json
Content-Length: 527
{
"results": [
{
"direction": "OUTBOUND",
"error_code": "OK",
"expires_at": "2024-06-14T00:00:00.000000Z",
"from": "12003004000",
"id": "01JDQ02MQ543RTQBT08WY88589",
"origin_id": "my-sms-id-1",
"parts": [
{
"id": "01JDQ02H94HEWKPK0VMJPY9N3H"
}
],
"schedule_at": "2024-06-14T00:00:00.000000Z",
"status": "NEW",
"timestamp": "2024-06-14T00:00:00.000000Z",
"to": "12003004001",
"type": "SMS"
}
]
}

Errored request

Occurs when there’s an issue with the request. Refer to the error_code field for details. A list of possible error codes can be found here.

HTTP/1.1 422
Content-Type: application/json
Content-Length: 527
{
"results": [
{
"direction": "OUTBOUND",
"error_code": "ACCOUNT_SMS_DISABLED",
"expires_at": "2024-06-14T00:00:00.000000Z",
"from": "12003004000",
"id": "01JDQ02MQ543RTQBT08WY88589",
"origin_id": "my-sms-id-1",
"parts": [
{
"id": "01JDQ02H94HEWKPK0VMJPY9N3H"
}
],
"schedule_at": "2024-06-14T00:00:00.000000Z",
"status": "NEW",
"timestamp": "2024-06-14T00:00:00.000000Z",
"to": "12003004001",
"type": "SMS"
}
]
}

Partial success

Occurs when there are successes and failures in the request.

HTTP/1.1 207
Content-Type: application/json
Content-Length: 527
{
"results": [
{
"direction": "OUTBOUND",
"error_code": "ACCOUNT_SMS_DISABLED",
"expires_at": "2024-06-14T00:00:00.000000Z",
"from": "12003004000",
"id": "01JDQ02MQ543RTQBT08WY88589",
"origin_id": "my-sms-id-1",
"parts": [
{
"id": "01JDQ02H94HEWKPK0VMJPY9N3H"
}
],
"schedule_at": "2024-06-14T00:00:00.000000Z",
"status": "NEW",
"timestamp": "2024-06-14T00:00:00.000000Z",
"to": "12003004001",
"type": "SMS"
}
]
}