# Obtain a token

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /{tenantCode}/v1/auth/token:
    post:
      summary: Obtain a token
      deprecated: false
      description: >-
        This is the common endpoint to obtain a token to access the API using
        the Client Credentials Grant
      tags:
        - v1/Authentication
        - Authentication
      parameters:
        - name: tenantCode
          in: path
          description: ''
          required: true
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClientCredentialTokenRequestDto'
      responses:
        201 - Token created:
          description: Token created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponseDtoResponseDto'
          headers: {}
          x-apidog-name: Success
        400 - Invalid credentials:
          description: Invalid credentials
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/ErrorResponseDto'
          headers: {}
          x-apidog-name: Success
        400 - Invalid scope:
          description: Invalid scope
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apidog-name: Success
        400 - Invalid tenant:
          description: Invalid tenant
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apidog-name: Success
      security: []
      x-apidog-folder: v1/Authentication
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/588483/apis/api-10817083-run
components:
  schemas:
    ClientCredentialTokenRequestDto:
      type: object
      properties:
        clientId:
          type: string
          description: Client Id you obtained as part of the registration process.
          nullable: true
        clientSecret:
          type: string
          description: Client Secret you obtained as part of the registration process.
          nullable: true
        scope:
          type: string
          description: "Scope you wish to access. \r\nEg: confirmapay:all \r\nconfirmapay:payments:all \r\nconfirmapay:transactions:all"
          nullable: true
      additionalProperties: false
      description: Request structure for requesting a token.
      x-apidog-orders:
        - clientId
        - clientSecret
        - scope
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    TokenResponseDtoResponseDto:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/TokenResponseDto'
        description: &ref_1
          $ref: '#/components/schemas/ApplicationMessageDto'
        narrative: *ref_1
      additionalProperties: false
      description: Response structure for a successful request.
      x-apidog-orders:
        - data
        - description
        - narrative
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ApplicationMessageDto:
      type: object
      properties:
        code:
          type: string
          nullable: true
        message:
          type: string
          nullable: true
      additionalProperties: false
      x-apidog-orders:
        - code
        - message
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    TokenResponseDto:
      type: object
      properties:
        accessToken:
          type: string
          nullable: true
        tokenType:
          type: string
          nullable: true
        expiresIn:
          type: integer
          description: In seconds
          format: int32
      additionalProperties: false
      x-apidog-orders:
        - accessToken
        - tokenType
        - expiresIn
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ErrorResponseDto:
      type: object
      properties:
        code:
          type: string
          description: "Application code for the error.\r\nEg: TRANSACTION-NOT-FOUND, TERMINAL-ID-IS-REQUIRED etc"
          nullable: true
        message:
          type: string
          description: "Friendly message for the error.\r\nEg: Transaction not found, Terminal Id is required etc"
          nullable: true
        validationErrors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Description on request body validation errors.
          x-apidog-orders: []
          properties: {}
          x-apidog-ignore-properties: []
          nullable: true
      additionalProperties: false
      description: Response structure for a failed request.
      x-apidog-orders:
        - code
        - message
        - validationErrors
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes: {}
servers:
  - url: https://sandbox.api.confirmapay.com
    description: Sandbox Env
security: []

```
