Authentication

Send your API key on every request, and keep it out of your code and logs

Every request carries an API key in the Authorization header.

curl https://api.mapier.ai/v1/whoami \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "x-mapier-version: 2026-12-01"

A request with no key, or with a key that was revoked or has expired, is refused before anything else happens:

401 Unauthorized
{ "error": { "code": "invalid_credentials", "message": "That API key is not valid." } }

What a key looks like

A key starts with mp_live_, then 43 letters and digits:

mp_live_9Kq2…

Every key sends from your project's lines. The prefix makes a key easy to spot when one lands in a log.

Create a key

  1. Open the console at convo.mapier.ai/app and go to the Keys page.
  2. Click Create key, and give it a name. You can also set when it expires.
  3. Copy the key into your secret manager before you close the dialog. It is shown once. Mapier keeps only a hash of it, so nobody can show it to you again.

The Keys page shows when each key was last used, so you can spot a key you do not recognize. Revoke a key on the same page; its next request is refused with 401.

What a key reaches

A key belongs to one project, and it sends from every line the project holds, on every channel. You do not have to choose a line: a person is answered on the line they last wrote to, and someone new gets the line Mapier picks. To choose, name the line at target.lineId. See Lines.

  • Everything belongs to a project. A conversation or attachment id from another project returns 404, the same as one that does not exist.
  • Keys share the project's budget. All keys in a project spend one command budget, so a second key adds no capacity. See Rate limits.

What a key may do

A key carries scopes, chosen when it is created and fixed from then on. To change them, create another key. A new key gets all four scopes unless you pick fewer. It can only get scopes its creator holds.

ScopeLets the key
messages:sendSend commands, check whether an address can be reached, and record an opt-out
messages:readRead the stream, events, receipts, history, attachments, contacts and people
lines:writeAdd and set up lines through POST /v1/line-setups
webhooks:writeManage webhook endpoints in the console. No route takes it from a key

Any key can call GET /v1/whoami, GET /v1/capabilities and the routes that read lines. A route the key has no scope for returns 403 insufficient_scope. GET /v1/whoami lists the key's scopes.

Personal access tokens

A personal access token is a person's credential in one organization, where a key is a project's. It starts with mp_pat_, is made in the console and shown once, and goes in the same Authorization: Bearer header. A command-line tool gets one by signing in from a terminal: see POST /v1/cli/logins.

  • It never does more than its owner. A call needs the scope the route names on the token, and the same right in its owner's role now. A token whose owner lost that right gets 403 forbidden with reason: "role"; one whose owner left the organization gets 401.
  • It names its project on every call about one. Send the project's id, as GET /v1/projects lists it, in x-mapier-project. Without it the call is 400 bad_request with reason: "missing_header". A project the token cannot reach is a 404.
  • It names its environment when it is not live. Send x-mapier-environment: test for test. An environment the token was not made for is 403 forbidden with reason: "environment".
curl https://api.mapier.ai/v1/conversations \
  -H "Authorization: Bearer $MAPIER_TOKEN" \
  -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \
  -H "x-mapier-version: 2026-12-01"

Each route's page says which credential it takes. The webhook endpoint and organization routes take a token only, and a key there gets 403 forbidden with reason: "personal_token_required". A key ignores x-mapier-project and x-mapier-environment.

Keep the key safe

Store it outside your code

Put it in an environment variable or a secret manager. Never commit it, and never send it to a browser: the API is for your server, and no key is safe to expose in a browser.

export MAPIER_API_KEY="mp_live_…"

Read it once at startup

const MAPIER_API_KEY = process.env.MAPIER_API_KEY;
if (!MAPIER_API_KEY) throw new Error("MAPIER_API_KEY is not set");

A missing key then stops your app at once, not with a 401 under load.

Keep it out of logs

The key travels in a header, so anything that prints request headers prints the key. Hide Authorization in your logging, and take care with verbose tools: curl -v prints the header in full.

A small client

Everything in these docs is plain HTTP, so a wrapper is a few lines:

const BASE = "https://api.mapier.ai";

export async function mapier(path: string, init: RequestInit = {}) {
  const res = await fetch(`${BASE}${path}`, {
    ...init,
    headers: {
      Authorization: `Bearer ${process.env.MAPIER_API_KEY}`,
      "Content-Type": "application/json",
      "x-mapier-version": "2026-12-01",
      ...init.headers,
    },
  });

  if (!res.ok) {
    const body = await res.json().catch(() => ({}));
    throw new Error(`${res.status} ${body.error?.code ?? "request failed"}`);
  }
  return res;
}

Every request and response shape is in the OpenAPI document at https://api.mapier.ai/openapi.json, which any generator turns into a typed client.