Authentication
The Mojeeb Public API uses API keys, not JWTs. Each key is a long-lived server-to-server credential issued from the dashboard and scoped to your organization. Send the key as a Bearer token over HTTPS.
How do I send my API key?
Pass the key in the standard Authorization header:
Authorization: Bearer mk_live_8aB3cDe4FgH5iJ6kLm7nOp_a1b2c3d4e5
HTTPS only. Plain HTTP requests are rejected by the load balancer before they reach the API.
What does the key format look like?
mk_live_<22 chars>_<10 char checksum>
Example: mk_live_8aB3cDe4FgH5iJ6kLm7nOp_a1b2c3d4e5
mk_— Mojeeb prefix; grep-able in logslive_— environment marker (test_is reserved for a future sandbox)- 22-character body with 130 bits of entropy
- 10-character checksum so the API can reject malformed keys before any database lookup
The checksum protects you against typos: a one-character mistake fails locally, fast.
Where do I get a key?
- Sign in to the Mojeeb dashboard. Your organization needs the Starter or Professional plan. You must be the owner, or an admin with access to every agent.
- Open the API Keys page from the sidebar
- Click Create key, give it a name, and confirm
- Copy the secret immediately — it's shown once and never again
If you lose a key, revoke it from the dashboard and create a new one. There is no way to recover the original secret.
The same keys work with the Mojeeb MCP server, which lets AI assistants such as Claude or Cursor call this API. Give each assistant a key of its own, so you can revoke it without affecting your other integrations, or let the assistant sign in instead.
Can an AI assistant sign in instead of using a key?
Yes. An AI assistant such as claude.ai, ChatGPT, Claude Code or Cursor can sign in with a person's Mojeeb account (OAuth 2.1 with PKCE), and then calls this API as that person: with their role and the agents they can open, never more, in the company they chose. Nobody creates or pastes a key.
- Who: the company's owner, or an admin with access to every agent, on any plan, approves the connection on a Mojeeb page.
- Access: Read only (scope
read: only endpoints whose scope ends in:read) or Read and change (scopefull). Both are open on every plan, Free included, and the page starts on Read and change when the app asks for it. - Tokens: an access token for an hour, renewed with a refresh token that changes on every use and lapses after 90 days unused. A refresh token used twice ends the connection.
- Ending it: removing the person from the company ends every assistant they connected at once.
- Limits: each connection has its own rate limit, the same as a key's.
The assistant sends its token as Authorization: Bearer …, like a key. It is meant for AI assistants through the MCP server; for your own servers and scripts, use a key. The sign-in endpoints are described at https://api.mojeeb.app/.well-known/oauth-authorization-server.
What are scopes?
Scopes name what a key may do, in resource:action format. Today every key is issued with full access, the * scope: it can call every endpoint the API offers, on every agent in its organization, managing your team included (team:write).
| Scope | Allows |
|---|---|
* | Every current and future endpoint. What every key holds today. |
whatsapp:send | Send WhatsApp messages (text, a file or both) and templates, and read a sent message's status (GET /v1/whatsapp/messages/{id}). Keys issued before October 11, 2026 held only this scope; they now hold *. |
Every page of the API reference already shows the scope its endpoint will require (x-scope), so a key can later be limited to reading, or to one kind of data:
| Scope | Endpoints |
|---|---|
whatsapp:read | A WhatsApp number's templates |
whatsapp_templates:write | Creating, editing and deleting a WhatsApp number's templates |
broadcasts:read / broadcasts:write | An agent's WhatsApp broadcasts and their recipients; broadcasts:write also sends them and resends their failed messages |
contacts:read / contacts:write | Contacts |
notes:read / notes:write | A contact's notes |
leads:read / leads:write | Leads, including assigning, pinning and deleting them and changing the status of many at once; the agent's lead fields; and the AI's lead capture prompt |
tickets:read / tickets:write | Tickets, including assigning and deleting them and changing the status of many at once; the agent's ticket fields; and the AI's ticket capture prompt and setting |
knowledge:read / knowledge:write | Knowledge bases |
connections:read / connections:write | Connections and their AI switches; connections:read also reads the website widget and its embed code |
agents:read / agents:write | Agents (listing and reading them) and their settings: name, description, Main Instructions, time zone, AI handoff, AI auto-disable, AI working hours, comment auto-hide and follow-ups |
team:read | Your team: members, their roles and emails, the agents each can open, and whether Mojeeb Support may open your data |
team:write | Managing your team: invitations, changing or removing members, and turning Mojeeb Support access on or off. The key's rank there is its creator's; see Your Team |
usage:read | Your plan, and its message and agent usage now and per billing period |
analytics:read | An agent's daily analytics |
custom_api:read / custom_api:write | An agent's custom API tools and their runs; custom_api:write also tests them and changes their sites' logins |
attachments:read / attachments:write | An agent's AI attachments and links to their files; attachments:write also switches them on and off and uploads or imports their media |
uploads:read / uploads:write | An agent's uploads, files staged for 24 hours for any media field; uploads:write creates them. Sending an upload's bytes takes no key, and using its url needs the scope of the endpoint it goes in |
saved_replies:read / saved_replies:write | An agent's saved replies; saved_replies:write also creates, replaces, switches off and deletes them and changes their media |
conversations:read / conversations:write | An agent's conversations and their messages; conversations:write also changes their state and assignee, replies to customers and tests the agent in a chat |
comments:read / comments:write | An agent's Facebook and Instagram comments with their replies and moderation; comments:write also hides and shows them |
ads:read | An agent's Meta ads: the ads customers reached it through, with the taps, comment replies, conversations, contacts and leads each brought in |
tool_runs:read | An agent's tool runs across every tool: which tool, how it went, the conversation it ran in and the ad behind it, and what was sent and received |
These scopes aren't issued yet. When they are, keys holding * keep working unchanged. usage:read, analytics:read, ads:read and tool_runs:read have no write scope: the API reads your plan and usage, your analytics, your ads and your tool runs, and never changes them. GET /v1/me needs none: any valid key can describe itself, and its reference page shows x-scope: none.
A request without the required scope returns 403 insufficient_scope with a required_scope field telling you exactly what was missing.
Can I restrict a key to specific agents?
Not from the dashboard yet. Every key you create there works on every agent in your organization, including agents added later, and the API Keys page shows it as All agents. A key that does carry an agent list can act only on those agents: a request for another agent of your organization returns 403 agent_not_authorized, and another organization's agent returns 404 agent_not_found. On the WhatsApp send endpoints, which take agent_id in the body, any agent outside the key's list returns 403 agent_not_authorized, whichever organization it belongs to. A message's status follows the list too: GET /v1/whatsapp/messages/{id} for a message sent through an agent outside it returns 404 message_not_found, the same as an unknown id.
GET /v1/me shows a key's agent list as agent_ids (null means every agent), and GET /v1/agents lists the agents it can act on now. See Your Key and Agents.
Until the dashboard offers the choice, use one key per integration, so you can revoke one without affecting the others.
A key with an agent list is also held to it for what agents share. An older knowledge base can still be linked to several agents (a new one belongs to the agent it is added to), so such a key can change a knowledge base only when it can act on every agent that uses it (403 shared_with_other_agents otherwise). The same goes for a custom API tool's site login, which the tools of several agents can use: such a key can add a tool to it, or change it, only when it can act on every agent whose tools use it (403 shared_with_other_agents otherwise).
Some reads cover your whole organization, whatever the key's agent list: your plan and usage, and your team. A key with an agent list still sees every teammate, but each teammate's agent_ids shows only the agents on the key's list.
What can a key do?
A key acts for your organization with the access of an agent admin on its agents. It reads and changes most of what an agent admin can in the dashboard, from an agent's settings to its leads, tickets, knowledge, attachments, saved replies and channels, and it reads your team, your plan and your usage. It never creates or deletes agents, and it never manages your billing or API keys. It manages your team only when it works on every agent and its creator is still the owner or an admin with every agent; removing someone takes a key created by the owner.
- Agents: list and read them, and change an agent's name, description, Main Instructions, time zone, AI handoff, AI auto-disable, AI working hours and comment auto-hide. Not its status, AI model, model provider, picture or language (
422 field_not_writable). - WhatsApp: send messages (text, a file or both) and templates, list a number's templates, create, edit and delete them and follow Meta's review, send broadcasts and follow each message (plans with broadcasts), and look up a message's status.
- Contacts and notes: read and update contacts; read and add notes, and edit or delete the ones the key's creator wrote.
- Leads: read, create, update, assign, pin and delete leads, and change the status of many leads at once; add, change and delete the agent's custom lead fields; and change the AI's lead capture prompt.
- Tickets: read, open, update, assign and delete tickets, and change the status of many tickets at once; add, change and delete the agent's custom ticket fields; and change the AI's ticket capture prompt and whether a new ticket switches the AI off. See Tickets.
- Knowledge: read, add, edit and delete knowledge bases.
- Conversations: list them and read their messages, reply to customers as your team with text, a file or both, open, close or archive a conversation and mark it read or unread, switch the AI off in it or end its pause, mark it urgent or resolved, and assign it. Not search inside message history.
- Comments: read an agent's Facebook and Instagram comments with their replies and moderation, and hide or show them.
- Channels and follow-ups: list an agent's connections and switch the AI on or off on each, read and change follow-up settings, and get the website widget and its embed code.
- Custom API tools: add, change, test, switch on and off and delete an agent's custom API tools, change their sites' logins, and read their runs (paid plans).
- AI attachments: list and read the photos, albums, videos and documents an agent's AI sends, and get links to their files; add, change, switch on and off and delete them, and upload their media or import it from links. See AI Attachments.
- Uploads: stage a file for 24 hours and use its
urlin any field that takes a media link, for a file that isn't online. See Uploads. - Saved replies: list, create, replace, switch off and delete the saved replies your team sends from the inbox, and put their media on them from links or uploads. See Saved Replies.
- Reports: read an agent's daily analytics, and your organization's plan and usage.
- Team: list your teammates with their names, roles and emails, and who can open each agent. With a key on every agent whose creator manages the team: list, send, resend and cancel invitations, change people's role or agents, and, with a key created by the owner, remove them; never an owner or the key's creator. See Your Team.
Deleting a lead, a ticket, a WhatsApp template, an AI attachment or a saved reply (with its files) is permanent, with no undo, and so is changing the status of many leads or tickets at once. A key never deletes contacts or conversations, never connects or disconnects channels, and never changes the website widget.
Where Mojeeb records a person, such as a note's author, who changed a lead's or ticket's status or who assigned a lead or ticket, it records the person who created the key. Unlike a teammate's edit, an edit through the API never assigns an unassigned lead or ticket to anyone. Only the assign endpoints do: POST /v1/agents/{agentId}/leads/{leadId}/assign, POST /v1/agents/{agentId}/tickets/{ticketId}/assign, which assigns the ticket only, and POST /v1/agents/{agentId}/conversations/{conversationId}/assign, which assigns the conversation's lead with it. A reply through the API never assigns the conversation either.
What happens when authentication fails?
Every authentication failure returns HTTP 401 with the standard error envelope. A single code (invalid_api_key) covers every sub-case of a key — the message field disambiguates for humans. An AI assistant's sign-in token that has expired or whose connection ended answers invalid_token, with a WWW-Authenticate header that tells the assistant to renew it or sign in again. One exception: when Mojeeb couldn't check the key at all, the 401 carries type: internal_error and code: internal_server_error; retry with backoff and don't rotate the key.
| Sub-case | message |
|---|---|
Missing Authorization header | Missing Authorization header. Send 'Authorization: Bearer mk_live_...'. |
| Wrong scheme (e.g. Basic) | Authorization header must use the Bearer scheme. |
| Malformed, unknown, revoked, or expired key | The API key is invalid, malformed, or revoked. |
Example response:
{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid, malformed, or revoked.",
"correlation_id": "req_01KQER73VQBSZK5RPVZCPW221V"
}
}
Common questions
Should I rotate keys regularly?
Yes. Treat API keys like database credentials — rotate every 90 days, rotate immediately if a key may have leaked, and use separate keys for separate environments and integrations so revocation has narrow blast radius.
Can a key read my teammates' emails?
Yes. GET /v1/organization/members and GET /v1/agents/{agentId}/members return each teammate's name, role and email, never their phone number, to any key with team:read, which every key holds today. Keep keys on your servers, and revoke a key that may have leaked.
Can I use the same key from multiple servers?
Yes. The key isn't IP-bound. The rate limit (default 60 req/min) is per key, so multiple servers sharing one key share the budget. For independent rate budgets, issue separate keys.
Is there a sandbox/test environment?
Not yet. The test_ environment marker is reserved in the key format but not currently issued. Develop against a test agent in your organization in the meantime, and use idempotency keys on WhatsApp sends so retries during development don't multiply them.
What's the difference between API key auth and the dashboard's JWT?
The dashboard authenticates users via JWT issued at login. The public API authenticates servers via long-lived API keys, and AI assistants via their sign-in. Internally all three produce the same authorization context — the same per-agent permission checks apply — but API keys and assistant sign-ins can't be used in the browser dashboard, and the dashboard's JWTs can't be used against /v1/ endpoints.