LineDevelopers

Send up to 500 messages in one request

POST/api/v1/messages/batch

Each message is accepted or rejected on its own. A retry with the same Idempotency-Key returns the same result for every message.

Bearer key, test or liveIdempotent with Idempotency-Key

Parameters

Idempotency-Keystringheaderrequired

Request body

Shared fields apply to every message unless the message sets its own value.

fromstring

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.

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.

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.

messagesarray of objectrequired

1 to 500 messages. Each needs to, and inherits any shared field it does not set.

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

200accepted and rejected counts, and one result per message in data, by index.
402The live wallet cannot cover the batch.
Plus 400, 401, 403, 429, 503. See Errors.
curl -X POST 'https://staging.useline.io/api/v1/messages/batch' \
  -H "Authorization: Bearer $LINE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H 'Content-Type: application/json' \
  -d '{
    "from": "+447700900123",
    "body": "Your appointment is tomorrow at 9am.",
    "messages": [
      {
        "to": "+447700900456"
      },
      {
        "to": "+447700900789"
      }
    ]
  }'