---
title: "Apply a unified-diff patch to the active repo session workspace."
method: POST
path: "/v1/repo-sessions/{session_id}/patch"
tags: ["repos"]
---

# Apply a unified-diff patch to the active repo session workspace.

`POST /v1/repo-sessions/{session_id}/patch`

## Request

- Base URL: `https://api.kody.codes`
- URL: `https://api.kody.codes/v1/repo-sessions/{session_id}/patch`
- Auth: HTTP bearer

Apply a unified-diff patch to the active repo session workspace. This is the file-level repo session API: use `repoRebaseSession` to merge from the published default branch. There is no git-command channel; branch, checkout, and remote operations are not available in sessions (use the git lane via `packageGetGitRemote` for full git). Patch application is all-or-nothing across files in the patch set and subject to the 10 MiB per-file limit on patched results.

Org permission: `package:write`.

## Path parameters

- `session_id` string, required: Active repo session id from repoOpenSession or repoListSessions.

## Request body

- object
  - `patch` string, required: Standard unified diff to apply. Multiple file patches can be stacked in one patch string.
  - `dry_run` boolean: Preview patch application without writing files.

## Response `200`

Success.

- object
  - `dry_run` boolean, required
  - `total_changed` integer, required
  - `edits` object[], required
    - `path` string, required
    - `changed` boolean, required
    - `content` string, required
    - `diff` string, required

## Other responses

- `400`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `401`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `403`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `404`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `409`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `413`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `429`: Too many requests (edge IP/token limit) or an entitlement / plan-cap limit. Wait at least `Retry-After` seconds before retrying.
- `500`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `503`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `default`: Error envelope `{ "error": { "code", "message", "details"? } }`.

---

[API](https://skmtc.dev/kody/apis/kody-api.md) · [All operations](https://skmtc.dev/kody/apis/kody-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kody/apis/kody-api/revisions/a020ecedb82b?raw)
