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

# End Session

> Finalize the session and start asynchronous processing. After this call no further audio uploads are accepted. The server collects and orders all uploaded chunks, commits the session, and queues it for transcription and template extraction. Poll `GET /voice/v1/sessions/{session_id}` (or use a webhook) to retrieve results once processing completes.


Lock the session and start processing — no body required. After this call no more audio is accepted.

On `202 Accepted`, poll [Get Session](/ekascribe/api-reference/sessions/get-session) (or use a [webhook](/api-reference/connect/webhooks/getting-started)) until the results are ready.


## OpenAPI

````yaml POST /voice/v1/sessions/{session_id}/end
openapi: 3.0.1
info:
  title: EkaScribe Protocol API (MedScribeAlliance v0.1)
  version: '0.1'
  description: >
    Session-based medical voice capture API implementing the MedScribeAlliance
    Protocol v0.1. Discover service capabilities, create a session, stream audio
    chunks, then end the session to trigger asynchronous transcription and
    structured-template extraction.
servers:
  - url: https://api.eka.care
    description: Production server
  - url: https://api.dev.eka.care
    description: Development server
security: []
paths:
  /voice/v1/sessions/{session_id}/end:
    post:
      tags:
        - protocol
      summary: End Session
      description: >
        Finalize the session and start asynchronous processing. After this call
        no further audio uploads are accepted. The server collects and orders
        all uploaded chunks, commits the session, and queues it for
        transcription and template extraction. Poll `GET
        /voice/v1/sessions/{session_id}` (or use a webhook) to retrieve results
        once processing completes.
      parameters:
        - name: session_id
          in: path
          required: true
          description: Session ID returned by Create Session
          schema:
            type: string
            example: ses_abc123def456
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EndSessionRequest'
            example:
              audio_files_sent: 3
      responses:
        '202':
          description: Session ended, processing started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EndSessionResponse'
              example:
                session_id: ses_abc123def456
                status: processing
                message: Session ended. Processing started.
                audio_files_received: 3
                audio_files:
                  - 0.webm
                  - 1.webm
                  - 2.webm
        '400':
          description: Session already ended
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - auth: []
components:
  schemas:
    EndSessionRequest:
      type: object
      properties:
        audio_files_sent:
          type: integer
          minimum: 0
          description: >-
            Optional number of audio chunks/files the client sent, used for
            reconciliation logging.
          example: 3
    EndSessionResponse:
      type: object
      properties:
        session_id:
          type: string
        status:
          type: string
          example: processing
        message:
          type: string
          example: Session ended. Processing started.
        audio_files_received:
          type: integer
          minimum: 0
        audio_files:
          type: array
          items:
            type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code.
              example: invalid_audio_format
            message:
              type: string
              description: Human-readable error message.
              example: Audio format 'audio/mp3' is not supported
            details:
              type: object
              additionalProperties: true
              description: Additional error context.
  securitySchemes:
    auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your auth token.

````