key value immediately. After that, Kernel only shows the masked value.
Before you start
You need one existing Kernel credential to create another API key:- Set
KERNEL_API_KEYbefore running the SDK examples.
- Omit
project_idto create an org-scoped key that can access resources across your organization. - Set
project_idto create a project-scoped key that can only access resources in that project. - When you authenticate with a project-scoped key, you can only create another project-scoped key for the same project.
Create an API key
Use the SDKs when your backend needs to provision keys for environments, customers, or automation jobs.SDKs
List and inspect API keys
List keys to audit what exists. List and retrieve responses includemasked_key, project_id, project_name, created_by, and expiry metadata, but they don’t include the plaintext key.
Rename or delete an API key
Rename a key when the owner or purpose changes. Delete a key when the workload no longer needs access.Rotate a key
rotate issues a replacement key in a single call and keeps the old key working for a short grace period, so your workload can switch over without downtime. The new key copies the rotated key’s name and project scope, and—like create—Kernel returns the plaintext key only once.
Two optional parameters control the timing:
days_to_expiresets the new key’s lifetime in days (1-3650). Omit it to give the new key the same lifetime the rotated key originally had, or to never expire if the old key never did.expire_in_dayssets how long the old key keeps working before it expires. Use0to revoke it immediately, or omit it for the default 7-day grace window. The old key stops authenticating automatically once the window passes—you don’t need to delete it.
- Store the new plaintext key in your secret manager.
- Deploy or restart the workload that uses
KERNEL_API_KEY. - Verify the workload can call Kernel before the grace window ends.
expire_in_days: 0 so the old key stops working as soon as the new one is issued.
Troubleshooting
| Error | What it means | What to do |
|---|---|---|
400 Bad Request | The name is missing, days_to_expire is outside 1-3650, expire_in_days is outside 0-3650, or project_id is empty. | Send a name, choose a valid expiry, or omit project_id for an org-scoped key. |
400 Bad Request (rotate) | days_to_expire is shorter than expire_in_days, so the new key would expire before the old key’s grace window ends. | Raise days_to_expire or lower expire_in_days. |
401 Unauthorized | Kernel couldn’t authenticate the request. | Set a valid KERNEL_API_KEY. |
404 Not Found | The project or API key doesn’t exist, or the caller can’t access it. | Check the ID. If you’re using a project-scoped key, you can only rotate keys in that same project. |