# OTOBO API Python examples

> Python examples for the OTOBO API: create a ticket, search the FAQ, and list queues with requests.

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

Call the OTOBO API from Python with `requests`. There is no separate SDK to install or version. The examples below are the whole client: a bearer token and JSON.

Replace `YOUR_TOKEN` with a token from **Admin → API** or from an agent's personal API token. The base URL on this OTOBO system is `https://helpdesk.example.com/otobo/otai-api.pl/v1`. How tokens expire and how rights follow the user is on the [authentication page](https://otobo-docs.softoft.de/en/otobo-api/authentication/).

## Create a ticket

Fields and errors: [Tickets](https://otobo-docs.softoft.de/en/otobo-api/tickets/).

```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())
```

## Search the FAQ

Fields and errors: [FAQ](https://otobo-docs.softoft.de/en/otobo-api/faq/).

```python

response = requests.get(
    "https://helpdesk.example.com/otobo/otai-api.pl/v1/faqs?query=vpn&limit=20",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

## List queues

Fields and errors: [Queues](https://otobo-docs.softoft.de/en/otobo-api/catalogue/).

```python

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

## List agents

Fields and errors: [Agents](https://otobo-docs.softoft.de/en/otobo-api/agents/).

```python

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

## Find a customer user

Fields and errors: [Customer users](https://otobo-docs.softoft.de/en/otobo-api/customers/).

```python

response = requests.get(
    "https://helpdesk.example.com/otobo/otai-api.pl/v1/customer-users?search=max@example.com",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

## Frequently asked questions

### Do I need a Python SDK for the OTOBO API?

No. The examples send HTTP with a bearer token. There is no package to publish or upgrade.

Call the OTOBO API from Python with requests. There is no separate SDK to install or version. The examples below are the whole client: a bearer token and JSON.

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

### Where do I send the token?

In the Authorization: Bearer header. The base URL ends with /otai-api.pl/v1.

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