Skip to main content
mailers.io

API and MCP

Your API key and first /api/v3 call, step by step

By mailers.io team Published 5 min read

You want to talk to mailers.io from code or from a script. The first hour usually goes to the same questions: where is the key, which scopes, what does a good answer look like, and why did I get a 403. This guide goes from nothing to a working call. It does not cover every endpoint. That is the job of the reference at docs.mailers.io.

What a key is

An API key is a secret that stands for your account. It begins with mio_live_, and it is used as a bearer token. A few properties are worth knowing before you create one.

  • Scopes. A key names the permissions it has, such as lists.read or send. A key cannot be given more than its creator’s own role allows, and a Viewer’s key can only read.
  • Expiry. A key can have an expiry date, and it can be revoked at any time.
  • Never a login. A key does not open the web app. The app’s own sign-in is separate.
  • Scoped to the account. There is no way to read another account’s data with it.
  • Stored as a hash. mailers.io keeps only a hash of the secret and a short hint, so nobody can read it back, including us.
  • Two kinds. An api key is for /api/v3. An smtp key is for the SMTP relay and works nowhere else. They are not interchangeable.

You can have up to 50 live keys of each kind, and creating keys is rate limited, at 20 per hour. API access is on every current plan.

Create the key

Open Account, then API keys. Choose the kind (API), give the key a name that says what it is for, pick the scopes and, if you wish, an expiry. Create it and copy the secret. It is shown once. Put it in a secret manager or an environment variable and never in code, a front-end bundle or a repository.

Use one key per application. If one is leaked or retired you revoke it alone, and the others keep working. Give it only the scopes it needs. The scopes available are:

Scope What it allows
messages.read Read message status and events
send Send a message, using one credit per queued recipient
lists.read, lists.write Read, or create and rename, lists
contacts.read, contacts.write Read, or add, update and delete, contacts
templates.read, templates.write Read, or change, e-mail templates
sequences.write Enrol one contact into a sequence
automations.trigger Enter one contact into an automation
mcp Connect an AI assistant to the MCP endpoint

For a first call, lists.read is enough.

Make the call

Every call goes to the /api/v3 path on the API host, which is given in the developer documentation. Put the key in the Authorization header.

curl -H "Authorization: Bearer $MAILERS_KEY" \
  "https://app.mailers.io/api/v3/lists?per_page=25"

Keep the key in an environment variable, as shown, so that it does not end up in your shell history.

A good answer is a 200 with a data array and a meta block for paging. Each list has an id, a name, a count of subscribed and unsubscribed contacts, and created and updated times. A new account may have an empty array, which is a fine result: it proves that the key, the scope and the path work.

Lists take page and per_page, and per_page must be 25, 50 or 100. A search and a sort are also accepted.

A second call that writes

When you are ready to change something, add the lists.write scope to a key and create a list.

curl -X POST -H "Authorization: Bearer $MAILERS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"API test"}' \
  "https://app.mailers.io/api/v3/lists"

A new list is a 201. It starts with the FIRST_NAME and LAST_NAME fields. If the name is taken you get a 409 with list_name_taken, and if your plan’s list limit is reached, a 409 with list_limit_reached. Creating lists shares an hourly budget of 60 per account with the app, so do not create lists in a loop.

From a list you can add contacts and, for outreach, enrol them in a sequence. Cold e-mail through an API and MCP shows the flow, and sending and tracking from code covers sending a message.

Read the errors

An error has a status and a body with a code, a message and the fields at fault. The common ones:

  • 400. The request is wrong. Check the fields in the body.
  • 401. The key is missing, wrong, expired or revoked. Check the header and that it says Bearer.
  • 403. The key is valid but lacks the scope, or the plan or role does not allow the call. Add the scope when you create a new key, because the scopes of an existing key are chosen at creation.
  • 404. The id does not exist in your account. A resource of another account looks the same.
  • 409. A conflict, such as a name already used or a limit reached.
  • 429. You are over a rate limit. Wait for the number of seconds in the Retry-After header.

The default limit is 600 requests per minute per account, and each key has its own limit too. Some actions also have an hourly budget. Back off on a 429 and do not retry a 400.

Habits that save trouble

  1. Start with a read call to prove the key and the path.
  2. Use the narrowest scopes and one key per application.
  3. Set an expiry on keys you create for tests.
  4. Rotate by creating a new key, switching the application and revoking the old one.
  5. Log the status and the Retry-After of failures, never the key.
  6. Keep to the documented endpoints. There is no endpoint for campaigns or for credits, and no SDK. The API is plain HTTP with an OpenAPI 3.1 file.

Using the same key with an assistant

If you want an AI assistant to work with your account, create a key with the mcp scope and the scopes for the jobs it should do. The MCP endpoint turns every other API operation into a tool, filtered by the key’s scopes, so a key that cannot write lists gives the assistant no tool that writes lists.

For everything else, the API overview shows what the API covers, and the reference lists every field and error.

Questions and answers

Can I see my key again after I create it?

No. The secret is shown once, when it is created. Only a short hint is shown afterwards, so store the key in your secret manager at once or create a new one.

Is API access on my plan?

API access is on every current plan. SMTP relay keys are a separate kind and need the relay switch on the plan.

Can a key read another account's data?

No. Every id is scoped to the key's own account, and a key is never a browser login.

Written by the mailers.io team. Published .

Keep reading

Related posts

Send cold e-mail from your own servers.

Connect your servers, import a list and write the steps. Replies stop the sequence.

  • 7-day money-back guarantee
  • Bring your own providers
  • Cancel anytime