Import API keys
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.
Import the API keys that your customers already have from another system into Ory Talos Secure API Keys.
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>
Import existing keys
If your customers already have API keys from another system, import those keys so that your customers can keep using their current secrets. Ory Talos Secure API Keys stores only a hash of each imported secret, and verifies imported keys the same way as issued keys.
- Ory Console
- curl
- Go to API Keys → Imported in the Ory Console and select Import key.
- On the Import API key page, enter a Key name, the owner's Actor, and the existing secret in API key secret.
- Optionally, set the other fields. Expires after works like Expiration when you issue a key, and its calendar button sets an exact expiry date. Key type and Advanced settings work the same as when you issue a key.
- Select Import key.

Send POST /v2alpha1/admin/importedApiKeys. The fields raw_key, name, and actor_id are required. The other fields are the
same as for issued keys. The response has HTTP status 201 and contains the imported key. It never contains the secret.
curl -sS -X POST "https://$PROJECT_SLUG.projects.oryapis.com/v2alpha1/admin/importedApiKeys" \
-H "Authorization: Bearer $ORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"raw_key": "legacy-key-EXAMPLE-not-a-real-secret",
"name": "Acme legacy key",
"actor_id": "org:acme",
"scopes": ["read:data"],
"ttl": "720h"
}' | jq
Imported keys follow these rules:
- You can import a secret only once per project. Importing the same secret again fails.
- A secret that has the format of an issued key or a derived token can't be imported.
- Imported keys get an expiry the same way as issued keys, and the same project maximum applies.
- You can't rotate an imported key. To replace one, issue a new key, move the client to it, and then revoke or delete the imported key.
Import keys in bulk
To import many keys, send POST /v2alpha1/admin/importedApiKeys:batchCreate with up to 1,000 items in requests. The Ory Console
doesn't offer bulk import. Each item has the same fields as a single import, and each item succeeds or fails on its own:
- If at least one item succeeds, the response has HTTP status 200.
resultshas one entry per item, in request order. Each entry has theindexof the item and either theimported_api_keyor anerror_codeanderror_message.success_countandfailure_countsummarize the batch. - If every item fails, the whole request fails with an error status.
- Items that would take the project over its active key limit fail with
BATCH_CREATE_IMPORTED_API_KEYS_ERROR_RESOURCE_EXHAUSTED.
When you retry, send only the items that failed. Items that were already imported fail with
BATCH_CREATE_IMPORTED_API_KEYS_ERROR_ALREADY_EXISTS.
curl -sS -X POST "https://$PROJECT_SLUG.projects.oryapis.com/v2alpha1/admin/importedApiKeys:batchCreate" \
-H "Authorization: Bearer $ORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{"raw_key": "legacy-key-EXAMPLE-1", "name": "Acme production", "actor_id": "org:acme"},
{"raw_key": "legacy-key-EXAMPLE-2", "name": "Globex staging", "actor_id": "org:globex"}
]
}' | jq
Delete an imported key
Deleting an imported key removes it permanently. The key disappears from the list and can't be restored. To keep a record of the key, revoke it instead.
- Ory Console
- curl
- Go to API Keys → Imported in the Ory Console, open the row menu of the key, and select Delete. On the key detail page, Delete key is in the Danger zone section.
- In the Delete API key? dialog, select Delete key.
Send DELETE /v2alpha1/admin/importedApiKeys/{key_id}. A successful request returns HTTP 204.
curl -sS -X DELETE "https://$PROJECT_SLUG.projects.oryapis.com/v2alpha1/admin/importedApiKeys/${KEY_ID}" \
-H "Authorization: Bearer $ORY_API_KEY"