Install
Initialize
MESSAGES_API_KEY from your environment. To pass a key explicitly:
Send a message
Receive messages via webhooks
Create a webhook from the Webhooks page in your dashboard and copy the signing secret. Then handle incoming events on your server:verifyWebhook throws a SignatureVerificationError.
List messages
Reactions
Typing indicators
Read receipts
Files
Upload files to send as message attachments:Delivery tracking
Lines
Chats
Webhooks
Pagination
List methods return a page object withdata, hasMore, and nextCursor. Use for await...of to iterate through all results:
Error handling
All errors extendMessagesError and include the error type, code, and message from the API:
| Property | Type | Description |
|---|---|---|
type | string | Error category (e.g. authentication_error) |
code | string | Machine-readable code (e.g. invalid_api_key) |
message | string | Human-readable explanation |
param | string | undefined | The parameter that caused the error |
status | number | HTTP status code |
requestId | string | Unique request ID for debugging |
Configuration
All options are passed tocreateClient: