MailerLite
MailerLite API

Batching

Bundle up to 50 API calls into a single batch request to stay within MailerLite's rate limits.

The batch endpoint can be used to make multiple request to our api in a single call

POST /api/batch

Request body

ParameterTypeRequiredLimitations
requestsarrayrequiredArray of objects containing required method and path properties and optional body
requests.*.methodstringrequiredThe method type of the intended request: GET, POST, PUT, DELETE, PATCH
requests.*.pathstringrequiredThe relative path of api endpoint. Must start with api/
requests.*.bodyobjectoptionalObjects containing properties for the body of the request

Restrictions

A maximum of 50 requests can be performed in a single batch
The order of response objects is the same as the order in which they were sent
Webhooks are not yet supported in batch requests

Rate limits

When a batch request consists entirely of POST api/subscribers requests (subscriber upserts), the API automatically processes them as a bulk import internally. This import path is subject to a separate 5 requests per minute rate limit, in addition to the global API rate limit.

When the import rate limit is exceeded, the batch will return a 429 response directly:

Response Code: 429 Too Many Requests
{
  "message": "You're being rate limited on import creation."
}

Response

Response Code: 200 OK
{
  "total": 1,
  "successful": 1,
  "failed": 0,
  "responses": [
    {
      "code": 200,
      "body": {
        "data": [
          {
            "id": "1",
            "name": "test field",
            "key": "test_field",
            "type": "text"
          },
          {
            "id": "2",
            "name": "new field",
            "key": "new_field",
            "type": "text"
          }
        ]
      }
    }
  ]
}

Error

If invalid data has been passed

Response Code: 422 Unprocessable Entity
{
  "message": "The given data was invalid.",
  "errors": {
    "requests.0.method": ["The requests.1.method field is required."],
    "requests.0.path": ["The requests.0.path field is required."]
  }
}

If one of the batched requests has failed the whole batch will still be processed and the payload for the relevant errored batch will return the error

{
  "total": 1,
  "successful": 0,
  "failed": 1,
  "responses": [
    {
      "code": 422,
      "body": {
        "message": "The given data was invalid.",
        "errors": {
          "requests.0.method": ["The name field is required."]
        }
      }
    }
  ]
}

On this page