# Messages ## Retrieve `client.messages.retrieve(stringmessageID, RequestOptionsoptions?): MessageRetrieveResponse` **get** `/api/v2/messages/{message_id}` Retrieve details of a specific message by its ID ### Parameters - **messageID:** `string` ### Returns - `MessageRetrieveResponse` - **data:** `Data` - **accountEmail:** `string` Email of the account - **content:** `string` Message content - **date\_sent:** `string` When the message was sent - **date\_updated:** `string` When the message was last updated - **error\_code:** `number | null` Numeric error code if message failed - **error\_detail:** `string | null` Detailed error information - **error\_message:** `string | null` Error message if message failed - **error\_reason:** `string | null` Error reason if message failed - **from\_number:** `string` Sender phone number - **group\_display\_name:** `string | null` Display name for group messages - **group\_id:** `string | null` Group ID for group messages - **is\_outbound:** `boolean` Whether this is an outbound message - **media\_url:** `string | null` URL of attached media - **message\_handle:** `string` Unique message identifier - **message\_type:** `"message" | "group"` - `"message"` - `"group"` - **number:** `string` Primary phone number (to_number for outbound, from_number for inbound) - **opted\_out:** `boolean` Whether the recipient has opted out - **participants:** `Array` List of participants for group messages - **plan:** `string` Account plan used for this message - **send\_style:** `"celebration" | "shooting_star" | "fireworks" | 10 more` The iMessage expressive message style - `"celebration"` - `"shooting_star"` - `"fireworks"` - `"lasers"` - `"love"` - `"confetti"` - `"balloons"` - `"spotlight"` - `"echo"` - `"invisible"` - `"gentle"` - `"loud"` - `"slam"` - **sendblue\_number:** `string | null` Sendblue phone number used - **service:** `"iMessage" | "SMS"` - `"iMessage"` - `"SMS"` - **status:** `"REGISTERED" | "PENDING" | "SENT" | 7 more` - `"REGISTERED"` - `"PENDING"` - `"SENT"` - `"DELIVERED"` - `"RECEIVED"` - `"QUEUED"` - `"ERROR"` - `"DECLINED"` - `"ACCEPTED"` - `"SUCCESS"` - **to\_number:** `string` Recipient phone number - **was\_downgraded:** `boolean` Whether the message was downgraded from iMessage to SMS - **status:** `string` ### Example ```typescript import SendblueAPI from 'sendblue-api'; const client = new SendblueAPI({ apiKey: 'My API Key', apiSecret: 'My API Secret', }); const message = await client.messages.retrieve('msg_abc123def456'); console.log(message.data); ``` ## List `client.messages.list(MessageListParamsquery?, RequestOptionsoptions?): MessageListResponse` **get** `/api/v2/messages` Retrieve a list of messages for the authenticated account with comprehensive filtering capabilities. Rate limited to 100 requests per 10 seconds per account. ### Parameters - **query:** `MessageListParams` - **account\_email:** `string` Filter by account email - **created\_at\_gte:** `string` Filter messages created after this date (ISO 8601 format) - **created\_at\_lte:** `string` Filter messages created before this date (ISO 8601 format) - **from\_number:** `string` Filter by sender phone number - **group\_id:** `string` Filter by group ID - **is\_outbound:** `"true" | "false"` Filter by message direction - `"true"` - `"false"` - **limit:** `number` Maximum number of messages to return - **message\_type:** `"message" | "group"` Filter by message type - `"message"` - `"group"` - **number:** `string` Filter by any phone number (from or to) - **offset:** `number` Number of messages to skip - **order\_by:** `"createdAt" | "updatedAt" | "sentAt"` Field to order messages by - `"createdAt"` - `"updatedAt"` - `"sentAt"` - **order\_direction:** `"asc" | "desc"` Sort order - `"asc"` - `"desc"` - **sendblue\_number:** `string` Filter by Sendblue phone number - **sent\_at\_gte:** `string` Filter messages sent after this date (ISO 8601 format) - **sent\_at\_lte:** `string` Filter messages sent before this date (ISO 8601 format) - **service:** `"iMessage" | "SMS"` Filter by service type - `"iMessage"` - `"SMS"` - **status:** `"REGISTERED" | "PENDING" | "SENT" | 7 more` Filter by message status - `"REGISTERED"` - `"PENDING"` - `"SENT"` - `"DELIVERED"` - `"RECEIVED"` - `"QUEUED"` - `"ERROR"` - `"DECLINED"` - `"ACCEPTED"` - `"SUCCESS"` - **to\_number:** `string` Filter by recipient phone number - **updated\_at\_gte:** `string` Filter messages updated after this date (ISO 8601 format) - **updated\_at\_lte:** `string` Filter messages updated before this date (ISO 8601 format) - **worker\_id:** `string` Filter by worker ID (Admin only) ### Returns - `MessageListResponse` - **data:** `Array` - **accountEmail:** `string` Email of the account - **content:** `string` Message content - **date\_sent:** `string` When the message was sent - **date\_updated:** `string` When the message was last updated - **error\_code:** `number | null` Numeric error code if message failed - **error\_detail:** `string | null` Detailed error information - **error\_message:** `string | null` Error message if message failed - **error\_reason:** `string | null` Error reason if message failed - **from\_number:** `string` Sender phone number - **group\_display\_name:** `string | null` Display name for group messages - **group\_id:** `string | null` Group ID for group messages - **is\_outbound:** `boolean` Whether this is an outbound message - **media\_url:** `string | null` URL of attached media - **message\_handle:** `string` Unique message identifier - **message\_type:** `"message" | "group"` - `"message"` - `"group"` - **number:** `string` Primary phone number (to_number for outbound, from_number for inbound) - **opted\_out:** `boolean` Whether the recipient has opted out - **participants:** `Array` List of participants for group messages - **plan:** `string` Account plan used for this message - **send\_style:** `"celebration" | "shooting_star" | "fireworks" | 10 more` The iMessage expressive message style - `"celebration"` - `"shooting_star"` - `"fireworks"` - `"lasers"` - `"love"` - `"confetti"` - `"balloons"` - `"spotlight"` - `"echo"` - `"invisible"` - `"gentle"` - `"loud"` - `"slam"` - **sendblue\_number:** `string | null` Sendblue phone number used - **service:** `"iMessage" | "SMS"` - `"iMessage"` - `"SMS"` - **status:** `"REGISTERED" | "PENDING" | "SENT" | 7 more` - `"REGISTERED"` - `"PENDING"` - `"SENT"` - `"DELIVERED"` - `"RECEIVED"` - `"QUEUED"` - `"ERROR"` - `"DECLINED"` - `"ACCEPTED"` - `"SUCCESS"` - **to\_number:** `string` Recipient phone number - **was\_downgraded:** `boolean` Whether the message was downgraded from iMessage to SMS - **pagination:** `Pagination` - **hasMore:** `boolean` Whether there are more messages available - **limit:** `number` Number of messages returned in this request - **offset:** `number` Number of messages skipped - **total:** `number` Total number of messages matching the filters - **status:** `string` ### Example ```typescript import SendblueAPI from 'sendblue-api'; const client = new SendblueAPI({ apiKey: 'My API Key', apiSecret: 'My API Secret', }); const messages = await client.messages.list(); console.log(messages.data); ``` ## Get Status `client.messages.getStatus(MessageGetStatusParamsquery, RequestOptionsoptions?): MessageResponse` **get** `/api/status` Retrieve the current status of a message using its message handle. Useful for resolving pending message statuses and avoiding duplicate messages. ### Parameters - **query:** `MessageGetStatusParams` - **handle:** `string` The message handle of the message you want to check status for ### Returns - `MessageResponse` ### Example ```typescript import SendblueAPI from 'sendblue-api'; const client = new SendblueAPI({ apiKey: 'My API Key', apiSecret: 'My API Secret', }); const messageResponse = await client.messages.getStatus({ handle: 'msg_abc123def456' }); console.log(messageResponse.account_email); ``` ## Send `client.messages.send(MessageSendParamsbody, RequestOptionsoptions?): MessageResponse` **post** `/api/send-message` Send an iMessage, SMS, or MMS to a single recipient ### Parameters - **body:** `MessageSendParams` - **content:** `string` Message text content - **from\_number:** `string` **REQUIRED** - The phone number to send from. Must be one of your registered Sendblue phone numbers in E.164 format. Without this parameter, the message will fail to send. - **number:** `string` Recipient phone number in E.164 format - **media\_url:** `string` URL of media file to send (images, videos, etc.) - **send\_style:** `"celebration" | "shooting_star" | "fireworks" | 10 more` The iMessage expressive message style - `"celebration"` - `"shooting_star"` - `"fireworks"` - `"lasers"` - `"love"` - `"confetti"` - `"balloons"` - `"spotlight"` - `"echo"` - `"invisible"` - `"gentle"` - `"loud"` - `"slam"` - **status\_callback:** `string` Webhook URL for message status updates ### Returns - `MessageResponse` ### Example ```typescript import SendblueAPI from 'sendblue-api'; const client = new SendblueAPI({ apiKey: 'My API Key', apiSecret: 'My API Secret', }); const messageResponse = await client.messages.send({ content: 'Hello, World!', from_number: '+19998887777', number: '+19998887777', }); console.log(messageResponse.account_email); ``` ## Domain Types ### Message Content - `MessageContent` - **account\_email:** `string` Email of the account - **content:** `string` Message content - **date\_created:** `string` When the message was created - **date\_sent:** `string` When the message was sent - **date\_updated:** `string` When the message was last updated - **from\_number:** `string` Sender phone number - **is\_outbound:** `boolean` Whether this is an outbound message - **media\_url:** `string` URL of attached media - **message\_handle:** `string` Unique message identifier - **send\_style:** `"celebration" | "shooting_star" | "fireworks" | 10 more` - `"celebration"` - `"shooting_star"` - `"fireworks"` - `"lasers"` - `"love"` - `"confetti"` - `"balloons"` - `"spotlight"` - `"echo"` - `"invisible"` - `"gentle"` - `"loud"` - `"slam"` - **status:** `"QUEUED" | "SENT" | "DELIVERED" | 3 more` - `"QUEUED"` - `"SENT"` - `"DELIVERED"` - `"READ"` - `"ERROR"` - `"RECEIVED"` - **to\_number:** `string` Recipient phone number ### Message Response - `MessageResponse` - **account\_email:** `string` Email of the account that sent the message - **content:** `string` Message content - **date\_created:** `string` When the message was created - **date\_updated:** `string` When the message was last updated - **error\_code:** `number` Numeric error code if message failed - **error\_message:** `string` Error message if message failed - **from\_number:** `string` Sending phone number - **is\_outbound:** `boolean` Whether this is an outbound message - **media\_url:** `string` URL of attached media - **message\_handle:** `string` Unique identifier for tracking the message - **number:** `string` Recipient phone number - **send\_style:** `"celebration" | "shooting_star" | "fireworks" | 10 more` The iMessage expressive message style - `"celebration"` - `"shooting_star"` - `"fireworks"` - `"lasers"` - `"love"` - `"confetti"` - `"balloons"` - `"spotlight"` - `"echo"` - `"invisible"` - `"gentle"` - `"loud"` - `"slam"` - **status:** `"QUEUED" | "SENT" | "DELIVERED" | 2 more` - `"QUEUED"` - `"SENT"` - `"DELIVERED"` - `"READ"` - `"ERROR"`