Skip to content
Last updated

Status Codes & Errors

This page explains how InstaMessage uses HTTP status codes and error responses across the API.

Understanding these responses will help you handle errors correctly, retry requests safely, and track message delivery reliably.


HTTP status codes

InstaMessage uses standard HTTP status codes to indicate the result of an API request.

Messaging operations are asynchronous, meaning a successful API response confirms acceptance — not delivery.


Success responses (2xx)

These responses indicate that the request was accepted or processed successfully.

Status CodeMeaningNotes
200 OKRequest processed successfullyCommon for read-only operations
201 CreatedResource createdUsed when creating messages, contacts, groups, opt-outs

Important
A successful response (including 201 Created) means the request was accepted — not delivered.
Message delivery outcomes are reported later via webhooks or the Message Status API.


Client errors (4xx)

These responses indicate an issue with the request itself.

Status CodeMeaningCommon causes
400 Bad RequestInvalid requestMissing fields, invalid JSON, invalid IDs
401 UnauthorizedAuthentication failedMissing or invalid API key
422 Unprocessable EntityValid request but invalid valuesInvalid phone number, unsupported parameters

InstaMessage does not currently return 403, 404, or 409 responses.
Invalid resources or IDs are reported as 400 Bad Request with a specific error code.


Server errors (5xx)

These responses indicate an error on the InstaMessage platform or an upstream provider.

Status CodeMeaning
500 Internal Server ErrorUnexpected platform error
502 Bad GatewayUpstream provider error
503 Service UnavailableTemporary service outage

Error response format

All error responses follow a consistent JSON structure:

{
  "code": 4006,
  "message": "Invalid phone number"
}

For batch operations (if supported in future), partial failures may be reported per item.


Error fields

All error responses include the following fields:

FieldDescription
codeNumeric, machine-readable error code
messageHuman-readable description of the error

Messaging is asynchronous

Sending a message is an asynchronous operation.

This means:

  • A successful API response confirms acceptance, not delivery
  • Delivery, failure, or read status is reported later

Message outcomes are available via:

  • Webhooks (message.status)
  • Message Status API (lookup by message_id)

Never assume message delivery based on an HTTP response alone.


Webhooks and delivery guarantees

Webhook delivery is best-effort.

  • Webhooks are not retried if your endpoint fails
  • Events may arrive out of order
  • Missed events can be recovered via the Message Status API

For reliability:

  • Respond with 200 OK immediately
  • Process events asynchronously
  • Store delivery updates idempotently using message_id and status

Retry guidance

Safe to retry

You may retry requests when encountering:

  • Network timeouts
  • 5xx server errors

Always ensure retries are idempotent to avoid duplicate actions.

Do NOT retry automatically

Do not retry requests that return:

  • 400 or 422 errors (fix the request instead)
  • 401 Unauthorized (fix authentication)

Common messaging errors

Invalid phone number

{
  "code": 4006,
  "message": "Invalid phone number"
}

Invalid or missing parameters

{
  "code": 4001,
  "message": "Missing required field: to"
}

Best practices

  • Always check HTTP status codes before assuming success
  • Treat message creation as asynchronous
  • Use webhooks for real-time delivery updates
  • Use the Message Status API as a fallback
  • Store and correlate message_id values
  • Never assume delivery from a 2xx response alone

Next steps

Understanding status codes and errors ensures your integration is reliable, predictable, and production-ready.