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

# Stop a session

> Interrupt active session work without archiving it. Continue with the next queued message, or set cancelQueued=true to cancel pending messages too.



## OpenAPI

````yaml https://api.tembo.io/public-api/openapi/public post /v1/sessions/{sessionId}/stop
openapi: 3.1.0
info:
  title: Tembo Public API
  description: >-
    Manage agents, sessions, repositories, and organization resources with the
    Tembo API.
  version: 1.0.0
servers:
  - url: https://api.tembo.io
    description: Tembo API
  - url: https://{deployment-origin}/api/public-api
    description: Self-hosted Tembo
    variables:
      deployment-origin:
        default: tembo.example.com
        description: Hostname of your self-hosted Tembo deployment
security: []
paths:
  /v1/sessions/{sessionId}/stop:
    post:
      tags:
        - Sessions
      summary: Stop a session
      description: >-
        Interrupt active session work without archiving it. Continue with the
        next queued message, or set cancelQueued=true to cancel pending messages
        too.
      operationId: stopSession
      parameters:
        - in: path
          name: sessionId
          schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          required: true
        - in: query
          name: cancelQueued
          schema:
            type: boolean
          description: >-
            Also cancel pending queued messages instead of continuing with the
            next queued message. Does not archive the session.
      responses:
        '200':
          description: Stop a session
          content:
            application/json:
              schema:
                type: object
                properties:
                  cancelledSessions:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  cancelledJobs:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  stoppedRuntimeSessions:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  interruptedRuntimeTurns:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  cancelledRuntimeTurns:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  state:
                    description: >-
                      Canonical session state after stopping and reconciling
                      queued work.
                    type: object
                    properties:
                      current:
                        type: string
                        enum:
                          - inProgress
                          - queued
                          - completed
                          - failed
                          - cancelled
                      isQueued:
                        type: boolean
                      isCancelled:
                        type: boolean
                      isCompleted:
                        type: boolean
                      isFailed:
                        type: boolean
                      inProgress:
                        type: boolean
                    required:
                      - isQueued
                      - isCancelled
                      - isCompleted
                      - isFailed
                      - inProgress
                    additionalProperties: false
                required:
                  - cancelledSessions
                  - cancelledJobs
                  - stoppedRuntimeSessions
                  - interruptedRuntimeTurns
                  - cancelledRuntimeTurns
                additionalProperties: false
        '400':
          description: >-
            Invalid request or missing required organization or user
            information.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '401':
          description: The session is private
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '403':
          description: The caller is not permitted to perform this operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '404':
          description: Session resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '409':
          description: Session operation conflicts with existing data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '500':
          description: Session operation failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
        '502':
          description: Session runtime or provider operation failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
      security:
        - apiKey: []
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: >
            import Tembo from '@tembo-io/sdk';


            const client = new Tembo();


            const session = await
            client.sessions.stop('7c9e6679-7425-40de-944b-e07fc1f90ae7');
        - lang: rust
          label: Rust SDK
          source: |
            use tembo_rs::*;

            let client = Tembo::from_env()?;

            let response = client
                .sessions()
                .stop("7c9e6679-7425-40de-944b-e07fc1f90ae7")
                .send()
                .await?;
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

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