Skip to main content
POST
Issue an API key
Issues a key and returns its secret once. No later request returns it — the secret is stored only as a hash. Save it before you do anything else; if you lose it, revoke the key and issue another. This is how an integration gives a job less authority than it has itself: a nightly export that only reads leads gets a key that can only read leads, so a mistake in that job cannot place a call or spend a shekel.

The first key is made by a person

This endpoint issues the second key onward, never the first. It needs api_keys:manage, and that scope can only be put on a key in the dashboard, by a workspace owner or admin under Settings → API Keys: tick API keys → Manage (or pick Full access) when you create a key, or tick it on an existing key under Edit scopes. There is no bootstrap endpoint and no way to earn the scope from code, by design: it is the one scope that can widen the whole workspace. So the pattern this page describes starts with one manual step and is code from then on:
1

Once, in the dashboard

Create a key with API keys → Manage ticked, or tick API keys → Manage on an existing key under Edit scopes. Store its secret wherever the integration keeps credentials. This is the only key that can reach /api-keys.
2

Per job or per client, from code

Call POST /api-keys with that key to issue a narrow key — one client, one job, one set of scopes.
3

Rotate from code

Issue the replacement under a new name — a name belongs to one active key, compared without regard to case — move the job over, then DELETE /api-keys/{id} the old one. Both keys work until you revoke the old one, so nothing stops in between. A key cannot revoke itself. In the dashboard, Rotate on a key’s card does all of this in one step: the new secret keeps the key’s name, permissions and agents, and its end date unless you pick another, and the old secret keeps working for the grace you pick — up to 7 days, shown as its expires_at, under the name <name> (old) — or stops at once, for a secret that leaked.
There is no update endpoint. A key’s scopes, agents and end date are changed in the dashboard, under Settings → API keys → Edit scopes; PATCH /api-keys/{id} answers 405 and says so, whatever scopes the calling key holds. From code, the equivalent is the rotation above: issue the key you want, move over, revoke the old one. If you are onboarding clients into separate workspaces, each workspace needs its own step 1: a key is scoped to one workspace and cannot issue keys in another.

What a new key may hold

scopes is required and has no default. A key is issued with exactly what you ask for. Any field this page does not list is refused by name with 400 API_KEY_REQUEST_INVALID, so a typo can never leave you believing a key is narrower than it is. Subset. You can only grant scopes the calling key holds. A key with leads:read cannot issue a key with calls:create; the refusal names the scopes that went beyond, so you know which one to fix. api_keys:manage is never granted here. A key issued through the API can never issue keys of its own, even when the key issuing it can. That keeps key issuance one generation deep and always starting with a person in the dashboard. If a key genuinely needs to issue keys, tick API keys → Manage when you create it in the dashboard, under Settings → API keys. api_keys:read is granted here like any other scope. An integration that should be able to audit the inventory — which keys exist, what each one can do, when each was last used — without being able to issue or revoke one gets api_keys:read and nothing else. Manage includes Read: a key holding api_keys:manage can grant api_keys:read even when Read was never ticked on it, since it already reads the list. In the dashboard, ticking API keys → Manage ticks Read with it. calls:metrics is the calls read without the people on them — counts, durations, outcomes and cost, with every number, name, summary, transcript, recording and collected value withheld (see the scope table). Read includes Metrics: a key holding calls:read can grant calls:metrics, and in the dashboard ticking Calls → Read ticks Metrics with it. agent_ids limits the key to some agents. Leave it out, or send null, and the key reaches the whole workspace, as every key always has. Send 1–100 agent ids and it reaches only those agents, their calls, the leads they called, their spend, their deliveries and their campaigns — see Limiting a key to some agents. This is how an agency gives each client a key that cannot see another client’s calls. Every id must be a live agent in this workspace; an empty list is refused rather than guessed at. A key limited to agents is refused the scopes it could never use — those that open only routes belonging to the whole workspace, adding an agent or changing a lead: agents:create, tools:create, phone_numbers:*, billing:manage, dispositions:*, leads:manage, lead_tags:*, agent_eval:*, integrations:*, tool-connections:*, shared_links:*, do_not_call:*, sip_endpoints:*, call_windows:manage, affiliates:read, api_keys:* and carrier_accounts:* — with 400 API_KEY_REQUEST_INVALID naming each; they used to be issued and then refused with 403 on every use. tools:read and tools:update stay: they read and retry the key’s own deliveries, and billing:read reads its agents’ spend (GET /billing/consumption). The dashboard greys the same ones out under Only these agents and refuses them there too, on a new key and on an edit. expires_at gives the key an end date. Send an ISO 8601 date-time with a time zone — 2026-12-31T23:59:59Z — and from that moment every request made with the key answers 401 EXPIRED_KEY. Leave it out, or send null, for a key that works until it is revoked. A moment that has passed, or a date without a time zone, is refused rather than guessed at. An expired key stays in the list, with its expires_at, until you revoke it. Required scope: api_keys:manage.

Example request

A key for one client of an agency — its calls and nothing else:
A contractor’s key that stops working at the end of the year:

Example response

key appears in this response and in no other.

Testing a scope boundary

The pair of requests below is the whole check — issue a key without a scope, then watch the endpoint that needs it refuse:
Revoke the probe key with DELETE /api-keys/{id} when you are done.

Errors

Authorizations

Authorization
string
header
required

Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).

Body

application/json
name
string
required

Unique among this workspace's active keys, compared without regard to case (Client-A is taken while client-a is live). The only handle you have on the key afterwards.

Maximum string length: 100
Example:

"Nightly lead sync"

scopes
string[]
required

A subset of the calling key's own scopes (api_keys:read counts as held by a key with api_keys:manage). api_keys:manage is not accepted.

Minimum array length: 1
Example:
agent_ids
string<uuid>[] | null

Limit the key to these agents — live agents in this workspace. Leave it out or send null for a key that reaches the whole workspace. An unknown id answers 400 API_KEY_AGENT_UNKNOWN and an empty list 400 API_KEY_REQUEST_INVALID.

Required array length: 1 - 100 elements
expires_at
string<date-time> | null

When the key stops working: an ISO 8601 date-time with a time zone, in the future. Leave it out or send null for a key that works until it is revoked. A past moment or a date without a time zone answers 400 API_KEY_REQUEST_INVALID.

Example:

"2026-12-31T23:59:59Z"

Response

Key issued. The only response that contains the secret.

An API key belonging to your workspace. The secret itself is stored only as a SHA-256 hash and is returned exactly once, by POST /api-keys; no read ever returns it. prefix is the first 16 characters of the secret and is what identifies a key in the dashboard list.

id
string<uuid>
name
string

What you called the key. Unique among this workspace's active keys, compared without regard to case.

Example:

"Nightly lead sync"

prefix
string

First 16 characters of the key, enough to tell two keys apart. Never the whole secret.

Example:

"ypr_live_9f2c41a"

scopes
string[]
Example:
agent_ids
string<uuid>[] | null

The agents this key is limited to, or null for a key that reaches the whole workspace. A limited key reaches those agents, their calls, the leads they called (read only), their spend, their deliveries and their campaigns, and calls only from numbers those agents answer or call from; everything the workspace shares answers 403 API_KEY_AGENT_SCOPED, and naming another agent answers 403 AGENT_OUTSIDE_KEY_SCOPE.

Example:

null

agents
object[] | null

The same agents as agent_ids, in the same order, each with its name — so a read says which client a limited key reaches. An archived agent keeps its name; an agent that no longer exists has name: null. null for a key that reaches the whole workspace.

Example:

null

created_at
string<date-time>
expires_at
string<date-time> | null

When the key stops working, or null for a key that works until it is revoked. Past this moment every request made with it answers 401 EXPIRED_KEY; the key stays listed until it is revoked.

Example:

null

last_used_at
string<date-time> | null

When this key last authenticated a request. null if it never has.

key
string

The full secret. This is the only response that ever contains it — store it before you do anything else. If you lose it, revoke the key and issue another.

Example:

"ypr_live_9f2c41a7b0e3…"