Send messages to patients in a batch
/messages:batchSends up to 60 messages in one request. Each item is the body of a single send and is checked the same way: recipient, channel, phone number, and opt-out. The batch counts as one request toward the per-second and per-minute request limits, and each message counts toward the per-minute message limit. All of an organization’s API keys share these limits. One Idempotency-Key covers the whole batch: retry with the same key and the same body to get the same results without sending anything twice.
Headers
Idempotency-KeyUUIDRequiredA UUID you generate for each write. Retrying with the same key returns the original result for 24 hours. Reusing a key with a different method, path, or body returns 409.
Body parameters
Messages to send in one request.
messagesarray of MessageSendRequiredUp to 60 messages, each the body of a single send.
Show child attributes
toRecipientRequiredWho to message. Provide exactly one of patient_id or phone.
Show child attributes
patient_idUUIDThe patient to message.
phonestringA mobile number. BloomText finds the patient with this number, or creates one.
patientPatientDetailsDetails for a patient BloomText creates while sending. Ignored when the phone number matches an existing patient.
bodystringRequiredMessage text: up to 1,600 characters for sms, or 40,000 for secure. A longer one returns 422 too_long.
channelsecure, smsRequiredRequired; there’s no default. sms sends the text itself as a regular SMS from the clinic’s number. secure sends a text or email with a secure link, and the message stays in BloomText.
fromstringThe clinic phone number to send from, in E.164 format, like +15125550100. Defaults to the default number: the one set on the API key, or the admin’s own. See List phone numbers.
Any other field returns 422 unknown_field. See Unknown fields are rejected.
Returns
Returns 207 Multi-Status with one result per message, in the order you sent them: an id and status: queued, or an error with a problem details object. One message’s error never fails the others.
Errors
Failed requests return application/problem+json problem details. The errors specific to this endpoint:
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | The request is malformed, such as invalid JSON. |
| 401 | invalid_token | The API key or access token is missing or malformed, or the access token has expired or been revoked. |
| 401 | key_revoked | An org admin revoked the API key. |
| 401 | key_expired | The API key’s expiry has passed. |
| 403 | insufficient_scope | The credential doesn’t have the scope this endpoint needs. |
| 403 | plan_required | The organization’s plan doesn’t include patient messaging. The whole batch is refused and nothing is sent. |
| 409 | idempotency_key_reused | The Idempotency-Key was already used with a different request. |
| 409 | idempotency_request_in_progress | A request with this Idempotency-Key is still running. Retry shortly. |
| 422 | validation_failed | messages is empty or holds more than 60 messages. Errors in individual messages come back in their results instead. |
| 422 | unknown_field | A message has a field the API doesn’t take. The whole batch is refused, naming the message (/messages/3/...), and nothing is sent. |
| 429 | rate_limited | The batch’s messages don’t fit in what’s left of the organization’s per-minute message limit. Nothing was sent; retry with the same Idempotency-Key after Retry-After. |
| 429 | rate_limited | Too many requests. Retry after Retry-After seconds. |