New Ory Agent Security is now live! Claim your complimentary test drive. Get Started!

Skip to main content

Revoke an API key

info

Ory Talos Secure API Keys on Ory Network is in preview. The HTTP API is versioned v2alpha1, and request and response shapes can change. Pin the version of the Ory SDK that you use.

Revoke an API key in Ory Talos Secure API Keys to stop it from working, for example when the secret leaked or its owner left.

Before you begin​

  • To manage keys in the Ory Console, you need the Owner or Developer role in the project. Members with the Viewer role can't view keys or send requests from the Playground.
  • If an API key page in the Ory Console shows Enable Ory Talos, select Enable API keys. The change takes a short time to apply. See Eventual consistency.

To call the API, you need your project slug and a project API key.

A project API key is required for all administrative operations. To create one, read Creating API Keys.

The quickstart shows where to find the project slug and how to set up the TypeScript and Go SDKs. The examples on this page read both values from environment variables:

export PROJECT_SLUG=<your-project-slug>
export ORY_API_KEY=<your-project-api-key>

Revoke a key​

Revocation permanently disables a key and can't be undone. The key stays in the list with the status Revoked, and its detail page shows the Revocation reason.

  1. Go to API Keys → Keys in the Ory Console, open the row menu of the key, and select Revoke. On the key detail page, Revoke key is in the Danger zone section.
  2. In the Revoke API key? dialog, choose a Reason.
  3. If you choose Privilege withdrawn, you can explain the decision in Additional details.
  4. Select Revoke key.

Revoke API key dialog in the Ory Console with the Affiliation changed reason selected

Reason in the Ory ConsoleAPI valueUse it when
No specific reasonREVOCATION_REASON_UNSPECIFIEDYou don't record a reason. This is the default.
Key compromiseREVOCATION_REASON_KEY_COMPROMISEThe secret leaked, or someone else might have it.
Affiliation changedREVOCATION_REASON_AFFILIATION_CHANGEDThe owner's relationship with you changed, for example they left your team.
SupersededREVOCATION_REASON_SUPERSEDEDA new key replaces this one.
Privilege withdrawnREVOCATION_REASON_PRIVILEGE_WITHDRAWNYou withdrew the owner's permission to use the key.

After you revoke a key:

  • Verification of the key returns is_valid: false with the error code VERIFICATION_ERROR_REVOKED.
  • You can't derive new tokens from the key. Tokens that you derived before the revocation stay valid until they expire.
  • The key no longer counts toward the active key limit.

Key holders can also revoke their own key without a project API key, by proving that they have the secret. This works for issued and imported secret keys, not for public keys. They call POST /v2alpha1/apiKeys:selfRevoke (revokeApiKey in the SDK) with the full secret in credential and an optional reason. The reason REVOCATION_REASON_PRIVILEGE_WITHDRAWN is for admins only and returns HTTP 400. A successful request returns HTTP 200, also when the key is already revoked.

Revoke all keys of an actor​

When a user leaves your organization or a customer closes their account, revoke all of their keys.

  1. On API Keys → Keys in the Ory Console, filter the list by the actor ID, and select Active in the Filters list.
  2. For each key in the list, revoke the key with the reason Affiliation changed.

To revoke the imported keys of an actor with the API, use adminListImportedApiKeys and adminRevokeImportedApiKey. The list response holds the keys in imported_api_keys, and the revoke request body is adminRevokeImportedApiKeyBody.