> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create OAuth client

> Create a new OAuth client



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/oauth.yml post /oauth/clients
openapi: 3.1.0
info:
  title: Telnyx OAuth API
  version: 2.0.0
  description: API for OAuth.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /oauth/clients:
    post:
      tags:
        - OAuth Clients
      summary: Create OAuth client
      description: Create a new OAuth client
      operationId: CreateOAuthClient
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OAuthClientCreateRequest'
      responses:
        '201':
          description: OAuth client created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/OAuthClient'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/oauth_Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/oauth_Error'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/oauth_Error'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const oauthClient = await client.oauthClients.create({
              allowed_grant_types: ['client_credentials'],
              allowed_scopes: ['admin'],
              client_type: 'public',
              name: 'My OAuth client',
            });

            console.log(oauthClient.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            oauth_client = client.oauth_clients.create(
                allowed_grant_types=["client_credentials"],
                allowed_scopes=["admin"],
                client_type="public",
                name="My OAuth client",
            )
            print(oauth_client.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\toauthClient, err := client.OAuthClients.New(context.TODO(), telnyx.OAuthClientNewParams{\n\t\tAllowedGrantTypes: []string{\"client_credentials\"},\n\t\tAllowedScopes:     []string{\"admin\"},\n\t\tClientType:        telnyx.OAuthClientNewParamsClientTypePublic,\n\t\tName:              \"My OAuth client\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", oauthClient.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.oauthclients.OAuthClientCreateParams;
            import com.telnyx.sdk.models.oauthclients.OAuthClientCreateResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    OAuthClientCreateParams params = OAuthClientCreateParams.builder()
                        .addAllowedGrantType(OAuthClientCreateParams.AllowedGrantType.CLIENT_CREDENTIALS)
                        .addAllowedScope("admin")
                        .clientType(OAuthClientCreateParams.ClientType.PUBLIC)
                        .name("My OAuth client")
                        .build();
                    OAuthClientCreateResponse oauthClient = client.oauthClients().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            oauth_client = telnyx.oauth_clients.create(
              allowed_grant_types: [:client_credentials],
              allowed_scopes: ["admin"],
              client_type: :public,
              name: "My OAuth client"
            )

            puts(oauth_client)
        - lang: CLI
          source: |-
            telnyx oauth-clients create \
              --api-key 'My API Key' \
              --allowed-grant-type client_credentials \
              --allowed-scope admin \
              --client-type public \
              --name 'My OAuth client'
components:
  schemas:
    OAuthClientCreateRequest:
      type: object
      properties:
        name:
          type: string
          description: The name of the OAuth client
          example: My OAuth client
        allowed_scopes:
          type: array
          items:
            type: string
          description: List of allowed OAuth scopes
          example:
            - admin
        client_type:
          type: string
          enum:
            - public
            - confidential
          description: OAuth client type
        require_pkce:
          type: boolean
          description: >-
            Whether PKCE (Proof Key for Code Exchange) is required for this
            client
          default: false
        allowed_grant_types:
          type: array
          items:
            type: string
            enum:
              - client_credentials
              - authorization_code
              - refresh_token
          description: List of allowed OAuth grant types
        redirect_uris:
          type: array
          items:
            type: string
            format: uri
          description: List of redirect URIs (required for authorization_code flow)
          default: []
        logo_uri:
          type: string
          format: uri
          description: URL of the client logo
        policy_uri:
          type: string
          format: uri
          description: URL of the client's privacy policy
        tos_uri:
          type: string
          format: uri
          description: URL of the client's terms of service
      required:
        - name
        - allowed_scopes
        - client_type
        - allowed_grant_types
      additionalProperties: false
    OAuthClient:
      type: object
      properties:
        record_type:
          type: string
          enum:
            - oauth_client
          description: Record type identifier
        client_id:
          type: string
          description: OAuth client identifier
        name:
          type: string
          description: Human-readable name for the OAuth client
        org_id:
          type: string
          description: Organization ID that owns this OAuth client
        user_id:
          type: string
          description: User ID that created this OAuth client
        allowed_scopes:
          type: array
          items:
            type: string
          description: List of allowed OAuth scopes
        client_type:
          type: string
          enum:
            - public
            - confidential
          description: OAuth client type
        require_pkce:
          type: boolean
          description: >-
            Whether PKCE (Proof Key for Code Exchange) is required for this
            client
        allowed_grant_types:
          type: array
          items:
            type: string
            enum:
              - client_credentials
              - authorization_code
              - refresh_token
          description: List of allowed OAuth grant types
        redirect_uris:
          type: array
          items:
            type: string
            format: uri
          description: List of allowed redirect URIs
        logo_uri:
          type:
            - string
            - 'null'
          format: uri
          description: URL of the client logo
        tos_uri:
          type:
            - string
            - 'null'
          format: uri
          description: URL of the client's terms of service
        policy_uri:
          type:
            - string
            - 'null'
          format: uri
          description: URL of the client's privacy policy
        client_secret:
          type:
            - string
            - 'null'
          description: >-
            Client secret (only included when available, for confidential
            clients)
        created_at:
          type: string
          format: date-time
          description: Timestamp when the client was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the client was last updated
      required:
        - record_type
        - client_id
        - name
        - org_id
        - user_id
        - client_type
        - require_pkce
        - created_at
        - updated_at
    oauth_Error:
      type: object
      properties:
        error:
          type: string
          description: Error code
        error_description:
          type: string
          description: Human-readable error description
      required:
        - error
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````