Management Keys
Keys that create, cap and revoke your API keys from a script, and never call a model.
On this page
A management key creates, caps and revokes your account's API keys over the API. It never calls a model, and an API key cannot manage keys, so a leaked key of one kind cannot do the other's job. Use one for teams, CI and agents that hand out their own keys.
Create a management key
- On your dashboard, open API keys and the Management keys tab.
- Choose Create management key and give it a name.
- Copy the key. It starts with
dcode_mgmt_and is shown only once.
You can revoke a management key on the same tab. The API keys it made keep working.
Endpoints
Base URL https://api.dipoleml.com. Every call sends Authorization: Bearer <management key>.
| Method | Path | What it does |
|---|---|---|
GET | /v1/management/keys | Lists your API keys, newest first, up to 100, revoked ones included. |
POST | /v1/management/keys | Creates an API key. Answers 201. |
GET | /v1/management/keys/:id | Returns one API key. |
PATCH | /v1/management/keys/:id | Changes its label, cap or expiry. |
DELETE | /v1/management/keys/:id | Revokes it at once and returns it. |
Create an API key
curl
curl https://api.dipoleml.com/v1/management/keys \ -H "Authorization: Bearer $DIPOLEML_MANAGEMENT_KEY" \ -H "Content-Type: application/json" \ -d '{ "label": "staging bot", "limit": 10, "expires_at": "2027-06-30T23:59:59Z" }'python
import os, requestsresp = requests.post( "https://api.dipoleml.com/v1/management/keys", headers={"Authorization": "Bearer " + os.environ["DIPOLEML_MANAGEMENT_KEY"]}, json={"label": "staging bot", "limit": 10, "expires_at": "2027-06-30T23:59:59Z"},)resp.raise_for_status()created = resp.json()print(created["id"], created["key"]){ "id": "ak_<16 hex characters>", "object": "key", "label": "staging bot", "status": "active", "created_at": "2026-11-13T15:04:05.000Z", "expires_at": "2027-06-30T23:59:59.000Z", "limit": 10, "used": 0, "limit_remaining": 10, "last_used_at": null, "key": "dcode_sk_<the new key>"}The new key is in key, in this answer only. Every field of the body is optional:
| Field | Type | Notes |
|---|---|---|
label | string | A name, up to 80 characters (longer is cut). Left out or empty, it is API key. |
limit | number or null | A spending cap in US dollars for the key's whole life, from 0 to 1,000,000. null or left out: no cap. |
expires_at | string or null | An ISO 8601 time, such as 2027-06-30T23:59:59Z. null or left out: never expires. |
The key object
| Field | Meaning |
|---|---|
id | The key's id, starting with ak_. Used in the paths above. It is not the key itself. |
object | Always key. |
label | The key's name. |
status | active, expired or revoked. |
created_at | When it was made, ISO 8601. |
expires_at | When it expires, ISO 8601, or null for never. |
limit | Its spending cap in US dollars, or null. |
used | What it has spent in all, in US dollars. |
limit_remaining | The cap minus what it spent (never below 0), or null with no cap. |
last_used_at | When it last made a billed request, or null. |
Caps and expiry
On every model call with an API key, the API checks in this order: the key's expiry (401, key_expired), then its cap (402, key_limit_reached), then your credit balance (402, insufficient_credits). A key is refused once what it spent has reached its cap; since a request is debited after it finishes, the last one can take it slightly past the cap.
curl -X PATCH https://api.dipoleml.com/v1/management/keys/ak_1a2b3c4d5e6f7a8b \ -H "Authorization: Bearer $DIPOLEML_MANAGEMENT_KEY" \ -H "Content-Type: application/json" \ -d '{"limit": 25}'curl -X PATCH https://api.dipoleml.com/v1/management/keys/ak_1a2b3c4d5e6f7a8b \ -H "Authorization: Bearer $DIPOLEML_MANAGEMENT_KEY" \ -H "Content-Type: application/json" \ -d '{"limit": null, "expires_at": "2027-12-31T23:59:59Z"}'A PATCH changes only the fields you send and returns the key. The same controls are on the dashboard's API keys page, under Edit, where the expiry is a choice of Never, 7, 30 or 90 days, or 1 year.
Revoke a key
curl -X DELETE https://api.dipoleml.com/v1/management/keys/ak_1a2b3c4d5e6f7a8b \ -H "Authorization: Bearer $DIPOLEML_MANAGEMENT_KEY"The answer is the key with status: "revoked". Its next request fails with 401 and invalid_api_key, and it cannot be turned back on. Revoked keys stay in the list, so your records stay complete.
Errors
Errors have the OpenAI-format shape (Errors and limits).
| Status | code | Meaning |
|---|---|---|
| 401 | missing_management_key | No key was sent. |
| 401 | invalid_management_key | The key is wrong or revoked, or it is an API key rather than a management key. |
| 400 | invalid_limit | limit is not an amount from 0 to 1,000,000. |
| 400 | invalid_expires_at | expires_at is not an ISO 8601 time. |
| 400 | invalid_label | label is not a string (on PATCH). |
| 400 | empty_update | A PATCH with none of label, limit or expires_at. |
| 400 | 400 | The body is not valid JSON. |
| 404 | key_not_found | No API key with that id on your account. |
| 405 | 405 | A method these paths do not take. |
Keeping management keys safe
- A management key can make keys that spend your credits. Keep it in your CI's secret store, never in code.
- If one leaks, revoke it on the dashboard and create another.
- Give keys you hand to machines a small cap and an expiry, so a lost key cannot surprise you.