iMarioiMario
DocumentsAPI reference

Guides

API Overview and QuickstartAuthenticationSandbox and Test KeysAPI ErrorsPaginationIdempotent RequestsRate LimitsAPI VersioningWebhooks

Endpoints

All EndpointsWorkspaceAudiencesPeopleStudiesReportsLibraryFilesAuto StudiesConnectionsMembersAPI KeysWebhook Endpoints
Guides

Authentication

Make keys, choose what they may do, and know whom a key acts as and who pays for its calls.

Send the key

Every request carries a credential in the Authorization header:

curl https://api.imario.ai/v1/workspace \
  -H "Authorization: Bearer imk_..."

The header X-iMario-Key: imk_... works too. A request with no credential is refused with 401 missing_api_key. A key that is unknown, revoked or expired, or a personal key whose holder has left the workspace, is refused with 401 invalid_api_key.

A key belongs to one workspace and works only there.

Kinds of credential

CredentialStarts withMade byActs as
Personal keyimk_any member, for themselvesits creator, with the creator's role at the time of each call
Service account keyimk_an owner or adminthe workspace, with the role chosen when the key was made
Test key, personal or service accountimk_test_the same peoplethe same, in the sandbox only
OAuth access tokenimo_an app a member approvedthe member who approved it, with their current role

Personal keys suit one person's scripts and tools. A personal key never does more than its creator may: if the creator becomes a viewer, the key acts as a viewer from the next call. When the creator leaves the workspace or is removed, their personal keys stop working.

Service account keys suit production systems that should not depend on one person. Only an owner or admin can make one. It gets the role Admin, Editor or Viewer, never above the role of the person making it. The key belongs to the workspace and keeps working when its creator leaves.

Create a key

  1. Open the workspace, then Settings > MCP & API.
  2. Under API keys, select Create key.
  3. Fill in the dialog:
    • Name: what the key is for, such as "Nightly CI job".
    • Type: Personal, or Service account with its Role. Only owners and admins see this choice.
    • Mode: Live, or Test for the sandbox.
    • Access: Full access, Read only, or Custom to choose read and write for each resource.
    • Expires: Never, after 30 days, 90 days or 1 year, or a custom number of days up to 3,650.
    • Allowed IP addresses, optional: one address or CIDR range per line.
  4. Select Create key and copy the key. It is shown once; afterwards the list shows only its first characters.

Members see their own keys in the list. Owners and admins see every key of the workspace, with who made it, when it was last used and when it expires, and can narrow the list to their own with Show keys. A workspace holds at most 50 working keys, live and test together; one more is refused with 409 key_limit_reached. A service account cannot get a role above its maker's (403 service_role_too_high). Over the API, a service account's key can make only service-account keys (403 personal_key_needs_member), and a test key cannot make a live one (403 test_key_cannot_mint_live).

Owners and admins can also make keys from code, with POST /v1/api-keys and a live key that holds keys:write. A key made this way can never do more than the key that made it. See API keys in the reference.

Scopes and roles

A call needs two things: the key must hold the call's scope, and the key's role must reach the role that scope needs. A personal key's role is its creator's current role; a service account's role is the one it was given. A missing scope is refused with 403 insufficient_scope, a role that is too low with 403 role_not_allowed. Both errors name what was missing in required_scope or required_role. A test key is refused with 403 livemode_only on the calls that need members:write, keys:write or connections:write.

ScopeWhat it allowsLeast role
workspace:readThe workspace, the credit balance, today's API budget and the credit ledgerViewer
audiences:readAudiences, their people, one person's profile and the key's chat history with them (each key has its own conversation with each person)Viewer
audiences:writeCreate an audience, a sub-group or an audience from files, and rebuild oneEditor
studies:readEstimates, studies, results, responses and segmentsViewer
studies:writeRun and cancel studies, which spends creditsEditor
insights:writeThe AI read of a group in a study, which spends creditsViewer
reports:readReports, report estimates, downloads and share linksViewer
reports:writeWrite reports, which spends credits, make downloads and share linksViewer
library:readSurveys, discussion guides, announcements and filesViewer
library:writeCreate, change and delete them, and upload filesEditor
chat:writeSend a message to one person in an audience, which spends creditsViewer
auto:readAuto studiesViewer
auto:writeStart, steer, stop and continue Auto studies, which spends creditsEditor
connections:readConnected data sources and what each offersViewer
connections:writeStart a syncEditor
members:readThe workspace's membersAdmin
members:writeInvite, change roles and remove membersAdmin
keys:readThe workspace's API keysAdmin
keys:writeMake and revoke API keysAdmin
webhooks:readWebhook endpoints and their deliveriesAdmin
webhooks:writeCreate, change, test and delete webhook endpoints, and rotate their secretsAdmin

"Admin" means an owner or an admin. Viewers may spend credits on reports, the AI read of a group and chat with a person. Running studies, building audiences and starting Auto studies need an editor or above.

Full access holds every scope, so what the key can do is set by its role. Read only holds every :read scope: the key can never spend credits or change anything. Custom holds the scopes you choose. Keys made before scopes existed have full access.

The same scopes apply on the MCP server. A key with custom access needs audiences:read to list or read audiences, audiences:write to create one, studies:read to estimate or read a study, studies:write to run one and library:write to upload a file. Test keys work on the REST API only.

OAuth access tokens for apps

An app that serves other iMario users, rather than your own workspace, should not ask people to paste keys. It uses iMario's OAuth 2.1 server, the same one AI apps use to connect to the MCP server: authorization code with PKCE (S256). The server's metadata, with every endpoint, is at https://mcp.imario.ai/.well-known/oauth-authorization-server. An app registers itself there, or identifies itself by the https address of its own client metadata document.

The person signs in, chooses the workspace the app may reach and approves. The app receives an access token that starts with imo_ and lasts one hour, and a refresh token that lasts 60 days and is replaced each time it is used. Keep only the newest refresh token. A used one presented again within 60 seconds of its replacement is refused and the connection stays (the app lost the answer and retried); presented later, it revokes every token of the connection, and the app has to be approved again. The access token acts as the person who approved it, with their current role, in that workspace only, and is always live.

OAuth scopeAPI scopes it grants
mcp:readEvery :read scope except members:read, keys:read and webhooks:read
mcp:runThe same, plus studies:write, audiences:write, library:write, insights:write, reports:write and chat:write

A token never carries the members, keys or webhooks scopes, nor auto:write or connections:write: those stay with keys a member makes on purpose. The person can disconnect the app under Connected apps in Settings > MCP & API; its tokens stop working on the next request.

Limit where and how long a key works

  • Allowed IP addresses. A key with an allowlist works only from those addresses: IPv4 or IPv6, single addresses or CIDR ranges, up to 50 entries. A call from anywhere else is refused with 403 ip_not_allowed.
  • Expiry. An expired key is refused with 401 invalid_api_key. The key list shows each key's date; make the replacement before it.
  • Revoking. Select the bin icon next to a key and confirm Revoke. Members revoke their own keys; owners and admins can revoke any key. From code, an owner or admin calls DELETE /v1/api-keys/{id}. The key is refused from its next request. Revoking does not cancel a study the key already started.
  • Suspension. If the account a key acts for is suspended (the creator of a personal key, the workspace owner for a service account), its calls are refused with 403 account_suspended.

Who pays for a call

CredentialCredits come from
Personal key, OAuth tokenThe workspace's credit pool when the workspace pays from a pool, otherwise the member's own wallet
Service account keyThe workspace's credit pool, otherwise the workspace owner's wallet

Three limits sit on top of the balance:

  • Daily limit, set by an owner or admin in Settings > MCP & API: one ceiling for every API key and connected app of the workspace together, reset at 00:00 UTC. A call that would pass it is refused before it starts, with 402 daily_budget_exceeded. GET /v1/usage shows what is left today.
  • Member monthly caps in a workspace that pays from a pool apply to personal keys and OAuth tokens as they apply to the member in the app (402 member_cap_exceeded). A service account has no cap of its own; its studies, reports and AI reads are recorded under the workspace's owner, so a cap set on the owner applies to them (chat never counts against one).
  • Rate limits per key: see Rate limits.

Each charge appears in the credit ledger with the key that made it (api_key_id in GET /v1/credit-transactions).

See what a key did

API activity, on the same Settings page, lists the last 200 requests: time, key, method and route, status, duration and request id. Filter it by key. Members see requests made with their own keys; owners and admins see every key's. Each response also carries its request id in the Request-Id header (see API errors).

Keep keys secret

  • Call the API from a server only. Never put a key in a web page, a browser extension or a mobile app: anyone who opens it can read the key. If a browser needs results, your server calls the API and passes on what the page needs.
  • Keep keys in an environment variable or a secret manager. Never put one in a committed file, a ticket, a chat message or a support request.
  • Give each system its own key with only the scopes it needs, so you can revoke one without stopping the others.
  • To rotate a key, create the new one, switch your system to it, check in API activity that calls arrive with the new key, then revoke the old one.
  • If a key leaks, revoke it at once.
← API Overview and QuickstartSandbox and Test Keys →

On this page

Send the keyKinds of credentialCreate a keyScopes and rolesOAuth access tokens for appsLimit where and how long a key worksWho pays for a callSee what a key didKeep keys secret