Diska
API

OAuth for partner platforms

Let your platform's customers connect their DISKA account in one click, without copying API keys.

If your platform (a sales system, a CRM, an ERP) wants to use DISKA on behalf of its customers, use OAuth 2.0. The customer clicks "Connect with DISKA", picks the company and the permissions on a DISKA screen, and your platform receives a token that only works for that company.

API keyOAuth
For whomA company integrating its own systemsA platform serving many companies
How it is obtainedThe customer copies it from Definições → Chaves API (Settings → API keys) and pastes it into your platformThe customer authorizes on a DISKA screen
ScopeThe key's scopes (no scopes = full access)Only the permissions the customer left checked
RevokingThe customer deletes the keyThe customer disconnects the app in Definições → Aplicações ligadas (Settings → Connected apps), or the app revokes
OAuth apps are in pilot. To register your platform, contact DISKA: we switch the feature on for your organization.

The flow is standard OAuth 2.1: authorization code with PKCE (S256, mandatory), one-hour access tokens and rotating refresh tokens.

Endpoints

URL
Metadata (RFC 8414)https://api.diska.ai/.well-known/oauth-authorization-server
Authorization (browser)https://app.diska.ai/oauth/authorize
TokenPOST https://api.diska.ai/oauth/token
Revocation (RFC 7009)POST https://api.diska.ai/oauth/revoke
Token informationGET https://api.diska.ai/v1/oauth/token-info
APIhttps://api.diska.ai/v1, with the same endpoints as the DISKA API

1. Register the app

In Definições → Apps OAuth (Settings → OAuth apps; owners and admins of your organization):

  • Name, description, website, privacy policy and logo, shown on the authorization screen. The website, privacy policy and logo must be https:// addresses.
  • Environment:
    • Teste (test): only members of your organization can authorize it, and only for your organization; http://localhost is accepted in redirect URIs. Use it while developing.
    • Produção (live): any DISKA company can authorize it. Until it is verified by DISKA, the authorization screen shows a warning and the app is limited to 100 connected companies. Changing a verified app's name, description, logo, website, privacy policy or redirect URIs, or adding permissions, makes it unverified again until DISKA reviews it.
  • Redirect URIs: up to 10, https:// (or http://localhost for test apps). Each request's redirect_uri must match one of them exactly.
  • Permissions: the ones the app may ask for (see ).

You receive the client_id (dsk_app_…) and the client_secret (dsk_cs_…). The secret is shown only once: keep it on your platform's server, never in a browser or a mobile app. You can generate a new one at any time; the old one stops working immediately, and tokens already issued keep working.

2. Send the customer to DISKA

For each connection, generate:

  • a random state, stored in the user's session (CSRF protection);
  • a random code_verifier (43 to 128 characters from A-Z a-z 0-9 - . _ ~) and its code_challenge = base64url(SHA-256(code_verifier)), without trailing =.

Then redirect the browser:

https://app.diska.ai/oauth/authorize
  ?response_type=code
  &client_id=dsk_app_…
  &redirect_uri=https://app.example.com/integrations/diska/callback
  &scope=organization:read agents:read calls:read calls:write
  &state=…
  &code_challenge=…
  &code_challenge_method=S256
Parameter
response_typeAlways code.
client_idYour app's.
redirect_uriOne of the registered ones, exactly.
scopeSpace-separated permissions. Omitted = every permission the app may ask for.
stateRequired. Returned unchanged.
code_challenge, code_challenge_methodPKCE; S256 only.

On the DISKA screen the customer signs in (if needed), picks the company (only owners and admins can connect apps) and can uncheck permissions. The screen also lists what the app can never do: see API keys, manage members, see billing and minutes, change numbers, telephony or WhatsApp, or delete the company.

3. Receive the code

If the customer approves, the browser returns to your redirect_uri:

https://app.example.com/integrations/diska/callback?code=dsk_ac_…&state=…

Check that state is the one you stored. The code is valid for 60 seconds, once.

If the customer declines, or the request is wrong once client_id and redirect_uri have been validated, it returns with an error:

…/callback?error=access_denied&error_description=…&state=…

An unknown client_id or an unregistered redirect_uri does not return to your app: the error is shown on the DISKA screen.

4. Exchange the code for tokens

From your server, with HTTP Basic authentication (client_id:client_secret) and an application/x-www-form-urlencoded body:

curl -X POST https://api.diska.ai/oauth/token \
  -u "dsk_app_…:dsk_cs_…" \
  -d grant_type=authorization_code \
  -d code=dsk_ac_… \
  -d redirect_uri=https://app.example.com/integrations/diska/callback \
  -d code_verifier=…

You may send client_id and client_secret in the body instead of Basic, but not both.

Response 200:

{
  "access_token": "dsk_oat_…",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "dsk_ort_…",
  "scope": "organization:read agents:read calls:read calls:write",
  "organization": {
    "id": "6f1c…",
    "name": "Loja Kianda",
    "nif": "5000000000"
  }
}
  • scope is what the customer granted, which may be less than you asked for.
  • organization identifies the company. nif is sent only with the organization:read permission; without it, it is null. Store the tokens against it. One customer may connect several companies; each has its own tokens.
  • If the same company authorizes the app again, the permissions become the new ones and the previous tokens stop working.

5. Call the API

Use the access token like an API key, in the same header:

curl https://api.diska.ai/v1/me \
  -H "Authorization: Bearer dsk_oat_…"
{
  "organization": { "id": "6f1c…", "name": "Loja Kianda", "slug": "loja-kianda" },
  "key": null,
  "app": {
    "client_id": "dsk_app_…",
    "name": "Vende",
    "scopes": ["organization:read", "agents:read", "calls:read", "calls:write"]
  }
}

Every DISKA API endpoint works, always in the token's company and only within the granted permissions. Voice minutes, limits and per-company switches (outbound calls, campaigns, chat) are that company's.

GET /v1/oauth/token-info returns the app, company, permissions and expiry of the token in use.

6. Refresh

The access token lasts 1 hour. Before it expires (or on a 401), exchange the refresh token for a new pair:

curl -X POST https://api.diska.ai/oauth/token \
  -u "dsk_app_…:dsk_cs_…" \
  -d grant_type=refresh_token \
  -d refresh_token=dsk_ort_…

The response has the same shape as step 4. Store both new tokens: the refresh token also changes on every refresh (rotation), and the previous access token stops working.

A refresh token works once. If an already-used refresh token shows up again, DISKA assumes it was stolen: it disconnects the company and the app has to ask for authorization again. Refresh from a single process at a time (for example, with a lock per company) and store the new pair before using it. If the same refresh token arrives twice within 10 seconds (two processes refreshing at once), the second request gets invalid_grant and the company is not disconnected: use the pair the first request received.

An unused refresh token expires after 90 days. Each refresh starts 90 days again. On refresh, scope may be omitted; if you send it, it must equal what was granted.

7. Revoke

When the customer disconnects DISKA in your platform:

curl -X POST https://api.diska.ai/oauth/revoke \
  -u "dsk_app_…:dsk_cs_…" \
  -d token=dsk_ort_…
  • Revoking the refresh token disconnects the company: every token stops working.
  • Revoking an access token ends only that token.
  • The response is always 200, even for an unknown token.

The customer can also disconnect the app, or take permissions away, in Definições → Aplicações ligadas: it takes effect on the next request. Your app is told by .

Permissions

PermissionGrants
organization:readThe company's tax number (NIF). The company's id and name always come in the token response.
agents:readList and view agents.
agents:writeCreate, edit and publish agents.
calls:readCalls, transcripts, post-call results and the call.completed webhook.
calls:writeOutbound calls.
analytics:readAnalytics.
phone-numbers:readNumbers.
knowledge:read, knowledge:writeKnowledge bases.
recordings:readRecordings.
campaigns:read, campaigns:writeCampaigns.
chats:writeChat with agents.

There is no permission to manage the company's own webhooks (/v1/webhook-endpoints): the app receives events on its own . A token without a permission gets 403 on that endpoint, even if the company has it on other keys.

Errors

On the token and revocation endpoints, errors follow OAuth ({"error", "error_description"}):

HTTPerrorWhen
401invalid_clientWrong client_id or client_secret, or missing authentication.
400invalid_requestA missing parameter, or an invalid code_verifier.
400invalid_grantCode or refresh token invalid, expired, already used, issued to another app, or a redirect_uri/code_verifier that does not match.
400invalid_scopeA scope different from the grant on refresh.
400unsupported_grant_typeA grant_type other than authorization_code or refresh_token.
400unauthorized_clientThe app is suspended by DISKA.
403app_connection_limitThe (unverified) app reached its limit of connected companies.
403organization_suspendedThe company is suspended. The connection stays: refresh once it is reactivated.

On the API (/v1), with a token:

HTTPWhen
401Invalid, expired or revoked token (WWW-Authenticate: Bearer error="invalid_token"). Refresh, or ask for authorization again.
403Missing permission (WWW-Authenticate: Bearer error="insufficient_scope", scope="…").
403Organização suspensa. (company suspended)
402The company ran out of voice minutes (only on requests that use voice).

App webhooks

Each app has one webhook URL, set in Definições → Apps OAuth, which receives events from every connected company. Setting the URL generates a signing secret (dskw_…), shown once.

EventWhen
app.authorization.createdA company connected the app (or connected it again).
app.authorization.updatedThe company took permissions away. data.scopes has those left.
app.authorization.revokedThe connection ended: by the company, by DISKA, or because a refresh token was reused. Not sent when the app itself revoked.
call.completedA call ended, in companies that granted calls:read. data is the same content as the call.completed webhook. If the company disconnects the app or removes calls:read, pending deliveries are cancelled.
pingSent by the Enviar ping (send ping) button.

Body:

{
  "id": "0b6f…",
  "event": "app.authorization.revoked",
  "created_at": "2026-11-19T10:15:02.123456+00:00",
  "organization_id": "6f1c…",
  "data": {
    "connection_id": "a1b2…",
    "reason": "member",
    "revoked_at": "2026-11-19T10:15:02.120000+00:00"
  }
}

Headers and signature are the same as the DISKA API webhooks: X-Diska-Event, X-Diska-Delivery (equal to id), X-Diska-Timestamp and X-Diska-Signature = sha256=<HMAC-SHA256("{timestamp}.{body}")>, with the app's webhook secret.

Answer 2xx within 10 seconds. A failed delivery is retried after 1 min, 5 min, 30 min, 2 h and 8 h (6 attempts). A 410 response stops the retries. Use id to ignore repeats. Ver entregas (view deliveries) shows the last 25 deliveries with their status and error.

Full example

import base64, hashlib, os, secrets
import requests

CLIENT_ID = os.environ["DISKA_CLIENT_ID"]
CLIENT_SECRET = os.environ["DISKA_CLIENT_SECRET"]
REDIRECT_URI = "https://app.example.com/integrations/diska/callback"


def start(session: dict) -> str:
    """Return the URL to redirect the browser to."""
    verifier = secrets.token_urlsafe(48)
    challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode()).digest()).rstrip(b"=").decode()
    session["diska_state"] = secrets.token_urlsafe(24)
    session["diska_verifier"] = verifier
    params = {
        "response_type": "code",
        "client_id": CLIENT_ID,
        "redirect_uri": REDIRECT_URI,
        "scope": "organization:read agents:read calls:read",
        "state": session["diska_state"],
        "code_challenge": challenge,
        "code_challenge_method": "S256",
    }
    return requests.Request("GET", "https://app.diska.ai/oauth/authorize", params=params).prepare().url


def callback(session: dict, query: dict) -> dict:
    """Exchange the code for tokens; store them against tokens['organization']['id']."""
    if query.get("error"):
        raise RuntimeError(query.get("error_description") or query["error"])
    if query.get("state") != session.pop("diska_state", None):
        raise RuntimeError("invalid state")
    response = requests.post(
        "https://api.diska.ai/oauth/token",
        auth=(CLIENT_ID, CLIENT_SECRET),
        data={
            "grant_type": "authorization_code",
            "code": query["code"],
            "redirect_uri": REDIRECT_URI,
            "code_verifier": session.pop("diska_verifier"),
        },
        timeout=15,
    )
    response.raise_for_status()
    return response.json()


def refresh(refresh_token: str) -> dict:
    response = requests.post(
        "https://api.diska.ai/oauth/token",
        auth=(CLIENT_ID, CLIENT_SECRET),
        data={"grant_type": "refresh_token", "refresh_token": refresh_token},
        timeout=15,
    )
    response.raise_for_status()
    return response.json()  # store the new pair before using it

Limits

  • POST /oauth/token and /oauth/revoke: 60 requests per minute per app and IP address.
  • /v1 with a token: 120 requests per minute per connected company, so one company never uses up another's limit.
  • Outbound calls (POST /v1/outbound-calls): up to 200 per day (UTC) per connected company. Campaign recipients (POST /v1/campaigns/{id}/recipients): up to 2000 per day per connected company. These come on top of the company's own limits; above them the API answers 429 and the company sees it in its audit log. Talk to DISKA if you need more.
Copyright © 2026