Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement OAuth 2.0 authentication flows for Telnyx API access. This skill provides JavaScript SDK examples.
.claude/skills/team-telnyx-telnyx-oauth-javascript/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 96% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 105% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 166% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 266% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 91% | 0% |
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
bashnpm install telnyx@6.74.2
javascriptimport Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted });
All examples below assume client is already initialized as shown above.
All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
javascripttry { const result = await client.messages.send({ to: '+13125550001', from: '+13125550002', text: 'Hello' }); } catch (err) { if (err instanceof Telnyx.APIConnectionError) { console.error('Network error — check connectivity and retry'); } else if (err instanceof Telnyx.RateLimitError) { // 429: rate limited — wait and retry with exponential backoff const retryAfter = err.headers?.['retry-after'] || 1; await new Promise(r => setTimeout(r, retryAfter * 1000)); } else if (err instanceof Telnyx.APIError) { console.error(`API error ${err.status}: ${err.message}`); if (err.status === 422) { console.error('Validation error — check required fields and formats'); } } }
Common error codes: 401 invalid API key, 403 insufficient permissions, 404 resource not found, 422 validation error (check field formats), 429 rate limited (retry with exponential backoff).
for await (const item of result) { ... } to iterate through all pages automatically.OAuth 2.0 Authorization Server Metadata (RFC 8414)
GET /.well-known/oauth-authorization-server
javascriptconst response = await client.wellKnown.retrieveAuthorizationServerMetadata(); console.log(response.authorization_endpoint);
Returns: authorization_endpoint (uri), code_challenge_methods_supported (arraystring]), grant_types_supported (arraystring]), introspection_endpoint (uri), issuer (uri), jwks_uri (uri), registration_endpoint (uri), response_types_supported (arraystring]), scopes_supported (arraystring]), token_endpoint (uri), token_endpoint_auth_methods_supported (arraystring])
OAuth 2.0 Protected Resource Metadata for resource discovery
GET /.well-known/oauth-protected-resource
javascriptconst response = await client.wellKnown.retrieveProtectedResourceMetadata(); console.log(response.authorization_servers);
Returns: authorization_servers (arraystring]), resource (uri)
OAuth 2.0 authorization endpoint for the authorization code flow
GET /oauth/authorize
javascriptawait client.oauth.retrieveAuthorize({ client_id: '550e8400-e29b-41d4-a716-446655440000', redirect_uri: 'https://example.com', response_type: 'code', });
Retrieve details about an OAuth consent token
GET /oauth/consent/{consent_token}
javascriptconst oauth = await client.oauth.retrieve('consent_token'); console.log(oauth.data);
Returns: client_id (string), logo_uri (uri), name (string), policy_uri (uri), redirect_uri (uri), requested_scopes (arrayobject]), tos_uri (uri), verified (boolean)
Create an OAuth authorization grant
POST /oauth/grants — Required: allowed, consent_token
javascriptconst response = await client.oauth.grants({ allowed: true, consent_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example' }); console.log(response.redirect_uri);
Returns: redirect_uri (uri)
Introspect an OAuth access token to check its validity and metadata
POST /oauth/introspect — Required: token
javascriptconst response = await client.oauth.introspect({ token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example' }); console.log(response.client_id);
Returns: active (boolean), aud (string), client_id (string), exp (integer), iat (integer), iss (string), scope (string)
Retrieve the JSON Web Key Set for token verification
GET /oauth/jwks
javascriptconst response = await client.oauth.retrieveJwks(); console.log(response.keys);
Returns: keys (arrayobject])
Register a new OAuth client dynamically (RFC 7591)
POST /oauth/register
Optional: client_name (string), grant_types (arraystring]), logo_uri (uri), policy_uri (uri), redirect_uris (arraystring]), response_types (arraystring]), scope (string), token_endpoint_auth_method (enum: none, client_secret_basic, client_secret_post), tos_uri (uri)
javascriptconst response = await client.oauth.register(); console.log(response.client_id);
Returns: client_id (string), client_id_issued_at (integer), client_name (string), client_secret (string), grant_types (arraystring]), logo_uri (uri), policy_uri (uri), redirect_uris (arraystring]), response_types (arraystring]), scope (string), token_endpoint_auth_method (string), tos_uri (uri)
Exchange authorization code, client credentials, or refresh token for access token
POST /oauth/token — Required: grant_type
Optional: client_id (string), client_secret (string), code (string), code_verifier (string), redirect_uri (uri), refresh_token (string), scope (string)
javascriptconst response = await client.oauth.token({ grant_type: 'client_credentials' }); console.log(response.access_token);
Returns: access_token (string), expires_in (integer), refresh_token (string), scope (string), token_type (enum: Bearer)
Retrieve a paginated list of OAuth clients for the authenticated user
GET /oauth_clients
javascript// Automatically fetches more pages as needed. for await (const oauthClient of client.oauthClients.list()) { console.log(oauthClient.client_id); }
Returns: allowed_grant_types (arraystring]), allowed_scopes (arraystring]), client_id (string), client_secret (string | null), client_type (enum: public, confidential), created_at (date-time), logo_uri (uri), name (string), org_id (string), policy_uri (uri), record_type (enum: oauth_client), redirect_uris (arraystring]), require_pkce (boolean), tos_uri (uri), updated_at (date-time), user_id (string)
Create a new OAuth client
POST /oauth_clients — Required: name, allowed_scopes, client_type, allowed_grant_types
Optional: logo_uri (uri), policy_uri (uri), redirect_uris (arraystring]), require_pkce (boolean), tos_uri (uri)
javascriptconst oauthClient = await client.oauthClients.create({ allowed_grant_types: ['client_credentials'], allowed_scopes: ['admin'], client_type: 'public', name: 'My OAuth client', }); console.log(oauthClient.data);
Returns: allowed_grant_types (arraystring]), allowed_scopes (arraystring]), client_id (string), client_secret (string | null), client_type (enum: public, confidential), created_at (date-time), logo_uri (uri), name (string), org_id (string), policy_uri (uri), record_type (enum: oauth_client), redirect_uris (arraystring]), require_pkce (boolean), tos_uri (uri), updated_at (date-time), user_id (string)
Retrieve a single OAuth client by ID
GET /oauth_clients/{id}
javascriptconst oauthClient = await client.oauthClients.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); console.log(oauthClient.data);
Returns: allowed_grant_types (arraystring]), allowed_scopes (arraystring]), client_id (string), client_secret (string | null), client_type (enum: public, confidential), created_at (date-time), logo_uri (uri), name (string), org_id (string), policy_uri (uri), record_type (enum: oauth_client), redirect_uris (arraystring]), require_pkce (boolean), tos_uri (uri), updated_at (date-time), user_id (string)
Update an existing OAuth client
PUT /oauth_clients/{id}
Optional: allowed_grant_types (arraystring]), allowed_scopes (arraystring]), logo_uri (uri), name (string), policy_uri (uri), redirect_uris (arraystring]), require_pkce (boolean), tos_uri (uri)
javascriptconst oauthClient = await client.oauthClients.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); console.log(oauthClient.data);
Returns: allowed_grant_types (arraystring]), allowed_scopes (arraystring]), client_id (string), client_secret (string | null), client_type (enum: public, confidential), created_at (date-time), logo_uri (uri), name (string), org_id (string), policy_uri (uri), record_type (enum: oauth_client), redirect_uris (arraystring]), require_pkce (boolean), tos_uri (uri), updated_at (date-time), user_id (string)
Delete an OAuth client
DELETE /oauth_clients/{id}
javascriptawait client.oauthClients.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
Retrieve a paginated list of OAuth grants for the authenticated user
GET /oauth_grants
javascript// Automatically fetches more pages as needed. for await (const oauthGrant of client.oauthGrants.list()) { console.log(oauthGrant.id); }
Returns: client_id (string), created_at (date-time), id (uuid), last_used_at (date-time), record_type (enum: oauth_grant), scopes (arraystring])
Retrieve a single OAuth grant by ID
GET /oauth_grants/{id}
javascriptconst oauthGrant = await client.oauthGrants.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); console.log(oauthGrant.data);
Returns: client_id (string), created_at (date-time), id (uuid), last_used_at (date-time), record_type (enum: oauth_grant), scopes (arraystring])
Revoke an OAuth grant
DELETE /oauth_grants/{id}
javascriptconst oauthGrant = await client.oauthGrants.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); console.log(oauthGrant.data);
Returns: client_id (string), created_at (date-time), id (uuid), last_used_at (date-time), record_type (enum: oauth_grant), scopes (arraystring])
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 14,329 | 9,304 | -35% | 1 | 1 | 0% | 2,699 | 5,285 | +96% | 0 | 0 | — |
case-22 | fail→pass | 10,207 | 5,177 | -49% | 1 | 1 | 0% | 2,143 | 4,384 | +105% | 0 | 0 | — |
case-02 | fail→pass | 8,565 | 5,066 | -41% | 1 | 1 | 0% | 1,642 | 4,367 | +166% | 0 | 0 | — |
case-03 | pass→pass | 10,779 | 6,003 | -44% | 1 | 1 | 0% | 2,052 | 4,548 | +122% | 0 | 0 | — |
case-04 | fail→pass | 5,866 | 4,437 | -24% | 1 | 1 | 0% | 1,122 | 4,108 | +266% | 0 | 0 | — |
case-05 | pass→pass | 10,927 | 7,604 | -30% | 1 | 1 | 0% | 2,202 | 4,659 | +112% | 0 | 0 | — |
case-06 | pass→pass | 16,346 | 6,207 | -62% | 1 | 1 | 0% | 1,757 | 4,356 | +148% | 0 | 0 | — |
case-07 | fail→pass | 10,610 | 2,162 | -80% | 1 | 1 | 0% | 1,946 | 3,709 | +91% | 0 | 0 | — |
case-08 | fail→pass | 12,155 | 3,191 | -74% | 1 | 1 | 0% | 2,298 | 3,827 | +67% | 0 | 0 | — |
case-09 | fail→pass | 8,987 | 3,676 | -59% | 1 | 1 | 0% | 1,758 | 4,009 | +128% | 0 | 0 | — |
case-10 | fail→pass | 7,788 | 3,027 | -61% | 1 | 1 | 0% | 1,461 | 3,892 | +166% | 0 | 0 | — |
case-11 | fail→pass | 8,310 | 2,496 | -70% | 1 | 1 | 0% | 1,481 | 3,796 | +156% | 0 | 0 | — |
case-12 | fail→pass | 15,646 | 4,304 | -72% | 1 | 1 | 0% | 2,863 | 4,263 | +49% | 0 | 0 | — |
case-13 | fail→pass | 9,377 | 2,492 | -73% | 1 | 1 | 0% | 1,884 | 3,760 | +100% | 0 | 0 | — |
case-14 | fail→pass | 9,286 | 3,799 | -59% | 1 | 1 | 0% | 1,660 | 4,146 | +150% | 0 | 0 | — |
case-15 | pass→pass | 7,626 | 5,523 | -28% | 1 | 1 | 0% | 1,520 | 4,546 | +199% | 0 | 0 | — |
case-16 | pass→pass | 6,163 | 4,140 | -33% | 1 | 1 | 0% | 1,269 | 4,235 | +234% | 0 | 0 | — |
case-17 | pass→pass | 6,397 | 5,430 | -15% | 1 | 1 | 0% | 1,364 | 4,447 | +226% | 0 | 0 | — |
case-18 | pass→pass | 4,624 | 2,143 | -54% | 1 | 1 | 0% | 1,016 | 3,717 | +266% | 0 | 0 | — |
case-19 | pass→pass | 5,373 | 2,218 | -59% | 1 | 1 | 0% | 1,160 | 3,723 | +221% | 0 | 0 | — |
case-20 | fail→pass | 7,107 | 3,656 | -49% | 1 | 1 | 0% | 1,512 | 4,079 | +170% | 0 | 0 | — |
case-21 | fail→pass | 7,455 | 3,850 | -48% | 1 | 1 | 0% | 1,559 | 4,074 | +161% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +64 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.