> ## 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.

# Refresh session

> Refresh an existing session, which will return a new access token and refresh token.



## OpenAPI

````yaml /api-spec/ias-public-api.yaml patch /me/sessions
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/sessions:
    patch:
      tags:
        - me
      summary: Refresh session
      description: >-
        Refresh an existing session, which will return a new access token and
        refresh token.
      operationId: refreshSession
      parameters:
        - $ref: '#/components/parameters/clientIdParam'
      requestBody:
        description: The refresh session request body.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/refreshSessionRequest'
      responses:
        '200':
          description: Successfully refreshed an existing session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sessionResponse'
        '400':
          description: >
            - [group:**request**, code:**0**]: Invalid field in the request
            body.

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

            - [group:**auth**, code:**0**]: Invalid CE-ClientId.

            - [group:**auth**, code:**1**]: Invalid refreshToken.
          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 refreshToken:
                  summary: Invalid refreshToken.
                  value:
                    group: auth
                    code: 1
                    message: Invalid refreshToken.
        '500':
          description: |
            - [group:**session**, code:**1**]: Failed to create access token.
            - [group:**session**, code:**2**]: Failed to create refresh token.
            - [group:**session**, code:**3**]: Failed to save session to cache.
            - [group:**session**, code:**4**]: Failed to get session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrStatusMsg'
              examples:
                Failed to create access token:
                  summary: Failed to create access token.
                  value:
                    group: auth
                    code: 1000
                    message: Failed to create access token.
                    traces:
                      - error occurred.
components:
  parameters:
    clientIdParam:
      name: CE-ClientId
      in: header
      schema:
        type: string
      required: true
      description: |
        A unique identifier to each user device and browser.
        - Must be less than 8 characters.
        - Only alphanumeric characters are allowed.
  schemas:
    refreshSessionRequest:
      type: object
      x-go-name: refreshSessionRequest
      properties:
        refreshToken:
          type: string
          description: >-
            The token to refresh the session. A refresh token can only be used
            once.
          example: eyJhbGciOiJIUzI1NiIsInR...
          x-oapi-codegen-extra-tags:
            binding: required
      required:
        - refreshToken
    sessionResponse:
      type: object
      x-go-name: sessionResponse
      properties:
        accessToken:
          type: string
          description: The access token for API requests.
          example: eyJhbGciOiJIUzI1NiIsInR...
        refreshToken:
          type: string
          description: The refresh token for session management.
          example: eyJhbGciOiJIUzI1NiIsInR...
      required:
        - accessToken
        - refreshToken
    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.

````