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

# Create Session

> Creates a new MedAssist session that provides a session ID and session token for WebSocket communication.


<RequestExample>
  ```bash cURL theme={null}
  curl --location --request POST 'https://matrix.eka.care/med-assist/session' \
  --header 'x-agent-id: <agent-id>'
  ```

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

  url = "https://api.eka.care/med-assist/session"

  payload = {}
  headers = {
    'x-agent-id': '<agent-id>'
  }

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

  print(response.text)
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.eka.care/med-assist/session";

  const headers = {
    'x-agent-id': '<agent-id>'
  };

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

## Next Steps

After creating a session, use the returned `session_id` and `session_token` to:

1. Connect to the WebSocket endpoint: `wss://api-ws.eka.care/ws/med-assist/session/<session-id>`
2. Authenticate using the session token
3. Start sending medical queries through the WebSocket connection

See the [WebSocket documentation](/api-reference/health-ai/medassist/websocket) for detailed implementation.


## OpenAPI

````yaml POST /med-assist/session
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:
    post:
      summary: Create Session
      description: >
        Creates a new MedAssist session that provides a session ID and session
        token for WebSocket communication.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Session created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  session_id:
                    type: string
                    format: uuid
                    description: Unique session identifier
                    example: a349a41e-5d49-488a-b300-66ccbfdf16b3
                  session_token:
                    type: string
                    description: JWT token for WebSocket authentication
                    example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        '403':
          description: Forbidden. Missing agent or malformed token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: forbidden
                  msg: No agent id provided
        '404':
          description: Not found. Agent ID not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: not_found
                  msg: Agent 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

````