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

# Update Thread

Updates thread properties including tags and agent assignment.

<ParamField path="threadId" type="string" required>
  The unique thread identifier (UUID)
</ParamField>

<ParamField body="tags" type="array">
  Array of string tags (replaces existing tags)
</ParamField>

<ParamField body="agent_id" type="string">
  New agent to assign to the thread (must be an `ai_human` type agent)
</ParamField>

### Response

Returns the updated thread object.

<ResponseField name="id" type="string" required>
  Thread identifier
</ResponseField>

<ResponseField name="agent_id" type="string" required>
  The agent name associated with this thread
</ResponseField>

<ResponseField name="user_id" type="string | null">
  User identifier if set
</ResponseField>

<ResponseField name="tags" type="array" required>
  Array of string tags
</ResponseField>

<ResponseField name="created_at" type="number" required>
  Unix timestamp in seconds
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PATCH https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000 \
    -H "Content-Type: application/json" \
    -d '{
      "tags": ["support", "escalated", "priority"]
    }'
  ```

  ```typescript JavaScript theme={null}
  const response = await fetch(
    'https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000',
    {
      method: 'PATCH',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        tags: ['support', 'escalated', 'priority']
      })
    }
  );
  const result = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "agent_id": "support_agent",
    "user_id": "user_abc123",
    "tags": ["support", "escalated", "priority"],
    "created_at": 1699900000
  }
  ```

  ```json 400 theme={null}
  {
    "error": "No valid fields to update"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "Thread not found: 550e8400-e29b-41d4-a716-446655440000"
  }
  ```
</ResponseExample>
