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

# Patch File

> Apply a partial update to a file in an agent's workspace.

## Authentication

Requires JWT token or Platform API key.

<ParamField path="agentId" type="string" required>Agent UUID</ParamField>
<ParamField path="path" type="string" required>File path within the agent workspace (wildcard segment)</ParamField>
<ParamField body="operation" type="string" required>Patch operation: `append`, `prepend`, or `replace`</ParamField>
<ParamField body="content" type="string" required>Content to apply</ParamField>
<ParamField body="position" type="number">Byte offset for `replace` operations</ParamField>
<ParamField body="length" type="number">Length for `replace` operations</ParamField>

## Example Request

Append content to the end of a file:

```bash theme={null}
curl -X PATCH "https://api.app.shinzo.ai/v1/agent/agt_abc123/filesystem/files/workspace/logs/app.log" \
  -H "Authorization: Bearer <jwt_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "append",
    "content": "\n2025-01-20 12:30:00 INFO Task completed"
  }'
```

Replace content at a specific byte offset:

```bash theme={null}
curl -X PATCH "https://api.app.shinzo.ai/v1/agent/agt_abc123/filesystem/files/workspace/data/config.txt" \
  -H "Authorization: Bearer <jwt_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "replace",
    "content": "new_value",
    "position": 128
  }'
```

## Response

```json theme={null}
{
  "path": "/workspace/logs/app.log",
  "size": 2048,
  "updated_at": "2025-01-20T12:30:00Z"
}
```

## Response Fields

| Field        | Type   | Description                       |
| ------------ | ------ | --------------------------------- |
| `path`       | string | Absolute path of the patched file |
| `size`       | number | New file size in bytes            |
| `updated_at` | string | Update timestamp (ISO 8601)       |

## Status Codes

| Code  | Description                       |
| ----- | --------------------------------- |
| `200` | File patched successfully         |
| `400` | Invalid request body or operation |
| `401` | Invalid authentication            |
| `403` | Access denied                     |
| `404` | Agent or file not found           |
