OAuth for partner platforms
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 key | OAuth | |
|---|---|---|
| For whom | A company integrating its own systems | A platform serving many companies |
| How it is obtained | The customer copies it from Definições → Chaves API (Settings → API keys) and pastes it into your platform | The customer authorizes on a DISKA screen |
| Scope | The key's scopes (no scopes = full access) | Only the permissions the customer left checked |
| Revoking | The customer deletes the key | The customer disconnects the app in Definições → Aplicações ligadas (Settings → Connected apps), or the app revokes |
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 |
| Token | POST https://api.diska.ai/oauth/token |
| Revocation (RFC 7009) | POST https://api.diska.ai/oauth/revoke |
| Token information | GET https://api.diska.ai/v1/oauth/token-info |
| API | https://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://localhostis 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.
- Teste (test): only members of your organization can authorize it, and only for your organization;
- Redirect URIs: up to 10,
https://(orhttp://localhostfor test apps). Each request'sredirect_urimust 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 fromA-Z a-z 0-9 - . _ ~) and itscode_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_type | Always code. |
client_id | Your app's. |
redirect_uri | One of the registered ones, exactly. |
scope | Space-separated permissions. Omitted = every permission the app may ask for. |
state | Required. Returned unchanged. |
code_challenge, code_challenge_method | PKCE; 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"
}
}
scopeis what the customer granted, which may be less than you asked for.organizationidentifies the company.nifis sent only with theorganization:readpermission; without it, it isnull. 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.
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
| Permission | Grants |
|---|---|
organization:read | The company's tax number (NIF). The company's id and name always come in the token response. |
agents:read | List and view agents. |
agents:write | Create, edit and publish agents. |
calls:read | Calls, transcripts, post-call results and the call.completed webhook. |
calls:write | Outbound calls. |
analytics:read | Analytics. |
phone-numbers:read | Numbers. |
knowledge:read, knowledge:write | Knowledge bases. |
recordings:read | Recordings. |
campaigns:read, campaigns:write | Campaigns. |
chats:write | Chat 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"}):
| HTTP | error | When |
|---|---|---|
| 401 | invalid_client | Wrong client_id or client_secret, or missing authentication. |
| 400 | invalid_request | A missing parameter, or an invalid code_verifier. |
| 400 | invalid_grant | Code or refresh token invalid, expired, already used, issued to another app, or a redirect_uri/code_verifier that does not match. |
| 400 | invalid_scope | A scope different from the grant on refresh. |
| 400 | unsupported_grant_type | A grant_type other than authorization_code or refresh_token. |
| 400 | unauthorized_client | The app is suspended by DISKA. |
| 403 | app_connection_limit | The (unverified) app reached its limit of connected companies. |
| 403 | organization_suspended | The company is suspended. The connection stays: refresh once it is reactivated. |
On the API (/v1), with a token:
| HTTP | When |
|---|---|
| 401 | Invalid, expired or revoked token (WWW-Authenticate: Bearer error="invalid_token"). Refresh, or ask for authorization again. |
| 403 | Missing permission (WWW-Authenticate: Bearer error="insufficient_scope", scope="…"). |
| 403 | Organização suspensa. (company suspended) |
| 402 | The 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.
| Event | When |
|---|---|
app.authorization.created | A company connected the app (or connected it again). |
app.authorization.updated | The company took permissions away. data.scopes has those left. |
app.authorization.revoked | The connection ended: by the company, by DISKA, or because a refresh token was reused. Not sent when the app itself revoked. |
call.completed | A 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. |
ping | Sent 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
import crypto from 'node:crypto'
const CLIENT_ID = process.env.DISKA_CLIENT_ID
const CLIENT_SECRET = process.env.DISKA_CLIENT_SECRET
const REDIRECT_URI = 'https://app.example.com/integrations/diska/callback'
const basic = 'Basic ' + Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString('base64')
export function start(session) {
const verifier = crypto.randomBytes(48).toString('base64url')
const challenge = crypto.createHash('sha256').update(verifier).digest('base64url')
session.diskaState = crypto.randomBytes(24).toString('base64url')
session.diskaVerifier = verifier
const url = new URL('https://app.diska.ai/oauth/authorize')
url.search = new URLSearchParams({
response_type: 'code',
client_id: CLIENT_ID,
redirect_uri: REDIRECT_URI,
scope: 'organization:read agents:read calls:read',
state: session.diskaState,
code_challenge: challenge,
code_challenge_method: 'S256'
})
return url.toString()
}
async function token(body) {
const response = await fetch('https://api.diska.ai/oauth/token', {
method: 'POST',
headers: { 'Authorization': basic, 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams(body)
})
const json = await response.json()
if (!response.ok) throw new Error(json.error_description || json.error)
return json
}
export async function callback(session, query) {
if (query.error) throw new Error(query.error_description || query.error)
if (query.state !== session.diskaState) throw new Error('invalid state')
delete session.diskaState
return token({
grant_type: 'authorization_code',
code: query.code,
redirect_uri: REDIRECT_URI,
code_verifier: session.diskaVerifier
}) // store the tokens against organization.id
}
export const refresh = refreshToken => token({ grant_type: 'refresh_token', refresh_token: refreshToken })
Limits
POST /oauth/tokenand/oauth/revoke: 60 requests per minute per app and IP address./v1with 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 answers429and the company sees it in its audit log. Talk to DISKA if you need more.

