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

# Fork a session

> Create an independent session from a fresh workspace snapshot, or the latest saved snapshot when stopped, without replaying messages or adding context. The fork returns right away and its messages queue until its workspace finishes booting.



## OpenAPI

````yaml https://api.tembo.io/public-api/openapi/public post /v1/sessions/{sessionId}/fork
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}/fork:
    post:
      tags:
        - Sessions
      summary: Fork a session
      description: >-
        Create an independent session from a fresh workspace snapshot, or the
        latest saved snapshot when stopped, without replaying messages or adding
        context. The fork returns right away and its messages queue until its
        workspace finishes booting.
      operationId: forkSession
      parameters:
        - in: path
          name: sessionId
          schema:
            type: string
            format: uuid
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 1000000
                  description: >-
                    Optional first task for the independent fork. Existing
                    messages are not replayed.
                title:
                  type: string
                  minLength: 1
                  maxLength: 1000
                  description: Display title for the forked session.
                queueRightAway:
                  type: boolean
                  default: true
                  description: >-
                    Start the supplied prompt immediately. Without a prompt, the
                    fork waits for a new message.
              additionalProperties: false
      responses:
        '201':
          description: Fork a session
          content:
            application/json:
              schema:
                type: object
                properties:
                  agent:
                    type:
                      - string
                      - 'null'
                  agentId:
                    type:
                      - string
                      - 'null'
                    format: uuid
                  artifactType:
                    type:
                      - string
                      - 'null'
                    enum:
                      - PullRequest
                      - ToolCall
                      - Plan
                      - Response
                      - File
                      - Service
                      - Source
                      - null
                  baseBranch:
                    type:
                      - string
                      - 'null'
                  branchName:
                    type:
                      - string
                      - 'null'
                  createdAt:
                    type: string
                    format: date-time
                  externalId:
                    type:
                      - string
                      - 'null'
                  externalUrl:
                    type:
                      - string
                      - 'null'
                  id:
                    type: string
                    format: uuid
                  kind:
                    type: string
                  lastQueuedAt:
                    type:
                      - string
                      - 'null'
                    format: date-time
                  lastSeenAt:
                    type: string
                    format: date-time
                  level:
                    type: integer
                  mode:
                    type: string
                    enum:
                      - normal
                      - planning
                    default: normal
                  parentSessionId:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    description: The session whose agent created this session.
                  projectId:
                    type:
                      - string
                      - 'null'
                  sandboxSize:
                    type:
                      - string
                      - 'null'
                    enum:
                      - nano
                      - micro
                      - small
                      - medium
                      - large
                      - xl
                      - xxl
                      - ultra
                      - null
                  sessionType:
                    type: string
                    enum:
                      - Chat
                      - Terminal
                    default: Chat
                  targetBranch:
                    type:
                      - string
                      - 'null'
                  title:
                    type: string
                  updatedAt:
                    type: string
                    format: date-time
                  visibility:
                    type: string
                    enum:
                      - public
                      - private
                    default: public
                  artifacts:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                        type:
                          type: string
                          enum:
                            - PullRequest
                            - ToolCall
                            - Plan
                            - Response
                            - File
                            - Service
                            - Source
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                        pullRequests:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                format: uuid
                              url:
                                type: string
                                format: uri
                              title:
                                type:
                                  - string
                                  - 'null'
                              status:
                                type: string
                                enum:
                                  - open
                                  - merged
                                  - closed
                              isDraft:
                                type: boolean
                              sourceBranch:
                                type:
                                  - string
                                  - 'null'
                              createdAt:
                                type: string
                                format: date-time
                              agent:
                                type:
                                  - string
                                  - 'null'
                              diff:
                                type:
                                  - object
                                  - 'null'
                                properties:
                                  additions:
                                    type: integer
                                    minimum: 0
                                  deletions:
                                    type: integer
                                    minimum: 0
                                  data:
                                    type: string
                                    maxLength: 1000000
                              updatedAt:
                                type: string
                                format: date-time
                              baseBranch:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 500
                              headSha:
                                type:
                                  - string
                                  - 'null'
                                maxLength: 200
                              author:
                                type:
                                  - object
                                  - 'null'
                                properties:
                                  avatarUrl:
                                    type:
                                      - string
                                      - 'null'
                                    format: uri
                                  login:
                                    type:
                                      - string
                                      - 'null'
                                    maxLength: 500
                                required:
                                  - avatarUrl
                                  - login
                                additionalProperties: false
                              codeRepository:
                                type:
                                  - object
                                  - 'null'
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                  name:
                                    type: string
                                  owner:
                                    type:
                                      - string
                                      - 'null'
                                  baseBranch:
                                    type:
                                      - string
                                      - 'null'
                                  provider:
                                    type: string
                                required:
                                  - id
                                  - name
                                  - owner
                                  - baseBranch
                                  - provider
                                additionalProperties: false
                            required:
                              - id
                              - url
                              - title
                              - status
                              - isDraft
                              - sourceBranch
                              - createdAt
                              - agent
                              - diff
                              - updatedAt
                              - baseBranch
                              - headSha
                              - author
                              - codeRepository
                            additionalProperties: false
                      required:
                        - id
                        - type
                        - createdAt
                        - updatedAt
                        - pullRequests
                      additionalProperties: false
                  automaticSizing:
                    type: boolean
                    description: Whether the session VM is sized automatically.
                  description:
                    type:
                      - string
                      - 'null'
                  diffSummary:
                    type:
                      - object
                      - 'null'
                    properties:
                      additions:
                        type: integer
                      deletions:
                        type: integer
                    required:
                      - additions
                      - deletions
                    additionalProperties: false
                  folderId:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    description: >-
                      Sidebar folder the authenticated user filed this session
                      in.
                  htmlUrl:
                    type: string
                    format: uri
                  isPinned:
                    type: boolean
                  project:
                    type:
                      - object
                      - 'null'
                    properties:
                      id:
                        type: string
                        format: uuid
                      name:
                        type: string
                      icon:
                        type: string
                        enum:
                          - folder
                          - code
                          - terminal
                          - book
                          - brain
                          - bug
                          - building
                          - cloud
                          - globe
                          - idea
                          - tools
                          - magic
                          - processor
                          - sandbox
                          - server
                          - tasks
                          - tactics
                          - images
                          - database
                          - api
                          - mobile
                          - package
                      color:
                        type: string
                        enum:
                          - neutral
                          - red
                          - orange
                          - yellow
                          - green
                          - teal
                          - blue
                          - purple
                          - pink
                    required:
                      - id
                      - name
                      - icon
                      - color
                    additionalProperties: false
                  sessionSource:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      name:
                        type: string
                      type:
                        type: string
                      repositories:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                            name:
                              type: string
                            provider:
                              type: string
                          required:
                            - id
                            - name
                            - provider
                          additionalProperties: false
                    required:
                      - id
                      - name
                      - type
                      - repositories
                    additionalProperties: false
                  sourcePullRequest:
                    type:
                      - object
                      - 'null'
                    properties:
                      id:
                        type: string
                        format: uuid
                      url:
                        type: string
                        format: uri
                      title:
                        type:
                          - string
                          - 'null'
                      status:
                        type: string
                        enum:
                          - open
                          - merged
                          - closed
                      isDraft:
                        type: boolean
                    required:
                      - id
                      - url
                      - title
                      - status
                      - isDraft
                    additionalProperties: false
                  state:
                    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:
                  - agent
                  - agentId
                  - artifactType
                  - baseBranch
                  - branchName
                  - createdAt
                  - externalId
                  - externalUrl
                  - id
                  - kind
                  - lastQueuedAt
                  - lastSeenAt
                  - level
                  - mode
                  - parentSessionId
                  - projectId
                  - sandboxSize
                  - sessionType
                  - targetBranch
                  - title
                  - updatedAt
                  - visibility
                  - artifacts
                  - automaticSizing
                  - description
                  - diffSummary
                  - folderId
                  - htmlUrl
                  - isPinned
                  - project
                  - sessionSource
                  - sourcePullRequest
                  - state
                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.fork('7c9e6679-7425-40de-944b-e07fc1f90ae7', {
              queueRightAway: true,
            });
        - lang: rust
          label: Rust SDK
          source: |
            use tembo_rs::*;

            let client = Tembo::from_env()?;

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

````

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