Authentication
Key types and prefixes, the Authorization header, scopes, sessions, rotation and what never to put in a browser.
Mendloop has two kinds of key and one kind of session. Create and revoke keys in Settings → API keys (or with the API keys endpoints). A key is shown in full once, when it's created; after that only its prefix.
Key types#
| Kind | Looks like | Scopes | Use it for | Safe in a browser? |
|---|---|---|---|---|
| Publishable | pk_live_…, pk_test_… |
events:write only |
SDKs in browsers and mobile apps, the DSN | Yes. It can only send events. |
| Secret | sk_live_…, sk_test_… |
Any of the scopes below | The REST API, CI, the source map CLI, server-side ingest | No |
A key is its prefix plus 40 random letters and digits. live or test in the prefix decides the mode of every
request made with it.
A key can be bound to one project (project_id) or be org-wide. A publishable key bound to a project only
sends to that project.
Sending a secret key#
Authorization: Bearer sk_live_…Any other scheme, or an empty value, is 401 invalid_authorization. A publishable key on the REST API is
401 publishable_key.
Sending a publishable key (ingest)#
| Endpoint | Where the key goes |
|---|---|
POST /api/{ingest_id}/envelope/, POST /api/{ingest_id}/store/ |
X-Sentry-Auth: Sentry sentry_key=pk_…, sentry_version=7, or Authorization: Sentry sentry_key=pk_…, or ?sentry_key=pk_…. For envelopes, the dsn in the envelope header also works. |
POST /v1/events |
X-Mendloop-Key: pk_… or Authorization: Bearer pk_… |
A secret key with events:write also works on these endpoints, but keep secret keys on servers.
Scopes#
Scopes apply to keys. Give a key only the scopes it needs.
| Scope | Allows |
|---|---|
events:write |
Send events to ingest. The only scope a publishable key can have. |
issues:read |
Read issues, events, releases, root causes, fix runs, pull requests, tickets, workflows and runs |
issues:write |
Change issues (status, assignee, severity, ignore, merge, unmerge, bulk), re-run triage, send a test event, start, rate and regenerate root causes, create, transition and comment on tickets, start fixes |
projects:read |
List projects |
projects:write |
Create and rename projects |
sourcemaps:write |
Upload and delete source maps and release files |
audit:read |
Read the audit log |
releases:write |
Accepted when creating a key; no endpoint checks it yet |
analytics:read |
Accepted when creating a key; no endpoint checks it yet |
Keys act with their owner's role#
A secret key is also limited by the role of the person who created it. A request passes only when the key has
the scope and that person's role allows the action. For example, a key with audit:read created by a
Developer reads only that Developer's own audit rows. If its creator leaves the organization the key gets
404 org_not_found; if their account is disabled, 403 api_key_owner_removed.
Developers can only create personal keys in test mode. Admins can create any key.
What a secret key can't do#
These need a signed-in session; a secret key gets 403 api_key_not_allowed:
- members, invites, teams, identities, policies and test targets
- API keys themselves
- connections, verify runs, webhook deliveries and tracker settings
- approvals and decisions, reverting pull requests
- creating, editing and publishing workflows; cancelling and retrying runs
- saved views and the live update stream
The "Auth" line on each endpoint says which applies.
Sessions#
The web app signs in with a session cookie, ml_session (httpOnly, SameSite=Lax). Session requests choose the
mode with the Mendloop-Mode header. Writes made with a session cookie must come from the web app's origin
or the API's own origin; any other Origin gets 403 origin_not_allowed. For scripts, use a secret key.
Rotation#
To rotate a secret key: create a new key with the same scopes, deploy it, then revoke the old one. Revoking is immediate; ingest stops accepting a revoked key too.
To rotate a publishable key: create a new one for the project, ship it in your next release, then revoke the old one once traffic on it stops. Only that project is affected.
Never put a secret key (sk_…) in a browser bundle, a mobile app, a public repository or a client-side
environment variable. Anyone who reads it can act with its scopes and its creator's role. In front-end code
use only the DSN or a publishable key.
The REST API only answers CORS requests from the web app's origin. Browser code on other sites can't call it, by design. Ingest answers CORS from any origin, without credentials.