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

# token_refresh

> Refreshes an existing access token, extending its validity period. Call this endpoint before the current token expires to maintain uninterrupted access.

Use the expires_in value from the login or previous refresh response to determine when to refresh the token. A common practice is to refresh when the token has half of its time remaining.

On success, the endpoint returns the 200 response and a JSON object containing a new access token and metadata about the refreshed session. Replace the access token in your client with the new token returned by the endpoint, and use the expires_in value to decide when to refresh again.



## OpenAPI

````yaml /openapi/generated-api-methods.json POST /v1/token_refresh
openapi: 3.1.0
info:
  title: Generated API methods
  version: 1.0.0
  description: Generated from imported ApiMethodV2 blocks.
servers:
  - url: https://{sql_node}
    variables:
      sql_node:
        default: sql_node
  - url: http://oc1-lts0:9090
security: []
paths:
  /v1/token_refresh:
    post:
      tags:
        - Ocient HTTP Query API
      summary: token_refresh
      description: >-
        Refreshes an existing access token, extending its validity period. Call
        this endpoint before the current token expires to maintain uninterrupted
        access.


        Use the expires_in value from the login or previous refresh response to
        determine when to refresh the token. A common practice is to refresh
        when the token has half of its time remaining.


        On success, the endpoint returns the 200 response and a JSON object
        containing a new access token and metadata about the refreshed session.
        Replace the access token in your client with the new token returned by
        the endpoint, and use the expires_in value to decide when to refresh
        again.
      operationId: postOcientHttpQueryApiTokenRefresh
      parameters:
        - name: Authorization
          in: header
          required: true
          description: >-
            The bearer token, which must be a valid access token still within
            its refresh lifetime configured on the server. To obtain a token,
            call either the /v1/login or /v1/token_refresh endpoints.
          schema:
            type: string
        - name: Content-Type
          in: header
          required: true
          description: 'Specifies the request body format. Use the value: application/json.'
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                database:
                  type: string
                  description: >-
                    Target database name. If you do not specify this parameter,
                    the request defaults this value to system.
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                  username:
                    type: string
                  database:
                    type: string
                  expires_in:
                    type: integer
                  status:
                    type: object
                    properties:
                      reason:
                        type: string
                      sql_state:
                        type: string
                      vendor_code:
                        type: integer
              examples:
                response:
                  value:
                    access_token: eyJhb...
                    username: jdoe
                    database: retail_analytics
                    expires_in: 3600
                    status:
                      reason: Token refreshed successfully
                      sql_state: '00000'
                      vendor_code: 0
      servers:
        - url: https://{sql_node}
          variables:
            sql_node:
              default: sql_node
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl -X POST https://your-ocient-instance/v1/token_refresh \
                -H "Authorization: Bearer YOUR_CURRENT_TOKEN" \
                -H "Content-Type: application/json" \
                -d '{
                    "database": "retail_analytics"
                }'

````