MailerLite

Getting started

Conventions, authentication, errors, and rate limits for integrating with the MailerLite REST API.

MailerLite API

MailerLite API is RESTful, fully-featured, and easy to integrate with.

You can use your favorite HTTP/REST library that is available for your programming language to make HTTP calls.

You must send JSON payloads in your requests and expect to get JSON responses. Don't forget to add these headers to each and every request.

Content-Type: application/json
Accept: application/json

Use the following base URL for all API endpoints:

https://connect.mailerlite.com/api

SDK

MailerLite supports this list of official libraries for your favorite programming languages. This is the easiest way to integrate MailerLite with your application.

Authentication

API keys

API keys are a quick way to implement machine-to-machine authentication without any direct inputs from a human beyond initial setup.

For example, you might want to run a scheduled job to sync your CRM data to your MailerLite account.

You can generate an API key by opening MailerLite, navigating to Integrations and choosing MailerLite API. Then click "Generate new token". Give it a name to help you identify where it's used in the future, e.g. "CRM sync job - production".

Once the key is generated, please copy and store it immediately. We will not be able to show this API key again in the future, as we don't store API keys in plain text for security reasons. If you lose it, you will have to replace it with a new API key.

Once you have your API key, provide it in an Authorization header together with your request payload, where XXX is your token:

Authorization: Bearer XXX

If you fail to provide a valid token, you'll get this response on all requests.

Response Code: 401 Unauthorized
{
  "message": "Unauthenticated."
}

API keys lifecycle & user deletion

API keys are permanently bound to the user who created them. If the user is removed from the account or the user account is deleted, the API key will stop working and will no longer authenticate any requests.

Versioning

All requests use the latest version, unless you override the API version. To lock down the API version, provide the current date at the time of implementation through X-Version header.

X-Version: 2038-01-19

Validation errors

You might encounter validation errors when sending requests to API endpoints. They will come in the following format

Response Code: 422 Unprocessable Entity
Content-Type: application/json
{
  "message": "The given data was invalid.",
  "errors": {
    "email": ["The email must be a valid email address."]
  }
}

Rate limits

MailerLite API has a global rate limit of 120 requests per minute. If you exceed that rate limit you will receive a 429 error response with a “Too Many Attempts” message. If you think you will be hitting these limits, please use batch endpoint and/or implement backoff strategy that would even out the requests over time.

Response Code: 429 Too Many Attempts
Content-Type: application/json
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 0
Retry-After: 119
{
  "message": "Too Many Attempts."
}

Import rate limits

Import creation endpoints have a separate rate limit of 5 requests per minute. This applies to:

  • POST /api/subscribers/import
  • POST /api/groups/{group_id}/import-subscribers
  • Batch requests where all items are POST api/subscribers (subscriber upserts)

If you exceed this limit you will receive a 429 response. Use the Retry-After header value to know when you can retry.

Response Code: 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
{
  "message": "You're being rate limited on import creation."
}

HTTP status codes

MailerLite returns standard HTTP response codes.

CodeNameExplanation
200OKThe request was accepted.
201CreatedResource was created.
202AcceptedThe request was accepted and further actions are taken in the background.
204No ContentThe request was accepted and there is nothing to return.
400Bad RequestThere was an error when processing your request. Please adjust your request based on the endpoint requirements and try again.
401UnauthorizedThe provided API token is invalid.
403ForbiddenThe action is denied for that account or a particular API token.
404Not FoundThe requested resource does not exist on the system.
405Method Not AllowedHTTP method is not supported by the requested endpoint.
408Request TimeoutThere is an error on our system. Please contact support
422Unprocessable EntityThere was a validation error found when processing the request. Please adjust it based on the endpoint requirements and try again.
429Too Many RequestsThere were too many requests made to the API.
500Internal Server ErrorThere was an error on our system. Please contact support
502Bad GatewayThere was an error on our system. Please contact support
503Service UnavailableThere was an error on our system. Please contact support
504Gateway TimeoutThere was an error on our system. Please contact support

More info on HTTP response codes can be found on Mozilla Developer Network.

Terms of service

Before implementing any integration, please make sure you're familiar with MailerLite's terms of service.

As stated in the ToC, if you collect subscribers on your own (as opposed to using MailerLite forms), you must accept responsibility for abuse prevention:

<..>you must ensure that the subscribers are collected in accordance with the industry best practice and requirements set out in these Terms and Anti-Spam Policy. You are responsible for preventing any type of abuse when collecting new subscribers through your own generated API key.

Branding

You can use our brand assets within these guidelines.

On this page