API Key Management API
Create, list, update, protect, disable, roll and revoke workspace API keys with the Roboflow REST API, the roboflow api-key CLI, or the MCP server.
You can manage your workspace's API keys in code: create keys, list and inspect them, rename them, attach metadata, set a rotation schedule, and disable, protect, roll or revoke them. To do the same in the dashboard, see Manage API Keys in the Dashboard.
The roboflow api-key CLI and the Roboflow MCP server use the same endpoints, so an agent can create the key an application needs without anyone copying it from the dashboard.
HTTP API
Authentication
Send a private API key as the api_key query parameter or an Authorization: Bearer header, as on every other endpoint (see Authenticate with the REST API). The key must belong to the workspace in the path. Each endpoint below lists the scope it needs. An unscoped (full-access) key has all of them.
With an OAuth token acting for a user, the user's role must also allow the action. By default only workspace owners and admins can manage API keys. A scoped key or an OAuth token can only grant abilities the caller already has (see Privilege Subset Rules).
List API Keys
Lists the workspace's keys, masked, and the workspace publishable key. Disabled keys are left out unless you pass includeDisabled=true.
Lists the workspace's API keys with masked metadata, and returns the workspace publishable key. Requires api-key:read. With an OAuth token, the user's role must allow viewing workspace API keys (owners and admins by default).
Roboflow API key or OAuth access token.
Workspace URL slug.
Set to true to include disabled keys.
falseSet to true to add folder names (folders) to folder-scoped keys.
falseSuccessful response.
The workspace publishable key, rf_ followed by the workspace id.
The request is invalid.
Authentication is missing or invalid.
The OAuth user's role does not allow viewing API keys.
The credential lacks the route's scope or the workspace is not the credential's.
The request rate is too high.
GET /{workspace}/api-keys HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"apiKeys": [
{
"keyId": "9f8c1a2b3d4e5f60",
"name": "production-server",
"prefix": "abcd",
"scopes": [
"model:infer"
],
"folderIds": [],
"default": false,
"protected": true,
"disabled": false,
"created_on": "2026-06-19T18:24:01.000Z",
"rotationDueAt": "2027-06-19T12:00:00.000Z",
"owners": [
"user_abc123"
],
"created_by": "user_abc123",
"customMetadata": {
"env": "prod"
}
}
],
"publishableKey": "text"
}Get a Single API Key
Returns masked metadata for one key, addressed by its keyId.
Returns masked metadata for one key. Requires api-key:read.
Roboflow API key or OAuth access token.
Workspace URL slug.
The key's keyId handle, from the list response. Never the secret key value.
9f8c1a2b3d4e5f60Successful response.
The request is invalid.
Authentication is missing or invalid.
The OAuth user's role does not allow reading API keys.
No active key with that keyId in the workspace (including one that was already rolled or revoked), or the credential lacks the route's scope, or the workspace is not the credential's. A folder-scoped caller also gets 404 for a key outside its folders.
The request rate is too high.
GET /{workspace}/api-keys/{keyId} HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"apiKey": {
"keyId": "9f8c1a2b3d4e5f60",
"name": "production-server",
"prefix": "abcd",
"scopes": [
"model:infer"
],
"folderIds": [],
"default": false,
"protected": true,
"disabled": false,
"created_on": "2026-06-19T18:24:01.000Z",
"rotationDueAt": "2027-06-19T12:00:00.000Z",
"owners": [
"user_abc123"
],
"created_by": "user_abc123",
"customMetadata": {
"env": "prod"
}
}
}Create an API Key
Creates a key. Leave out scopes to give the new key the same access as the credential that calls the endpoint. This works on every plan, so a script behaves the same whether or not the workspace has Advanced API Keys.
Creates an API key and returns its secret once in key. Requires api-key:create. The new key can never have more scopes or folders than the caller. Sending a scopes array, folderIds, customMetadata, rotationDueAt or owners requires Advanced API Keys; omitting scopes or sending null does not.
Roboflow API key or OAuth access token.
Workspace URL slug.
Every field is optional. An empty body creates a key with the caller's own scopes and folders. Unknown fields return 400.
Display name for the key.
Limits the key to these scopes. Omitted: the key gets the calling credential's own scopes, on every plan. A full-access caller creates a full-access key. null: an unscoped (full-access) key. The caller must have full access itself. []: a valid key with no abilities, which you can grant scopes to later. A list: exactly those scopes. A section name (ex: model) grants all of that section's scopes. A role preset (ex: role:reviewer, or a custom role's name after role:) expands to that role's scopes, and role:owner means full access. Presets combine with explicit scopes. Sending an array (including []) requires Advanced API Keys.
["model:infer"]Limits the key to these project folders. Omitted, the key gets the caller's folders. A key for every folder needs a caller who can see every folder. A non-empty list requires Advanced API Keys.
Creates the key protected. See Protecting a Key.
Rotation due date as an ISO date or date-time (UTC), strictly in the future (ex: 2027-10-22). The owners get one reminder email in the 15 days before it. Requires Advanced API Keys.
2027-10-22Member ids to remind before rotationDueAt. Omitted while signed in with Advanced API Keys, you become the only owner if you can roll the key yourself from an enabled account with an email address. Omitted with an API key, the list stays empty. Each id must be a member who can roll the key (see List Owner Candidates). An empty list reminds everyone who can roll the key. Requires Advanced API Keys.
Created.
The new key's non-secret handle.
The secret key value. Returned only in this response. Store it now: no endpoint returns it again.
Display name.
Stored scopes, after role presets and sections expand. null for a full-access key.
Folders the key is limited to.
True when the key is protected.
Rotation due date, or null.
Member ids reminded before the due date.
The workspace publishable key.
The body is invalid (ex: an unknown scope or role, an unknown field, malformed metadata, a past due date).
Authentication is missing or invalid.
The request asks for scopes or folders the caller does not hold, the plan lacks Advanced API Keys for a field you sent, or an OAuth caller's role does not allow the action.
The credential lacks the route's scope or the workspace is not the credential's. Also returned when a folderIds entry does not exist.
The request rate is too high.
POST /{workspace}/api-keys HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 107
{
"name": "production-server",
"scopes": [
"model:infer"
],
"rotationDueAt": "2027-10-22",
"owners": [
"user_abc123"
]
}{
"keyId": "9f8c1a2b3d4e5f60",
"key": "AbCdEf0123456789xyz",
"name": "production-server",
"scopes": [
"model:infer"
],
"folderIds": [],
"protected": false,
"rotationDueAt": "2027-10-22T00:00:00.000Z",
"owners": [
"user_abc123"
],
"publishableKey": "rf_5f3Tq8k2ZbW1aXyZ"
}Update an API Key
Changes a key's name, scopes, metadata or rotation schedule, protects it, or disables or re-enables it. Send only the fields you want to change. scopes, customMetadata and owners replace the current values.
Updates a key's name, scopes, metadata or rotation schedule, protects it, or disables or re-enables it. Requires api-key:update. Changing scopes, metadata, disabled, rotationDueAt or owners requires Advanced API Keys.
Roboflow API key or OAuth access token.
Workspace URL slug.
The key's keyId handle, from the list response. Never the secret key value.
9f8c1a2b3d4e5f60Send only the fields you want to change. Omitted fields stay as they are. An empty body or an unknown field returns 400.
New display name. Renaming needs no plan feature.
Replaces the key's scopes. null makes the key full access (the caller must have full access). [] leaves a valid key with no abilities. A list sets exactly those scopes; section names and role: presets expand as on create. The new scopes must be a subset of the caller's. Refused with 409 on a protected key. Requires Advanced API Keys.
["model:infer","project:read"]Send true to protect the key. false returns 403: you can only unprotect a key in the dashboard.
true disables the key, false re-enables it. Disabling a protected key, or a key that backs a Dedicated Deployment, returns 409. Requires Advanced API Keys.
Rotation due date as an ISO date or date-time (UTC), strictly in the future (ex: 2027-10-22). The owners get one reminder email in the 15 days before it. null clears it. The key's current date is accepted even when it is already past. Requires Advanced API Keys.
Replaces the members reminded before the due date. Each id must be a member who can roll the key (see List Owner Candidates). An empty list reminds everyone who can roll the key. Requires Advanced API Keys.
Successful response.
The body is empty or invalid (ex: an unknown scope, an unknown field, a past due date).
Authentication is missing or invalid.
The body sends "protected": false, asks for scopes the caller cannot grant, needs Advanced API Keys, or an OAuth caller's role does not allow the action.
No active key with that keyId in the workspace (including one that was already rolled or revoked), or the credential lacks the route's scope, or the workspace is not the credential's. A folder-scoped caller also gets 404 for a key outside its folders.
The key is protected and cannot be disabled or given new scopes, or it backs a Dedicated Deployment and cannot be disabled.
The request rate is too high.
PATCH /{workspace}/api-keys/{keyId} HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 22
{
"name": "renamed-key"
}{
"apiKey": {
"keyId": "9f8c1a2b3d4e5f60",
"name": "production-server",
"prefix": "abcd",
"scopes": [
"model:infer"
],
"folderIds": [],
"default": false,
"protected": true,
"disabled": false,
"created_on": "2026-06-19T18:24:01.000Z",
"rotationDueAt": "2027-06-19T12:00:00.000Z",
"owners": [
"user_abc123"
],
"created_by": "user_abc123",
"customMetadata": {
"env": "prod"
}
}
}Revoke an API Key
Revokes a key permanently. Applications that use it fail to authenticate right away.
A key that backs a Dedicated Deployment cannot be revoked. Give the deployment another key first, or roll the key instead. Nothing else blocks the call, so check the dashboard's dependency warning and your own consumers first. Audit Logs record the revoke with the dependencies the key had at the time. They do not record the key's inference or read traffic, so they cannot tell you who still uses it.
Revokes the key permanently. Anything that uses it fails to authenticate at once. Requires api-key:revoke.
Roboflow API key or OAuth access token.
Workspace URL slug.
The key's keyId handle, from the list response. Never the secret key value.
9f8c1a2b3d4e5f60Successful response.
The keyId you sent.
The request is invalid.
Authentication is missing or invalid.
The OAuth user's role does not allow revoking API keys.
No active key with that keyId in the workspace (including one that was already rolled or revoked), or the credential lacks the route's scope, or the workspace is not the credential's. A folder-scoped caller also gets 404 for a key outside its folders.
The key is protected, or it backs a Dedicated Deployment. Unprotect it in the dashboard, or give the deployment another key or roll the key instead.
The request rate is too high.
DELETE /{workspace}/api-keys/{keyId} HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"status": "revoked",
"keyId": "9f8c1a2b3d4e5f60"
}Roll an API Key
Revokes the key and creates its replacement in one call. Dedicated Deployments that run on the old key move to the new one. See Rotate API Keys for when to roll and what to check first.
If a deployment cannot be moved, the call fails with The API key was not rolled (409, 423 or 502) and the old key stays live. A replacement with the same name may have been created and kept active, so list the keys before you retry.
The replacement gets a new keyId, and nothing links it to the old key afterwards. Store keyId and revokedKeyId from the response if you need to trace the rotation. The old key stops working as soon as the call returns.
Revokes the key and creates its replacement in one call, and returns the new secret once in key. The replacement keeps the key's name, scopes, folders, metadata and disabled state, and Dedicated Deployments on the key move to it. Requires both api-key:revoke and api-key:create, and the caller must hold at least the key's scopes and folders.
Roboflow API key or OAuth access token.
Workspace URL slug.
The key's keyId handle, from the list response. Never the secret key value.
9f8c1a2b3d4e5f60Optional rotation schedule for the replacement. Send no body to carry the old key's schedule over. Both fields require Advanced API Keys.
The replacement's rotation due date (ISO date or date-time, UTC, in the future), or null for none. Omitted, the replacement is due the same number of days after the roll as the old key was after its creation, up to one year. A key without a date stays without one.
The replacement's owners. Omitted, the old key's owners carry over. An empty list reminds everyone who can roll the key.
Successful response.
The replacement's new handle. Nothing links it to the old key afterwards, so store both ids if you need to trace the rotation.
The replacement's secret value. Returned only in this response.
Display name, kept from the old key.
Scopes, kept from the old key. null for full access.
Folders, kept from the old key.
Always false: a protected key cannot be rolled.
True when the old key was disabled. A disabled key rolls to a disabled key.
The replacement's rotation due date, or null.
The replacement's owners.
The keyId of the key that was revoked.
The body is invalid (ex: an unknown field or a past due date).
Authentication is missing or invalid.
The caller cannot grant the key's scopes or folders, the plan lacks Advanced API Keys for a field you sent, or an OAuth caller's role does not allow the action.
No active key with that keyId in the workspace (including one that was already rolled or revoked), or the credential lacks the route's scope, or the workspace is not the credential's. A folder-scoped caller also gets 404 for a key outside its folders. A second roll of the same keyId gets this once the first roll has finished.
The key is protected, another roll of it is in progress, it is disabled while it backs a Dedicated Deployment, or a Dedicated Deployment on it is still being created. The key was not rolled.
A Dedicated Deployment on the key belongs to a folder whose usage is paused, so it could not be moved. The key was not rolled.
The request rate is too high.
The deployment service failed while moving a Dedicated Deployment. The key was not rolled, but a replacement with the same name may exist. The error sets "retryable".
POST /{workspace}/api-keys/{keyId}/roll HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 55
{
"rotationDueAt": "2027-10-22",
"owners": [
"user_abc123"
]
}{
"keyId": "0a1b2c3d4e5f6071",
"key": "NewSecretValue0123456789",
"name": "production-server",
"scopes": [
"model:infer"
],
"folderIds": [],
"protected": false,
"disabled": false,
"rotationDueAt": "2027-10-22T12:00:00.000Z",
"owners": [
"user_abc123"
],
"revokedKeyId": "9f8c1a2b3d4e5f60"
}List Owner Candidates
Lists the members who can roll a key. Only these members can be a key's owners on create, update or roll. Call it before you set owners, so the rotation reminder reaches someone who can act on it.
Lists the members who can roll a key, which are the only members you can set as its owners. Requires api-key:create or api-key:update, and Advanced API Keys. You must be able to grant the key's folders.
Roboflow API key or OAuth access token.
Workspace URL slug.
The keyId of an existing key. Do not send with folderIds.
9f8c1a2b3d4e5f60Folder ids for a key you are about to create, comma-separated or repeated. Do not send with keyId. Send neither for a key that reaches every folder, which needs a caller who can see every folder.
folderA,folderBSuccessful response.
Both keyId and folderIds were sent.
Authentication is missing or invalid.
The plan lacks Advanced API Keys, the caller cannot grant the folders, or an OAuth caller's role does not allow the action.
No active key with that keyId in the workspace (including one that was already rolled or revoked), or the credential lacks the route's scope, or the workspace is not the credential's. A folder-scoped caller also gets 404 for a key outside its folders.
The request rate is too high.
GET /{workspace}/api-keys/owner-candidates HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"members": [
{
"uid": "user_abc123",
"email": "ada@example.com",
"name": "Ada"
}
]
}Protecting a Key
A protected key cannot be disabled, revoked or rolled from the API, the CLI, the MCP server or the dashboard, and its scopes cannot change, until someone unprotects it. Use it to stop an automated agent from taking down a production key by mistake.
Protect: send
{ "protected": true }to Update an API Key.Unprotect: only in the dashboard. The API, CLI and MCP server cannot unprotect a key, so a compromised or careless agent cannot remove the protection and then revoke the key.
The Publishable Key
Every workspace has a publishable key of the form rf_<workspaceId>. It is:
Not a secret: you can put it in browser code (ex: inferencejs).
Limited to inference and model downloads: it cannot manage data, train, or manage keys.
Permanent: it comes from the workspace ID, so you cannot create, rotate or revoke it.
The list and create responses include it as publishableKey, or you can read it on its own:
Returns the workspace publishable key. Requires workspace:read. A folder-scoped key gets 404: read publishableKey from the list or create response instead.
Roboflow API key or OAuth access token.
Workspace URL slug.
Successful response.
rf_ followed by the workspace id. Not a secret: it can only run inference and download models.
The request is invalid.
Authentication is missing or invalid.
The credential does not have access to this resource.
The credential lacks the route's scope or the workspace is not the credential's. Also returned for a folder-scoped credential.
The request rate is too high.
GET /{workspace}/api-keys/publishable HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"publishableKey": "rf_5f3Tq8k2ZbW1aXyZ"
}Use the publishable key for browser and edge inference, and a scoped private key for server work. Anyone with the publishable key can run inference with and download the workspace's models. That is the intended trade-off.
Privilege Subset Rules
A key you create or update can never have more abilities than the credential that creates it:
With a scoped private key, the new key's
scopesmust be a subset of the calling key's scopes, and itsfolderIdsa subset of the calling key's folders. An unscoped (full-access) key can grant anything.With an OAuth token acting for a user, the requested scopes are also checked against that user's role. You can only grant abilities your role allows.
A key for all folders (no
folderIds) needs a user who can see every folder. Workspace owners without All Folder Access must list the folders the key can reach. This also applies when you create a key in the web app.
Requests that go past what the caller can grant return 403.
Errors
Each endpoint above lists its error statuses. Two things apply to all of them:
A credential that lacks the route's scope gets
404, not403, so Roboflow does not reveal whether the resource exists. A403means the caller can manage keys but asked for more than it has, or the plan lacks Advanced API Keys.There are two error body shapes. Most errors return a string,
{"error": "Some message"}. The authentication layer returns an object,{"error": {"message": "...", "type": "...", "hint": "..."}}, for a missing or invalid key (401) and for a missing scope or wrong workspace (404). Handle both.
See Errors and Status Codes for the general error format.
CLI
The roboflow api-key command group lets you manage your workspace's API keys from the terminal. It wraps the API key REST endpoints and uses the workspace and credentials from your CLI config (see Install and Set Up the CLI).
list
List the workspace's API keys.
get
Show details for one key.
create
Create a new key (prints the secret once).
update
Update a key's name, scopes, metadata or rotation schedule.
protect
Mark a key as protected.
disable
Disable or re-enable a key.
revoke
Permanently revoke a key.
roll
Revoke a key and create its replacement (prints the new secret once).
publishable
Print the workspace publishable key.
Add --json (a global flag, before the command) to get machine-readable output for scripting, e.g. roboflow --json api-key list.
List keys
Get one key
Keys are addressed by their keyId (the non-secret handle shown in list):
Create a key
The secret is printed once. To capture it in a script, use --json and pipe to jq:
Update a key
--scope replaces the key's existing scopes with exactly the set you pass, --metadata replaces the key's metadata, and --owner replaces its owners. --clear-owners leaves the list empty, so everyone who can roll the key is reminded. Send --name on its own to rename without touching the rest.
Protect / unprotect a key
A protected key cannot be disabled, revoked or rolled via the CLI, API, or MCP. Unprotecting can only be done in the dashboard. There is intentionally no unprotect command, so an automated workflow cannot remove the safety and revoke a production key in one step.
Disable / re-enable a key
Disabled keys are rejected by the API but can be re-enabled. A protected key cannot be disabled.
Revoke a key
Revoking is permanent. A protected key cannot be revoked from the CLI: unprotect it in the dashboard first. A key that backs a Dedicated Deployment cannot be revoked until the deployment gets another key.
Roll a key
Rolling revokes the key and creates its replacement in one step. The replacement keeps the old key's name, scopes, folders and metadata, and the old value stops working immediately. If a Dedicated Deployment cannot be moved to the replacement, the command fails with "The API key was not rolled", the old key stays live, and a replacement may already exist, so run list before retrying. Omit --rotation-due-at and --owner to carry the old key's schedule over. Capture the new secret from the output, or with --json:
A protected key cannot be rolled from the CLI: unprotect it in the dashboard first. A key can be rolled once. Afterwards its keyId is no longer found, and the replacement's keyId in list carries no link back to it, so record both ids from the roll output. See Rotate API Keys for the full cutover procedure.
Get the publishable key
The publishable key (rf_<workspaceId>) is non-secret and safe to embed in browser / inferencejs code. It is inference-only and cannot be created or revoked. See The Publishable Key for details.
MCP Server
Connect your AI agent to the MCP Server and it can manage API keys with these tools:
api_keys_list
List all API keys for the workspace.
api_keys_get
Get metadata for a single key.
api_keys_get_publishable
Get the workspace's publishable key.
api_keys_create
Create a new API key.
api_keys_update
Update a key's name, scopes, metadata or rotation schedule.
api_keys_protect
Mark a key as protected.
api_keys_disable
Disable or re-enable a key without revoking it.
api_keys_revoke
Permanently revoke a key.
api_keys_roll
Revoke a key and create its replacement in one step. Returns the new secret once.
api_keys_owner_candidates
List the members who can roll a key, so an agent only sets owners the reminder can reach.
The MCP Server cannot unprotect a key. A protected key stays protected until a person unprotects it in the dashboard.
api_keys_create and api_keys_roll return the new secret to the agent, so it ends up in that agent's conversation and logs. Treat those transcripts as sensitive, or create keys from the dashboard instead.
Last updated
Was this helpful?