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

# OAuth2 Token

> OAuth2 token endpoint supporting `client_credentials` and `refresh_token` grant types.

**`client_credentials` grant type (default):**

The `client_id` and `client_secret` represent the API key and secret generated from the
Unomiq Dashboard.

The `audience` parameter specifies the target API for the token. Defaults to
`https://api.unomiq.com` (Management and Economic Engine APIs).
Use `https://gateway-api.unomiq.com` for OTel Gateway access.

**`refresh_token` grant type:**

Exchange a refresh token for a new access token. Requires `client_id` and `refresh_token`.
If refresh token rotation is enabled, a new refresh token will also be returned.

**Note:** For automatic OpenTelemetry instrumentation, use the
[OTel OAuth2 Client Credentials Authenticator Extension](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/oauth2clientauthextension)
which handles token retrieval and refresh automatically.



## OpenAPI

````yaml POST /token
openapi: 3.1.0
info:
  title: Unomiq OAuth Authentication API
  description: Validate API credentials and retrieve OAuth2 access tokens.
  version: 1.0.0
servers:
  - url: https://oauth-api.unomiq.com
    description: Production
security: []
paths:
  /token:
    post:
      tags:
        - OAuth2
      summary: OAuth2 token endpoint
      description: >-
        OAuth2 token endpoint supporting `client_credentials` and
        `refresh_token` grant types.


        **`client_credentials` grant type (default):**


        The `client_id` and `client_secret` represent the API key and secret
        generated from the

        Unomiq Dashboard.


        The `audience` parameter specifies the target API for the token.
        Defaults to

        `https://api.unomiq.com` (Management and Economic Engine APIs).

        Use `https://gateway-api.unomiq.com` for OTel Gateway access.


        **`refresh_token` grant type:**


        Exchange a refresh token for a new access token. Requires `client_id`
        and `refresh_token`.

        If refresh token rotation is enabled, a new refresh token will also be
        returned.


        **Note:** For automatic OpenTelemetry instrumentation, use the

        [OTel OAuth2 Client Credentials Authenticator
        Extension](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/oauth2clientauthextension)

        which handles token retrieval and refresh automatically.
      operationId: getToken
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Body_getToken'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_getToken:
      properties:
        client_id:
          type: string
          title: Client Id
        grant_type:
          type: string
          title: Grant Type
          default: client_credentials
        audience:
          type: string
          title: Audience
          default: https://api.unomiq.com
        client_secret:
          type: string
          title: Client Secret
        refresh_token:
          type: string
          title: Refresh Token
      type: object
      required:
        - client_id
      title: Body_getToken
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````