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

# Create an auth token.

> Create a short-term authentication token using user credentials for exchanging access and refresh tokens.



## OpenAPI

````yaml /api-spec/ias-public-api.yaml post /me/auth-tokens
openapi: 3.0.3
info:
  title: IAM Service API
  description: APIs for IAM Service.
  version: 2.4.0
servers:
  - url: https://console.gmicloud.ai/api/v1
    description: IAM Service API
security: []
paths:
  /me/auth-tokens:
    post:
      tags:
        - me
      summary: Create an auth token.
      description: >-
        Create a short-term authentication token using user credentials for
        exchanging access and refresh tokens.
      operationId: createAuthToken
      requestBody:
        description: The create session request body.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createAuthTokenRequest'
      responses:
        '201':
          description: Successfully created an auth token for user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/authTokenResponse'
        '400':
          description: >
            - [group:**request**, code:**0**]: Invalid field in the request
            body.

            - [group:**request**, code:**1**]: The request body is required.

            - [group:**session**, code:**0**]: Invalid email or password.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Invalid field in the request body:
                  summary: Invalid field in the request body.
                  value:
                    group: request
                    code: 0
                    validationDetail:
                      - field: email
                        expression: required
                        originalValue: ''
                        reason: This field is required.
                No request body:
                  summary: No request body.
                  value:
                    group: request
                    code: 1
                    message: The request body is required.
                Invalid email or password:
                  summary: Invalid email or password.
                  value:
                    group: session
                    code: 0
                    message: Invalid email or password.
        '429':
          description: |
            - [group:**rate-limit**, code:**0**]: Rate limit exceeded.
          headers:
            Retry-After:
              description: The number of seconds the user should wait before retrying.
              schema:
                type: integer
                example: 300
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Rate limit exceeded:
                  summary: Rate limit exceeded.
                  value:
                    group: rate-limit
                    code: 0
                    message: Rate limit exceeded.
        '500':
          description: >
            - [group:**email**, code:**0**]: Failed to send email.

            - [group:**rate-limit**, code:**1**]: Failed to get rate limit
            configuration.

            - [group:**rate-limit**, code:**2**]: Failed to save rate limit
            configuration.

            - [group:**session**, code:**200**]: Failed to create auth token.

            - [group:**session**, code:**201**]: Failed to save auth token data.

            - [group:**session**, code:**204**]: Failed to create OTP code.

            - [group:**session**, code:**207**]: Unsupported OTP code delivery
            method.

            - [group:**user**, code:**1200**]: Get user encountered DB error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Failed to create auth token:
                  summary: Failed to create auth token.
                  value:
                    group: session
                    code: 200
                    message: Failed to create auth token.
                    traces:
                      - error occurred.
components:
  schemas:
    createAuthTokenRequest:
      type: object
      x-go-name: createAuthTokenRequest
      properties:
        email:
          type: string
          description: |
            User's email address.
            - Must be a valid email format.
          example: john_doe@example.com
          x-oapi-codegen-extra-tags:
            binding: required,email
        password:
          type: string
          description: User's password.
          example: john_doe_password
          x-oapi-codegen-extra-tags:
            binding: required
      required:
        - email
        - password
    authTokenResponse:
      type: object
      x-go-name: authTokenResponse
      properties:
        authToken:
          type: string
          description: >-
            A temporary token issued  after the initial login step. This token
            is used in the create session API to exchange for access and refresh
            tokens.
          example: eyJhbGciOiJIUzI1NiIsInR...
        is2FARequired:
          type: boolean
          description: >-
            Whether two-factor authentication (2FA) is required for the create
            session API. If `true`, the client must include an OTP code in the
            request body to complete the authentication.
          example: true
      required:
        - authToken
        - is2FARequired
    ErrStatusMsg:
      type: object
      properties:
        group:
          type: string
          description: >-
            API function group\n -Will be "request" if there are invalid request
            parameters.
          x-oapi-codegen-extra-tags:
            binding: required
        code:
          type: integer
          description: The substatus error code for the API response.
          x-oapi-codegen-extra-tags:
            binding: required
        message:
          type: string
          description: The substatus error Message for API response.
          x-go-type-skip-optional-pointer: true
        traces:
          type: array
          items:
            type: string
          description: The original error messages.
          x-go-type-skip-optional-pointer: true
        validationDetail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationDetail'
          description: >-
            Returned when there are invalid request
            paremeters(group="request")\n List of invalid fields and the reason
            of error.
          x-go-type-skip-optional-pointer: true
      example:
        group: request
        code: 0
        validationDetail:
          - field: email
            expression: required
            originalValue: ''
            reason: This field is required.
      required:
        - group
        - code
    ValidationDetail:
      type: object
      properties:
        field:
          type: string
          description: The field of the request data.
          x-go-type-skip-optional-pointer: true
        expression:
          type: string
          description: The form of violation.
          x-go-type-skip-optional-pointer: true
        argument:
          type: string
          description: The number or data to support the expression.
          x-go-type-skip-optional-pointer: true
        originalValue:
          description: The original value from the request.
          x-go-type-skip-optional-pointer: true
        reason:
          type: string
          description: The reason for the validation error.
          x-go-type-skip-optional-pointer: true
      example:
        - field: fieldXXX
          expression: required
          originalValue: ''
          reason: This field is required.

````