Common API usage
Base URL
All paths referenced for MessageBird services in the API references uses the following base URL:
Esempio di codice
https://api.bird.com/
Base media URL
All paths referenced for retrieving media uses the following base URL:
Esempio di codice
https://media.api.bird.com
Authentication
In order to authenticate HTTP requests with an access key, you must provide it in the Authorization HTTP header with the following format. Replace <access-key> with your valid access key.
Esempio di codice
Authorization: AccessKey <access-key>
Authorization
Access key authorization is determined by the permissions assigned to your access key. See API Authorization for details on creating and managing access keys.
Formats and Headers
All HTTP responses are in JSON. It's advised to send the Accept HTTP header with the value application/json with each request. Both POST and PUT requests to the API must contain a JSON-formatted payload in the request body.
Errors
MessageBird uses standard HTTP status codes to indicate success or failure of API requests.
- HTTP response codes in the 2xx range indicate the request was successfully processed
- HTTP response codes in the 4xx range indicate that there was a client error - for example: authentication error, not enough balance or wrong/missing parameters. Don't worry, the HTTP response body includes a JSON-formatted response that tells you exactly what went wrong. If you're stuck, feel free to contact support, we're happy to help you out
- HTTP response codes in the 5xx range indicate a server error. It's considered safe to retry the same request, preferably with a delay
Pagination
When retrieving data via a request, the default page size is 10. This means the response will include a maximum of 10 items per page. If you need more items, you can set a custom value for the limit parameter, up to a maximum of 100.
| Name | Description | Example |
|---|---|---|
| limit | Limits the number of results to return. | 10 |
| pageToken | Tracks the current position in the list. Use it as the pageToken in the next request to continue fetching data. | WzE3MzIyMTIxNTU1NTAsIjY3MzEyNjAxLWQ4NjUtNGI1YS1hMmRmLTQ2ZGRiOWQ2NmUwOCJd |
If a response includes a nextPageToken, it indicates there are additional items available to fetch from the API. To retrieve the next set of items, provide the nextPageToken value as the pageToken parameter in the subsequent request.
Esempio di codice
{
"results": [],
"nextPageToken": "WzE3MzIyMTIxNTU1NTAsIjY3MzEyNjAxLWQ4NjUtNGI1YS1hMmRmLTQ2ZGRiOWQ2NmUwOCJd"
}Important: Pages can occasionally be empty or contain fewer items than expected, even when more items are available. To reliably determine the end of the list, always check for the presence of the nextPageToken field in the response. If nextPageToken is present, you should perform another request using the provided token, regardless of the current page's content.
A follow-up request would look like this:
Esempio di codice
GET /endpoint?limit=10&pageToken=abc123In this example, the value of abc123 from the nextPageToken in the previous response is passed as the pageToken parameter to fetch the next set of items.
Rate Limits
50 retrieval calls per second burst or 2,000 retrieval calls per minute steady.