Documentation menu

Send an SMS

Sends one SMS to one mobile number. The response gives you a reference you can use to get the message and check its status.

POST https://api.diarybook.com/{authKey}/v2/sms

Request

Path parameters

ParameterDescription
authKeyYour API key. See Authentication.

Headers

HeaderValue
Content-Typeapplication/json

Body

FieldTypeRequiredDescription
tostringYesThe recipient’s mobile number, in international format, for example +353871234567.
textstringYesThe message text. Long messages are sent as several parts; see SMS message parts.
fromstringNoThe sender ID to send from. It must be approved on your account. Leave it out to use your account’s default sender.
senderRefstringNoYour own reference for the message, up to 40 characters, such as an order or ticket number. You can use it in place of our reference to get the message.
categorystringNoA billing category, up to 25 characters, for grouping costs in your reports.
clientRefstringNoA reference for the person or record the message is about in your system, up to 40 characters.

Empty strings in senderRef and category are treated as not supplied.

Example request

{
  "to": "+353871234567",
  "from": "MYCOMPANY",
  "text": "Your order 10482 has been dispatched and will arrive tomorrow.",
  "senderRef": "ORDER-10482",
  "category": "Dispatch"
}

With curl:

curl -X POST "https://api.diarybook.com/YOUR_API_KEY/v2/sms" \
  -H "Content-Type: application/json" \
  -d '{
        "to": "+353871234567",
        "from": "MYCOMPANY",
        "text": "Your order 10482 has been dispatched and will arrive tomorrow.",
        "senderRef": "ORDER-10482",
        "category": "Dispatch"
      }'

Response

200 OK

The message has been accepted and queued for sending.

{
  "reference": "msg_sms_Xk3pR9bTq2LmZa7vN4wY",
  "links": [
    {
      "href": "https://api.diarybook.com/YOUR_API_KEY/v2/sms/msg_sms_Xk3pR9bTq2LmZa7vN4wY",
      "rel": "self"
    },
    {
      "href": "https://api.diarybook.com/YOUR_API_KEY/v2/sms/ORDER-10482",
      "rel": "self"
    }
  ]
}
FieldTypeDescription
referencestringOur unique reference for the message, beginning msg_sms_. Store it to look the message up later.
linksarrayLinks for retrieving the message. The first uses reference. A second is included when you supplied a senderRef.

A 200 means the message was accepted, not that it was delivered. Use Get an SMS to follow its status.

Errors

StatusBodyCause
400No message details givenThe request body is missing or isn’t valid JSON.
400No message bodytext is missing or empty.
400No mobile numberto is missing or empty.
400Error[9101]: ...The message was rejected, for example an invalid value. The number is a status code.
401(empty)The API key is missing or not recognised.
429(empty)Rate limit exceeded. See Rate limits.
500A server error occurredA problem on our side. Retry later.

Example 400 response:

HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8

No mobile number

Things to know

  • Cost. Each message part is charged to your account at the rate for the destination country. The price is shown when you get the message.
  • Sender IDs and replies. Recipients can’t reply to a branded sender ID. To receive replies, send from a reply number instead. See Replies.
  • Opt-outs. Numbers on your account’s stop list are not sent to. See Opt-outs.
  • Characters. A message containing characters outside the GSM 7-bit alphabet, such as emoji, is sent as Unicode and holds fewer characters per part. See SMS message parts.