Skip to content

OTOBO API PHP examples

Call the OTOBO API from PHP with cURL. There is no Composer package to publish for this API. 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.

Fields and errors: Tickets.

<?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;

Fields and errors: FAQ.

<?php
$ch = curl_init("https://helpdesk.example.com/otobo/otai-api.pl/v1/faqs?query=vpn&limit=20");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_TOKEN",
"Accept: application/json",
"Content-Type: application/json",
],
CURLOPT_RETURNTRANSFER => true,
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $body;

Fields and errors: Queues.

<?php
$ch = curl_init("https://helpdesk.example.com/otobo/otai-api.pl/v1/queues");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_TOKEN",
"Accept: application/json",
"Content-Type: application/json",
],
CURLOPT_RETURNTRANSFER => true,
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $body;

Fields and errors: Agents.

<?php
$ch = curl_init("https://helpdesk.example.com/otobo/otai-api.pl/v1/agents");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_TOKEN",
"Accept: application/json",
"Content-Type: application/json",
],
CURLOPT_RETURNTRANSFER => true,
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $body;

Fields and errors: Customer users.

<?php
$ch = curl_init("https://helpdesk.example.com/otobo/otai-api.pl/v1/customer-users?search=max@example.com");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_TOKEN",
"Accept: application/json",
"Content-Type: application/json",
],
CURLOPT_RETURNTRANSFER => true,
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $body;

Frequently asked questions

Do I need a PHP 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 PHP with cURL. There is no Composer package to publish for this API. 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.

Sources

Where do I send the token?

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

Sources

Workflows and integrations

Web services, processes, and connections that fit your landscape.