LineDevelopers

Send or schedule one SMS

POST/api/v1/messages

Without send_at, Line sends at once. With it, the message is scheduled until its time.

With a test key, the last four digits of to pick the outcome: 0002 ends failed, 0003 ends undelivered, and any other number ends delivered.

Bearer key, test or liveIdempotent with Idempotency-Key

Parameters

Idempotency-Keystringheaderrequired

Request body

fromstringrequired

An approved number in E.164 format, or an approved sender name such as ACMEDENTAL. A sender name is one-way and sends only to UK and Irish numbers.

tostringrequired

One recipient in E.164 format.

bodystring

The text. Send either body or template_id.

template_idstring · uuid

An active template. Line renders it with variables before it counts segments.

variablesobject

A value for every {{variable}} in the template.

send_atstring · date-time

Schedule the send, up to 35 days ahead. Include an offset, such as Z or +01:00. Credits are reserved at acceptance and released if the send is canceled.

expires_atstring · date-time

Do not send after this time. A message still waiting then ends as expired and its credits are released.

client_referencestring
metadataobject
max_segmentsinteger

Reject the send when the encoded body exceeds this limit. The service maximum is 10.

max_creditsnumber

Reject the send when the estimate exceeds this decimal credit ceiling.

Responses

201The message and durable dispatch work were created.
402The live wallet has insufficient available credits.
409The idempotency key conflicts with another request or is still resolving.
422A sender, destination, opt-out, template, segment, schedule or cost policy blocked the send.
Plus 400, 401, 403, 429, 503. See Errors.
curl -X POST 'https://staging.useline.io/api/v1/messages' \
  -H "Authorization: Bearer $LINE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H 'Content-Type: application/json' \
  -d '{
    "from": "+447700900123",
    "to": "+447700900456",
    "body": "Hi Sam, your engineer arrives between 10 and 12 tomorrow."
  }'
Response 201
{
  "id": "6f1c2a9e-3b7d-4e2a-9c51-0d8e4f7a2b10",
  "conversation_id": null,
  "status": "queued",
  "livemode": false,
  "from": "+447700900123",
  "to": "+447700900456",
  "sender_type": "phone_number",
  "encoding": "GSM-7",
  "segments": 1,
  "estimated_credits": "1",
  "send_at": null,
  "expires_at": null,
  "template_id": null,
  "template_version": null,
  "client_reference": null,
  "request_id": "req_6b1f0c2a",
  "status_url": "https://staging.useline.io/api/v1/messages/6f1c2a9e-3b7d-4e2a-9c51-0d8e4f7a2b10"
}