> For the complete documentation index, see [llms.txt](https://mava.gitbook.io/mava-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mava.gitbook.io/mava-docs/webhooks-and-api/api/update-ticket.md).

# Update Ticket

### Endpoint

```
PUT /api/ticket
```

### Authentication

* Requires API token authentication
* Subject to rate limiting

### Request Body

| Field        | Type   | Required | Description                         |
| ------------ | ------ | -------- | ----------------------------------- |
| `ticketId`   | string | Yes      | The unique identifier of the ticket |
| `status`     | string | No       | New ticket status                   |
| `priority`   | number | No       | New priority level                  |
| `categoryId` | string | No       | ID of the category to assign        |
| `assignedTo` | string | No       | ID of the agent to assign           |

#### Valid Values

* **`status`**: `"Open"`, `"Resolved"`, `"Pending"`, `"Waiting"`
* **`priority`**: `1`, `2`, `3`
* **`categoryId`**: Must be a valid category ID from GET /categories
* **`assignedTo`**: The `id` of an agent from GET /agents. Omit to leave assignment unchanged, or `null` to make the ticket unassigned

> **Note:** `assignedTo` takes an agent **ID** (obtained from GET /agents), not an email address. This allows agents who signed up with a wallet — and therefore have no email — to be assigned tickets. Passing an email (or any value that is not a valid agent ID) returns a validation error.

### Response

**Success (200 OK)**

```json
{
  "message": "Ticket updated"
}
```

#### Error Responses

**Ticket not found (400)**

```json
{
  "error": "Ticket not found"
}
```

**Invalid category (400)**

```json
{
  "error": "Category not found"
}
```

**Invalid status/priority (400)**

```json
{
  "error": "Invalid status or priority"
}
```

**Assignee not found (400)**

```json
{
  "error": "Assignee not found"
}
```

**Server error (500)**

```json
{
  "error": "Internal server error"
}
```

### Behavior

* Each change (status, priority, category, assignment) creates an audit log message
* Changes only apply when new values differ from existing values
* Categories must be active and associated with the client
* `assignedTo` is resolved to an agent in your organization. An ID that does not belong to your organization is rejected with `Assignee not found`
* Assigning a ticket that the AI is actively handling ends AI handling (the ticket is handed off to the agent)

### Example (cURL)

```bash
curl -X PUT https://app.mava.app/api/ticket \
    -H "x-auth-token: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"ticketId":"TICKET_ID","assignedTo":"6630a1f4c2b9e4a1d8f00b21"}'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mava.gitbook.io/mava-docs/webhooks-and-api/api/update-ticket.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
