# Token

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/auth/token:
    post:
      summary: Token
      deprecated: false
      description: >
        Obtain an access token.

        Use grant_type = client_credentials.


        The token defines what the client is authorized to do through the scope
        parameter:

        - closedloop.read → allows data retrieval (GET endpoints only)

        - closedloop.write → allows creation, updates, and deletions (POST,
        PATCH, DELETE)
      operationId: token
      tags:
        - Vrtx Closed loop/Auth
        - Auth
      parameters: []
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                grant_type:
                  type: string
                  enum:
                    - client_credentials
                  examples:
                    - client_credentials
                  pattern: \S
                  description: Grant type = client_credentials
                  example: client_credentials
                client_id:
                  type: string
                  examples:
                    - sandbox-e2e-client
                  pattern: \S
                  description: Provided client identifier
                  example: sandbox-e2e-client
                client_secret:
                  type: string
                  examples:
                    - u8H3xNf4T0k3n
                  pattern: \S
                  description: Provided client secret
                  example: u8H3xNf4T0k3n
                scope:
                  type: string
                  examples:
                    - closedloop.read closedloop.write
                  description: Space-delimited scopes
                  example: closedloop.read closedloop.write
              required:
                - grant_type
                - client_id
                - client_secret
      responses:
        '200':
          description: Token response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
              examples:
                TokenResponse:
                  summary: TokenResponse
                  value:
                    access_token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                    token_type: Bearer
                    expires_in: 300
                    refresh_expires_in: 0
                    scope: closedloop.read closedloop.write
          headers:
            Cache-Control:
              description: no-store
              schema:
                type: string
            Pragma:
              description: no-cache
              schema:
                type: string
          x-apidog-name: OK
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequest:
                  summary: BadRequest
                  value:
                    error_code: INVALID_INPUT
                    error_message: Input parameters failed validation
                    details:
                      - field: client_id
                        message: client_id is required
                        code: required
                    status_code: 400
          headers: {}
          x-apidog-name: Bad Request
      security: []
      x-apidog-folder: Vrtx Closed loop/Auth
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1053095/apis/api-24814161-run
components:
  schemas:
    TokenResponse:
      type: object
      required:
        - access_token
        - token_type
        - expires_in
      properties:
        access_token:
          type: string
          description: Access token (JWT)
        token_type:
          type: string
          examples:
            - Bearer
          description: Token type
        expires_in:
          type: integer
          format: int64
          description: Lifetime in seconds
        refresh_token:
          type: string
          description: Refresh token
        refresh_expires_in:
          type: integer
          format: int64
          description: Refresh token lifetime in seconds (Keycloak specific)
        scope:
          type: string
          description: Granted scopes
        id_token:
          type: string
          description: ID Token (optional)
      x-apidog-orders:
        - access_token
        - token_type
        - expires_in
        - refresh_token
        - refresh_expires_in
        - scope
        - id_token
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ErrorResponse:
      type: object
      properties:
        error_code:
          type: string
        error_message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
        status_code:
          type: integer
          format: int32
      x-apidog-orders:
        - error_code
        - error_message
        - details
        - status_code
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ErrorDetail:
      type: object
      properties:
        field:
          type: string
        message:
          type: string
        code:
          type: string
      x-apidog-orders:
        - field
        - message
        - code
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: Enter your JWT access token for authentication
    bearerAuth1:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
    bearerAuth2:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: Enter your JWT access token for authentication
    bearerAuth3:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT issued by Keycloak. The client_id/azp in the token must map to a
        configured tenant (public, fai, neomrs; e.g., fai-sandbox -> fai) or
        requests will return 403.
    bearerAuth4:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: Enter your JWT access token for authentication
    bearer:
      type: http
      scheme: bearer
servers:
  - url: https://api.sandbox.vrtx.sa
    description: Sandbox
security:
  - bearer: []

```
