Skip to main content
POST
/
oauth
/
token
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx();

const response = await client.oauth.token({ grant_type: 'client_credentials' });

console.log(response.access_token);
{
"access_token": "<string>",
"token_type": "Bearer",
"expires_in": 123,
"scope": "<string>",
"refresh_token": "<string>"
}

Authorizations

Authorization
string
header
required

OAuth client credentials (client_id:client_secret) via HTTP Basic Auth, or client credentials in request body for public clients

Body

grant_type
enum<string>
required

OAuth 2.0 grant type

Available options:
client_credentials,
authorization_code,
refresh_token
scope
string

Space-separated list of requested scopes (for client_credentials)

Example:

"admin"

code
string

Authorization code (for authorization_code flow)

redirect_uri
string<uri>

Redirect URI (for authorization_code flow)

code_verifier
string

PKCE code verifier (for authorization_code flow)

refresh_token
string

Refresh token (for refresh_token flow)

client_id
string

OAuth client ID (if not using HTTP Basic auth)

client_secret
string

OAuth client secret (if not using HTTP Basic auth)

Response

Token response

access_token
string
required

The access token

token_type
enum<string>
required

Token type

Available options:
Bearer
expires_in
integer
required

Token lifetime in seconds

scope
string

Space-separated list of granted scopes

refresh_token
string

Refresh token (if applicable)