Send a Message


Send an SMS or MMS to a single recipient.

Endpoint

POST /api/v1/messaging/message

Request body

FieldTypeRequiredDescription
tostringYesRecipient phone number in E.164 format (e.g., +18005551234)
fromstringYesSender phone number in E.164 format. Must be an active number assigned to your account.
bodystringConditionalMessage text, up to 640 characters. Required for SMS. Optional for MMS if mediaUrl is provided.
mediaUrlstringNoPublicly accessible URL to a media file. When provided, the message is sent as MMS.
idempotencyKeystringNoUnique key to prevent duplicate sends on retries. See Idempotency.

SMS example

curl -X POST https://platform.textingline.com/api/v1/messaging/message \
  -u "your_key_id:your_key_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+18005551234",
    "from": "+18005559876",
    "body": "Your verification code is 482910"
  }'

MMS example

curl -X POST https://platform.textingline.com/api/v1/messaging/message \
  -u "your_key_id:your_key_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+18005551234",
    "from": "+18005559876",
    "body": "Check out our new collection!",
    "mediaUrl": "https://example.com/images/promo.jpg"
  }'

Response

{
  "id": "msg_DsAdb4EBYBh3z25sBA1qnv",
  "direction": "outbound",
  "to": "+18005551234",
  "from": "+18005559876",
  "body": "Your verification code is 482910",
  "status": "sent",
  "sentAt": "2026-03-15T14:30:05.000Z",
  "createdAt": "2026-03-15T14:30:00.000Z"
}
FieldDescription
idUnique message identifier, prefixed with msg_
directionMessage direction: outbound or inbound
statusOne of sent, queued, or failed
errorTypeError classification. Present only when status is failed. See values below.
errorMessageHuman-readable error description. Present only when status is failed.
sentAtISO 8601 timestamp of when the message was sent to the provider. Absent when status is failed.
createdAtISO 8601 timestamp of when the message was created

Failed responses

When the message is accepted but the provider cannot deliver it (e.g., the recipient has opted out), the API returns a 201 response with status: failed instead of an HTTP error. This allows you to distinguish between request-level errors (4xx/5xx) and delivery-level failures.

{
  "id": "msg_Hp2sABcDeFgHiJkLmNoPqR",
  "direction": "outbound",
  "to": "+18005551234",
  "from": "+18005559876",
  "body": "Your verification code is 482910",
  "status": "failed",
  "errorType": "opted_out",
  "errorMessage": "The recipient has opted out from receiving messages from this sender.",
  "createdAt": "2026-03-15T14:30:00.000Z"
}

Error types

errorTypeDescription
unknownAn unspecified error occurred during message processing
platform_errorAn internal platform error prevented the message from being sent
provider_errorThe upstream provider encountered an internal processing error
invalid_destinationThe destination number is invalid, unreachable, or not mobile
invalid_senderThe sender identity is not valid or not authorized
destination_blockedThe destination number is blocked from receiving messages
opted_outThe recipient has opted out from receiving messages
invalid_contentThe message content is invalid or exceeds allowed limits
routing_errorThe message could not be routed to the destination
geographic_restrictionThe message was blocked due to geographic restrictions
service_restrictedThe requested service type is not supported for this destination

Credits

Each message consumes credits from your account balance:

  • SMS: 2 credits (1 message + 1 carrier lookup)
  • MMS: 2 SMS credits + 1 MMS credit

If your balance is insufficient, the request is rejected with error code 33023. Check your credit balance in the dashboard.

Common errors

CodeDescription
33004The from number is not assigned to your account
33009The from number is not in an active state
33016Message body contains unsupported characters
33019Message violates compliance rules
33023Insufficient credits

See Error Codes for the full reference.