DM Champ Docs

API Keys API

These endpoints let you manage your account’s API keys from code. They only ever act on the calling account’s own keys.

Field-level detail (every parameter, request and response body) lives in the API Reference. This page explains how the two kinds of key behave and what to watch out for.

Read this first. Rotating or revoking your key takes effect immediately. The moment either call succeeds, the old key stops working and every integration that still uses it starts getting 401 errors. Rotate during a maintenance window and update all your integrations right away.


Two kinds of key

  • Your main key: the single full-access key under Settings → Integrations → API Key. You can look up its masked preview, check your rate-limit usage, rotate it, or revoke it (/api-keys/current, /api-keys/rotate, /api-keys/usage).
  • Scoped keys: extra, named keys you create for one job, each limited to the parts of the API you choose (/api-keys and /api-keys/{id}, see Scoped keys). Creating one changes nothing about your main key; existing integrations carry on untouched.

Endpoints

Task Method + path Explorer
Get main key metadata GET /api-keys/current Open in API Reference
Get rate-limit usage GET /api-keys/usage Open in API Reference
Rotate the main key POST /api-keys/rotate Open in API Reference
Revoke the main key DELETE /api-keys/current Open in API Reference
List scoped keys GET /api-keys Open in API Reference
Create a scoped key POST /api-keys Open in API Reference
Update a scoped key PATCH /api-keys/{id} Open in API Reference
Revoke a scoped key DELETE /api-keys/{id} Open in API Reference

Your main key

Check the key and your usage

GET /api-keys/current returns a masked preview (first 4 and last 4 characters), whether the full key can be shown again in the app (api_key_retrievable), and the creation date when known. The full key is never returned by the API: to see or copy it, open Settings → Integrations → API Key and click Show or Copy. api_key_retrievable is false for keys created before retrievable copies were kept; rotate once and the new key can be shown again later.

GET /api-keys/usage answers only your main key (a limited key gets 403 key_scope_denied). It returns the request limit per window, how many requests were counted so far, how many remain, and when the window resets. Use it to throttle on your side so your integration backs off before it hits 429. If nothing has been recorded in the current window yet, usage is zero and the response carries a note saying why.

curl "https://api.dmchamp.com/v1/api-keys/usage?apiKey=YOUR_API_KEY"
{
  "success": true,
  "usage": { "limit": 300, "window_seconds": 60, "used": 37, "remaining": 263, "window_resets_at": "2026-06-09T12:01:00.000Z" }
}

Rotate the key

POST /api-keys/rotate generates a new key and invalidates the old one in the same step. Use it if you suspect a leak, or as part of a regular rotation policy.

curl -X POST "https://api.dmchamp.com/v1/api-keys/rotate?apiKey=YOUR_API_KEY"
{ "success": true, "api_key": "abcdEFGH1234ijkl5678MNOP9012qrst", "message": "API key rotated. ..." }

The new key is shown once. It is in this response and cannot be retrieved in full through the API afterwards. Store it the moment you receive it. The previous key stops working the instant this call succeeds.

Revoke the key

DELETE /api-keys/current permanently deletes your main key. Every later request that uses it, including Make, Zapier or custom scripts, is rejected with 401. To get API access back, generate a new key from your account settings while signed in to the app.

There is no undo. Unlike rotation, revocation does not hand you a replacement key. Only revoke when you mean to stop API access (for example, a leaked key you cannot replace right away).


Scoped keys

A scoped key is an extra API key for one specific job, carrying only the access that job needs. The classic case: you want to point a client dashboard, a reporting tool or an internal script at your account without handing over a key that could also send messages, change your AI agents or buy a phone number.

The restriction travels with the key itself, so whoever holds it can only do what you allowed when you created it.

What you can restrict

Field What it means
read_only true (the default) means only GET requests are allowed. Any create, update or delete is refused, and so are the few reads that are sent as a POST: task search (POST /tasks/search), smart list previews and evaluations, chat summaries for a set of contacts, chat media download links and the cost estimates. Reading contacts, conversations, appointments and analytics is all GET and works.
tags The API sections the key may use, written with the same section names you see in these docs and in the API explorer: Analytics, Campaigns, Contacts, Messages, Appointments, and so on. The endpoints that list and manage your managed accounts are their own section, SubAccounts, separate from Agency (snapshots are Snapshots), so a read-only key for GET /subaccounts needs "tags": ["SubAccounts"]. Agency, Agency Credit Price, SubAccounts and White Label can only be given to a key on an agency account; on any other account the request is refused with invalid_scopes. Sending a message to a contact is Messages on every channel, including POST /whatsapp-web/send and sending a WhatsApp template to one contact; sending a template to many contacts at once and managing templates stay under WhatsApp Templates. Reading or changing your custom field definitions (GET and PUT /users/me/custom-fields) is Users, not Contacts: a Contacts key reads contacts and writes a contact’s custom field values, but needs Users added to read which fields exist. An empty list means every section.
sub_account_ids Which accounts the key may act on. Empty means your own account only. ["*"] means your own account plus any account you actually manage. A list of account ids means those accounts only, never your own: every call must pass sub_account_id with one of them, so a key you hand to one client cannot read or change your own data or another client’s. Ownership is still checked on every request.
rate_limit_per_min Requests per minute for this key, counted in its own budget so it cannot use up your other integrations’ allowance. Defaults to 60, and cannot be set above 300.

You can also give a key an expires_at date (ISO 8601, in the future). After that moment the key stops working on its own. Leave it out and the key works until you revoke it.

Create a scoped key

curl -X POST "https://api.dmchamp.com/v1/api-keys?apiKey=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Client dashboard - Acme",
    "scopes": { "read_only": true, "tags": ["Analytics"], "sub_account_ids": [], "rate_limit_per_min": 60 }
  }'

The 201 response carries the key value in api_key (shown once) plus the key record in key, whose id (a key_... value) is what you use to update or revoke it.

The key is shown once. It is in this response and nowhere else, ever. Store it the moment you receive it. If you lose it, revoke it and create another.

  • Leaving out scopes is not the same as sending an empty tags list. Leave scopes out entirely and you get the safe default: read-only, Analytics only, your own account only, 60 requests per minute. Send "tags": [] on purpose and the key may use every section, read as a deliberate request for an unrestricted key.
  • read_only stays true unless you explicitly send false. A typo or a missing flag can never produce a key that can write.

List, update and revoke

  • List (GET /api-keys) returns the account’s scoped keys, newest first (up to 200), including revoked ones so you can see what was withdrawn and when. Only masked previews come back.
  • Update (PATCH /api-keys/{id}) changes the label, scopes and/or expiry; sending none of them returns 400. The {id} is the key’s id from the list, never the key itself. Scopes are replaced, not merged: whatever you send becomes the key’s complete permission set, so narrowing a key can never leave the old wider access in place. Always send the full scopes object, not just the field you are changing.
  • No rotate in place. A scoped key’s value never changes. To roll one, create a new key and revoke the old one, so a credential’s access never changes under an integration still holding it.
  • Revoke (DELETE /api-keys/{id}) is immediate: the next request with that key gets 401. Your main key and every other scoped key are unaffected. The key stays in your list marked "revoked": true. Revoking an already revoked key succeeds and changes nothing. An unknown id returns 404.

Denials fail closed

If a request falls outside what the key allows, it is refused rather than let through:

error_code Status What happened
key_read_only 403 A read-only key attempted a write.
key_scope_denied 403 The endpoint is outside the key’s sections, or the managed account is not on its list. A key limited to a list of managed accounts gets this when a call leaves out sub_account_id, names an account not on its list, or uses the endpoints that manage your managed accounts and snapshots. Also returned when a scoped key tries to manage API keys.
invalid_scopes 400 The requested scopes included the API Keys section. Keys cannot manage keys.

If a scoped key gets an unexpected 403, the endpoint you called is simply not inside its scopes: widen the key or use your main key.

Only the account owner manages keys (or its agency, from inside a client account it manages). The scoped-key endpoints require your main key, or an owner session in the app. A scoped key can never list, create, edit or revoke keys, itself included, so a restricted key can never be used to mint a wider one.


Good to know

  • On an API-key endpoint, a missing or invalid key returns 401, and an account with no key on file returns 404 ("No API key found for this account").
  • The shared codes every endpoint can return (400, 403 when your plan does not include API access, 429, 500) are listed with retry guidance in Errors & Pagination.

Next steps