Working with Tickets

Create, search, get, and update OTOBO tickets with the Python SDK.

Working with tickets — OTOBO

All ticket operations are async. Use async with OTOBOClient(...) or call await client.aclose() when finished.

Authentication

Every API call requires a prior login():

from otobo import BasicAuth

client.login(BasicAuth(user_login="agent1", password="secret"))

Get a ticket

ticket = await client.get_ticket(12345)
print(ticket.title, ticket.queue)

Update a ticket

from otobo import IdName, TicketUpdate

updated = await client.update_ticket(
    TicketUpdate(
        id=12345,
        state=IdName(name="closed successful"),
    )
)

Search tickets

from otobo import IdName, TicketSearch

ids = await client.search_tickets(
    TicketSearch(
        queues=[IdName(name="Raw")],
        limit=50,
    )
)

Search and fetch full tickets

search_and_get runs search, then loads each ticket concurrently:

tickets = await client.search_and_get(
    TicketSearch(queues=[IdName(name="Raw")])
)
for t in tickets:
    print(t.id, t.title)

Error handling

GenericInterface business errors raise OTOBOError with code and message. HTTP transport problems raise httpx exceptions.

from otobo import OTOBOError

try:
    await client.get_ticket(999999)
except OTOBOError as e:
    print(e.code, e.message)

Dynamic fields

Pass dynamic fields as dict[str, str] on ticket models. The client maps them to GenericInterface DynamicField payloads automatically.

Further reading