Getting started

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
1
2

Use the following base URL for all API endpoints:

https://connect.mailerlite.com/
1

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 MailerLiteopen in new window, navigating to Integrationsopen in new window and choosing MailerLite APIopen in new window. 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
1

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

Response Code: 401 Unauthorized
1
{
  "message": "Unauthenticated."
}
1
2
3

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
1

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
1
2
{
  "message": "The given data was invalid.",
  "errors": {
    "email": ["The email must be a valid email address."]
  }
}
1
2
3
4
5
6

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
1
2
3
4
5
{
  "message": "Too Many Attempts."
}
1
2
3

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 supportopen in new window
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 supportopen in new window
502Bad GatewayThere was an error on our system. Please contact supportopen in new window
503Service UnavailableThere was an error on our system. Please contact supportopen in new window
504Gateway TimeoutThere was an error on our system. Please contact supportopen in new window

More info on HTTP response codes can be found on Mozilla Developer Networkopen in new window.

Terms of service

Before implementing any integration, please make sure you're familiar with MailerLite's terms of serviceopen in new window.

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 open in new window within these guidelinesopen in new window.

Last Updated: