# OTOBO API tickets

> Create, search, read, and patch tickets on the OTOBO API with bearer-token HTTP requests.

- HTML: https://otobo-docs.softoft.de/en/otobo-api/tickets/
- Markdown: https://otobo-docs.softoft.de/en/otobo-api/tickets.md

Ticket routes use the same fields agents already know: title, queue, state, priority, type, customer user, and the first article.

| Action | Request |
| --- | --- |
| Search and list | `GET /tickets?queue=Service%20Desk&state=new&limit=20&offset=0` |
| One ticket | `GET /tickets/42` |
| Create | `POST /tickets` |
| Partial update | `PATCH /tickets/42` |

Search parameters: `queue`, `state`, `priority`, `type`, `title`, `ticketNumber`, `customerUser`, `limit`, `offset`. `GET /tickets` is the list. `GET /tickets/{id}` is one ticket. There is no separate find or findAll path.

## Create

```json
{
  "title": "Printer offline",
  "queue": "Service Desk",
  "state": "new",
  "priority": "3 normal",
  "customerUser": "max@example.com",
  "article": {
    "subject": "Printer offline",
    "body": "Floor 2, the device shows no paper path.",
    "mimeType": "text/plain"
  }
}
```

The response includes `id` and `ticketNumber`.

## Update

`PATCH` sends only the fields that change.

```json
{
  "state": "open",
  "priority": "4 high"
}
```

A queue the token's user cannot write returns `403`.

### Python

```python

payload = {
  "title": "Printer offline",
  "queue": "Service Desk",
  "state": "new",
  "priority": "3 normal",
  "customerUser": "max@example.com",
  "article": {
    "subject": "Printer offline",
    "body": "Floor 2, the device shows no paper path.",
    "mimeType": "text/plain"
  }
}

response = requests.post(
    "https://helpdesk.example.com/otobo/otai-api.pl/v1/tickets",
    headers={"Authorization": "Bearer YOUR_TOKEN"},,
    json=payload
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

### TypeScript

```typescript
const payload = {
  "title": "Printer offline",
  "queue": "Service Desk",
  "state": "new",
  "priority": "3 normal",
  "customerUser": "max@example.com",
  "article": {
    "subject": "Printer offline",
    "body": "Floor 2, the device shows no paper path.",
    "mimeType": "text/plain"
  }
};

const response = await fetch("https://helpdesk.example.com/otobo/otai-api.pl/v1/tickets", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_TOKEN",
    Accept: "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

### Java

```java

HttpClient client = HttpClient.newHttpClient();
String payload = """
        {
          "title": "Printer offline",
          "queue": "Service Desk",
          "state": "new",
          "priority": "3 normal",
          "customerUser": "max@example.com",
          "article": {
            "subject": "Printer offline",
            "body": "Floor 2, the device shows no paper path.",
            "mimeType": "text/plain"
          }
        }
        """;
HttpRequest.BodyPublisher body = HttpRequest.BodyPublishers.ofString(payload);
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://helpdesk.example.com/otobo/otai-api.pl/v1/tickets"))
    .header("Authorization", "Bearer YOUR_TOKEN")
    .header("Accept", "application/json")
    .method("POST", body)
    .build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "title": "Printer offline",
  "queue": "Service Desk",
  "state": "new",
  "priority": "3 normal",
  "customerUser": "max@example.com",
  "article": {
    "subject": "Printer offline",
    "body": "Floor 2, the device shows no paper path.",
    "mimeType": "text/plain"
  }
}
JSON;
$ch = curl_init("https://helpdesk.example.com/otobo/otai-api.pl/v1/tickets");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json",
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $body;
```

Longer examples, one page per language:

- [Python](https://otobo-docs.softoft.de/en/otobo-api/python/)
- [TypeScript](https://otobo-docs.softoft.de/en/otobo-api/typescript/)
- [Java](https://otobo-docs.softoft.de/en/otobo-api/java/)
- [PHP](https://otobo-docs.softoft.de/en/otobo-api/php/)

Catalogue values for queue, state, and type come from the [catalogue routes](https://otobo-docs.softoft.de/en/otobo-api/catalogue/).

## Frequently asked questions

### Which HTTP method updates a ticket?

PATCH /tickets/{id} updates only the fields you send. There is no separate full-replace call.

- [OTOBO API tickets](https://otobo-docs.softoft.de/en/otobo-api/tickets/)
- [OTOBO Admin Manual](https://doc.otobo.org/manual/admin/11.0/en/content/index.html)

### How do I search tickets?

GET /tickets with query parameters such as queue, state, title, ticketNumber, limit, and offset.

Search parameters: queue, state, priority, type, title, ticketNumber, customerUser, limit, offset. GET /tickets is the list. GET /tickets/{id} is one ticket. There is no separate find or findAll path.

- [OTOBO API tickets](https://otobo-docs.softoft.de/en/otobo-api/tickets/)
- [OTOBO Admin Manual](https://doc.otobo.org/manual/admin/11.0/en/content/index.html)
