Introduction
API is built on HTTP. Our API is RESTful. There is no need to learn yet another 3rd party library to use the API. You can use your favorite HTTP/REST library available for your programming language to make HTTP calls. You can also use our prepared libraries to use Mailerlite. All code examples will be using our prepared libraries.
Base URL
All API requests should start with the following base part:
https://api.mailerlite.com/api/v1/
Authentication
When you sign up for an account, you are given an API key. You authenticate to the Mailerlite API by providing your API key in the request. You can find your API key in page: Account & Settings ยป Account Settings
To authenticate you should pass apiKey
parameter in the request. When sending POST/PUT/DELETE requests you can pass apiKey
parameter together with other parameters. It is not necessary to pass it as GET parameter.
You can try the following API call right in your browser:
https://api.mailerlite.com/api/v1/campaigns/?apiKey=YOUR_API_KEY
Warning Keep your API key secret!
Formats
POST requests that are made to Mailerlite must have header Content-Type: application/x-www-form-urlencoded
value and the data should be formatted respectively. All responses from Mailerlite are in JSON format. There is an option to use XML format instead of JSON. Just add .xml
to your request link and all responses will be in XML, e.g.
https://api.mailerlite.com/api/v1/campaigns.xml/?apiKey=YOUR_API_KEY
Wrappers
PHP library which implements the complete functionality of the Mailerlite REST API. Examples how to use it are shown next to every function in documentation.
https://github.com/mailerlite/mailerlite_rest_v1
Errors
Mailerlite uses standard HTTP response codes.
Code | Description |
---|---|
200 | Everything is OK |
400 | Missing a required parameter or calling invalid method |
401 | Invalid API key provided |
404 | Can't find requested items |