Skip to main content
Every request to the Diameter API must be authenticated with a valid Bearer token. Diameter implements the OAuth 2.0 Client Credentials flow — your server exchanges a client_id and client_secret for a short-lived access token, then attaches that token to downstream API calls. Tokens are valid for 600 seconds (10 minutes) and cannot be refreshed; request a new one using the same flow when the current one expires.

Getting Your Credentials

To obtain a client_id and client_secret, email support@diameterpay.com. Include your company name and a brief description of your use case. The Diameter team will provision a Tenant for you and reply with sandbox credentials.
Store your client_secret securely. It is shown only once during provisioning. Never embed it in client-side code, commit it to version control, or share it in plaintext. Use environment variables or a secrets manager in all environments.

Token Endpoints

Use the sandbox endpoint during development and testing. Switch to the production endpoint only when you are ready to go live.

Requesting a Token

Send a POST request to the token endpoint with a body encoded as application/x-www-form-urlencoded. Include the four fields below.
string
required
Must be client_credentials.
string
required
The Client ID issued to your Tenant.
string
required
The Client Secret issued to your Tenant.
string
A space-separated list of OAuth scopes your token needs. Omit this field to request all scopes granted to your Tenant, or list only the scopes you need (recommended).

Token Response

A successful request returns a JSON object with three fields.

Using the Token

Attach the token to every API request in the Authorization header using the Bearer scheme.

Scopes

Scopes control which API resources a token can access. Request only the scopes your integration actually needs — this limits the blast radius if a token is ever leaked.
Your Tenant may not have all scopes enabled by default. Contact support@diameterpay.com if you receive a 403 Forbidden response indicating a missing scope that you expect to have access to.
Follow the principle of least privilege: a service that only reads payment status only needs payments.read. A service that creates end users needs end-users.write. Separate long-running background services from write-intensive services and issue each a token with the minimum required scopes.

Token Expiry and Rotation

Tokens expire after 10 minutes. Diameter does not support refresh tokens in the Client Credentials flow. To maintain uninterrupted access, proactively request a new token before the current one expires. The recommended pattern is to fetch a fresh token at startup and cache it in memory with a timer that triggers a re-fetch at the 9-minute mark (giving a 60-second buffer before the 10-minute expiry):
Python — token caching with proactive refresh

Deprecated JWT Authentication

Diameter previously supported direct JWT-based authentication where tokens were signed and passed in a custom header. That mechanism still functions for tenants that have not yet migrated, but all new integrations must use OAuth 2.0 Client Credentials. The legacy JWT method will be removed in a future major version. If you are currently using it, contact support@diameterpay.com to plan your migration.

Error Handling

Authentication errors return standard HTTP status codes with a JSON error body.
401 Unauthorized — expired token
403 Forbidden — missing scope
Never retry a 403 Forbidden response in a tight loop. A missing scope cannot be fixed by requesting a new token alone — the scope must either be included when requesting the token or enabled on your Tenant by support.