---
title: "Set User Session Worktree"
method: PATCH
path: "/api/v1/worktrees/session/{session_id}"
tags: ["worktrees"]
---

# Set User Session Worktree

`PATCH /api/v1/worktrees/session/{session_id}`

Set the worktree for a user session.

## Path parameters

- `session_id` string, required

## Request body

- WorktreeSetRequest — Request to set a user session's worktree.
  - `worktree_id` string, required — Worktree ID to associate with session

## Response `200`

Successful Response

- WorktreeDescriptor — Serialized worktree entity returned to API clients.
  - `id` string, required — Unique worktree identifier
  - `workspace_id` string, required — Parent workspace identifier
  - `name` string, nullable — Worktree name (null for the main worktree)
  - `is_main` boolean, required — Whether this is the main/default worktree for the workspace
  - `path` string, nullable — Filesystem path for the worktree on the machine
  - `worktree_type` 'LOCAL' | 'REMOTE', nullable — Type of worktree: LOCAL (user machine) or REMOTE (sandbox)
  - `user_machine_path` SharedSchemasWorktreeUserMachinePathDescriptor — Machine path information associated with a LOCAL worktree.
    - `id` string, required
    - `machine_id` string, required
    - `local_path` string, required
  - `managed_machine_id` string, nullable — Managed machine ID if worktree_type is REMOTE
  - `last_heartbeat_at` string, date-time, nullable — Most recent liveness heartbeat received from the sandbox container (REMOTE only).
  - `last_synced_checkpoint_id` string, nullable — ID of the last checkpoint that was successfully synced to cloud storage. This may differ from current_checkpoint_id if a recent checkpoint failed to sync.
  - `checkpoint_restore_pending` boolean — Whether a checkpoint needs to be restored on next local session start
  - `current_checkpoint_id` string, nullable — Identifier of the current checkpoint for this worktree
  - `checkpoint_metadata` object, nullable — Metadata associated with the current checkpoint (e.g., commit info)
  - `created_at` string, date-time, required — Timestamp when the worktree was created
  - `updated_at` string, date-time, required — Timestamp when the worktree was last updated

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/omnara/apis/omnara-api.md) · [All operations](https://skmtc.dev/omnara/apis/omnara-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/omnara/omnara-api/revisions/624048e40cad/schema)
