# Fork Team Session (/reference-api/schema/teams/fork-team-session)

## Team storage and identity [#team-storage-and-identity]

Use the database-backed [example Team server](/reference-api/schema/teams/create-team-run#example-team-server). Keep the Team run's returned `run_id` and `session_id`; a nested member run is not interchangeable with the Team run. Stored run, checkpoint and session operations require the configured database.

JWT user isolation is opt-in; non-admin service-account PAT callers always self-scope. Scoped callers need their own matching Team session and run, while configured resource authorization also applies. Run and checkpoint lookups return **404** for inaccessible or mismatched records. For factories, retain any `factory_input` needed by endpoints that reconstruct the Team.

Fork an existing nonempty Team session. The response contains `session_id` for the fork and `forked_from_session_id` for the original. Copied runs receive fresh IDs; list runs under the new session before selecting one. The original session is retained. An empty or unavailable source session cannot be forked (**400**), including a session outside the effective user scope.

## `POST /teams/{team_id}/sessions/{session_id}/fork`

**Summary:** Fork Team Session

**Description:** Deep-copy a team session into a new independent session. Every run is copied with a fresh ``run_id``; the new session has a fresh ``session_id``. The original is untouched. Use to explore alternative conversation paths without mutating the source.

Distinct from ``/continue?fork=true``: that creates a sibling **run** inside the **same** session. This creates a sibling **session**.

### Authentication

- Option 1: `HTTPBearer` — HTTP bearer

### Parameters
- `session_id` (path; string; required)
- `team_id` (path; string; required)
- `user_id` (query; string | null; optional)

### Request body

None.

### Responses

#### `200`

Session forked successfully

**`application/json`**

Type `unspecified`.

#### Other responses

- `400` — Source session is empty or missing `application/json`: Schema `BadRequestResponse` (object).
- `401` — Unauthorized `application/json`: Schema `UnauthenticatedResponse` (object).
- `404` — Team not found `application/json`: Schema `NotFoundResponse` (object).
- `422` — Validation Error `application/json`: Schema `ValidationErrorResponse` (object).
- `500` — Internal Server Error `application/json`: Schema `InternalServerErrorResponse` (object).