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

# End a session

> Stores the final transcript and variables, writes `session.ended` and the call log, settles the charge by the project's pricing rule and runs the project's post-session steps (`session.finalized` fires right after the settlement: a custom call has no recording to wait for). A `text` session and a test call answer `chargeStatus: "not_charged"`. Calling it twice returns the first result.



## OpenAPI

````yaml https://api.pathors.com/openapi.json post /v1/projects/{projectId}/custom-agent/sessions/{sessionId}/end
openapi: 3.1.0
info:
  title: Pathors API
  description: >-
    Public developer API for the Pathors platform. Authenticate with a developer
    key (`Authorization: Bearer dk_...`) created from the dashboard. See
    [docs.pathors.com](https://docs.pathors.com) for guides.
  version: 1.0.0
  contact:
    name: Pathors Support
    url: https://app.pathors.com/support
servers:
  - url: https://api.pathors.com
    description: Production
  - url: http://localhost:8080
    description: Local development
security:
  - developerKey: []
tags:
  - name: Projects
    description: CRUD for projects owned by the authenticated developer
  - name: Agent Config
    description: Read and update a project's agent configuration and versions
  - name: Pathway
    description: Manage a project's pathway graph — nodes and decision edges
  - name: Chat
    description: OpenAI-compatible chat completions for a project agent
  - name: Sessions
    description: Create, search, terminate, and inspect agent sessions
  - name: Session History
    description: Browse and inspect persisted session history
  - name: Tools
    description: Manage a project's tools and inspect available tool types
  - name: Knowledgebases
    description: Manage knowledgebases and query them for relevant chunks
  - name: Datasets
    description: Upload and manage source files embedded into a knowledgebase
  - name: Test Cases
    description: CRUD for agent test cases
  - name: Test Suites
    description: Group test cases, run them, and read results
  - name: Webhooks
    description: Manage webhook subscriptions for project events
  - name: Calls
    description: Place outbound voice calls from a project agent
  - name: Campaigns
    description: Create and activate outbound campaigns that dial a call list
paths:
  /v1/projects/{projectId}/custom-agent/sessions/{sessionId}/end:
    post:
      tags:
        - Custom Agent
      summary: End a session
      description: >-
        Stores the final transcript and variables, writes `session.ended` and
        the call log, settles the charge by the project's pricing rule and runs
        the project's post-session steps (`session.finalized` fires right after
        the settlement: a custom call has no recording to wait for). A `text`
        session and a test call answer `chargeStatus: "not_charged"`. Calling it
        twice returns the first result.
      operationId: postV1ProjectsByProjectIdCustomAgentSessionsBySessionIdEnd
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
          description: The ID of your project
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
          description: The session id returned by POST /sessions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $schema: https://json-schema.org/draft/2020-12/schema
              type: object
              properties:
                endedAt:
                  type: string
                  format: date-time
                  pattern: >-
                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
                durationSeconds:
                  type: number
                  minimum: 0
                  maximum: 86400
                reason:
                  type: string
                  enum:
                    - caller_hangup
                    - agent_hangup
                    - transferred
                    - time_limit
                    - error
                status:
                  default: completed
                  type: string
                  enum:
                    - completed
                    - failed
                    - no_answer
                messages:
                  default: []
                  maxItems: 2000
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - assistant
                      content:
                        type: string
                        maxLength: 20000
                      timestamp:
                        type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
                      interrupted:
                        type: boolean
                    required:
                      - role
                      - content
                variables:
                  default: {}
                  type: object
                  propertyNames:
                    type: string
                    minLength: 1
                    maxLength: 128
                  additionalProperties: {}
                summary:
                  type: string
                  maxLength: 4000
              required:
                - endedAt
                - durationSeconds
                - reason
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      sessionId:
                        type: string
                      chargeStatus:
                        type: string
                        enum:
                          - settled
                          - pending
                          - not_charged
                      charge:
                        anyOf:
                          - type: object
                            properties:
                              amountUsd:
                                type: number
                              billedMinutes:
                                type: number
                              ratePerMin:
                                type: number
                              rule:
                                type: string
                            required:
                              - amountUsd
                              - billedMinutes
                              - ratePerMin
                              - rule
                          - type: 'null'
                      cost:
                        type: object
                        properties:
                          llmUsd:
                            type: number
                          sttUsd:
                            type: number
                          ttsUsd:
                            type: number
                          otherUsd:
                            type: number
                          totalUsd:
                            type: number
                        required:
                          - llmUsd
                          - sttUsd
                          - ttsUsd
                          - otherUsd
                          - totalUsd
                    required:
                      - sessionId
                      - chargeStatus
                      - charge
                      - cost
                required:
                  - data
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                required:
                  - error
        '401':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                required:
                  - error
        '403':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                required:
                  - error
        '404':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                required:
                  - error
        '409':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                required:
                  - error
components:
  securitySchemes:
    developerKey:
      type: http
      scheme: bearer
      bearerFormat: Developer key (dk_...)
      description: Developer key created from the dashboard (Settings → Developer Keys)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.