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

# Refresh Session Token

> Refreshes an expired session token to extend the session lifetime.

Use this endpoint when the session token has expired but you want to continue the conversation.


<RequestExample>
  ```bash cURL theme={null}
  curl --location --request GET 'https://api.eka.care/med-assist/session/a349a41e-5d49-488a-b300-66ccbfdf16b3/refresh' \
  --header 'x-agent-id: <agent-id>' \
  --header 'x-sess-token: <old_token>'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.eka.care/med-assist/session/a349a41e-5d49-488a-b300-66ccbfdf16b3/refresh"

  payload = {}
  headers = {
    'x-agent-id': '<agent-id>',
    'x-sess-token': '<old_token>'
  }

  response = requests.request("GET", url, headers=headers, data=payload)

  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.eka.care/med-assist/session/a349a41e-5d49-488a-b300-66ccbfdf16b3/refresh";

  const headers = {
    'x-agent-id': '<agent-id>',
    'x-sess-token': '<old_token>'
  };

  fetch(url, {
    method: 'GET',
    headers: headers
  })
  .then(response => response.text())
  .then(result => console.log(result));
  ```
</RequestExample>

## When to Use

Use this endpoint when your session token has expired but you want to continue the medical consultation. The refresh endpoint allows you to extend the session lifetime without creating a new session.

## Next Steps

After refreshing the token, use the new `session_token` to:

1. Update your WebSocket authentication
2. Continue the medical conversation seamlessly
3. The session ID remains the same, only the token is renewed

For WebSocket implementation details, see the [WebSocket documentation](/api-reference/health-ai/medassist/websocket).


## OpenAPI

````yaml GET /med-assist/session/{session_id}/refresh
openapi: 3.0.1
info:
  title: MedAssist APIs
  description: Medical assistant chat functionality for healthcare consultations
  version: 1.0.0
servers:
  - url: https://api.eka.care
    description: Production server
  - url: https://api.dev.eka.care
    description: Development server
security: []
paths:
  /med-assist/session/{session_id}/refresh:
    get:
      summary: Refresh Session Token
      description: >
        Refreshes an expired session token to extend the session lifetime.


        Use this endpoint when the session token has expired but you want to
        continue the conversation.
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: The unique session identifier
          example: a349a41e-5d49-488a-b300-66ccbfdf16b3
        - name: x-sess-token
          in: header
          required: true
          schema:
            type: string
          description: The expired session token
          example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
      responses:
        '200':
          description: Token refreshed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  session_id:
                    type: string
                    format: uuid
                    description: Unique session identifier
                    example: a349a41e-5d49-488a-b300-66ccbfdf16b3
                  token:
                    type: string
                    description: New JWT token for WebSocket authentication
                    example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                  expires_at:
                    type: string
                    format: date-time
                    description: New token expiration timestamp
                    example: '2024-01-01T14:00:00Z'
        '403':
          description: Forbidden. Missing agent or invalid session token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: forbidden
                  msg: Invalid session token
        '404':
          description: Session not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: not_found
                  msg: Session not found
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: internal_server_error
                  msg: Internal server error
      security:
        - agentAuth: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code identifying the type of error
              example: internal_server_error
            msg:
              type: string
              description: Human-readable error message
              example: No agent id provided
          required:
            - code
            - msg
      required:
        - error
  securitySchemes:
    agentAuth:
      type: apiKey
      in: header
      name: x-agent-id
      description: Your API key for authentication

````