HeskAPI documentation
REST API for HESK 3.7 and 3.8, PHP 8.1+
Quick start
Upload the drop-in zip
Copy the admin/ and api/ folders and heskapi_license.php from the zip into your HESK root directory (same folder as hesk_settings.inc.php). The copy adds files and changes no HESK file. Keep README.txt and USAGE.md out of the HESK folder: USAGE.md contains your license key.
Your license is already in place
Your download includes heskapi_license.php, filled in and locked to your domain. Keep it in the HESK root with the other files and leave it unedited: the API checks it against your domain on every request. If your download has no license file, download it again from your activation email, or paste the key we sent into a heskapi_license.php file in the HESK root.
Open the API Manager and enable the API
Log into HESK and open admin/api_manager.php (for example https://yourhesk.com/admin/api_manager.php). Copy the API key shown on the first visit, since it is shown only once. Check that the API status is Enabled (the default). To add an API Manager link to the HESK admin menu, paste the snippet from README.txt into inc/show_admin_nav.inc.php, and paste it again after each HESK upgrade.
Make your first API call
Send a request to /api/v1/?action=list_tickets with your API key. You should receive a JSON response with your HESK tickets.
Authentication
Every request needs the API key, except the emailed confirmation link (verify_ticket). HeskAPI generates the key on the API Manager page inside HESK, at admin/api_manager.php.
Pass the key via HTTP header (recommended):
X-HESK-API-Key: your_api_key_here
Or via query parameter:
GET /api/v1/?action=list_tickets&key=your_api_key_here
Reissue the key from the API Manager page at any time. The old key stops working as soon as the new one is issued.
Rate limiting
HeskAPI limits requests per caller IP address: the CF-Connecting-IP header when the request has one (Cloudflare sets it), otherwise the connecting IP. Only requests with a valid key count. Set the number of requests and the window in seconds on the API Manager page; the default is 60 requests per 60 seconds.
Over the limit, the API returns HTTP 429 with a JSON error body and a Retry-After header giving the seconds until the window resets.
Endpoints
/api/v1/?action=list_tickets
Returns HESK tickets, newest first, 25 per page.
| Parameter | Type | Description |
|---|---|---|
page | int | Page number (default: 1) |
status | int | HESK status ID: 0=New, 1=Waiting reply, 2=Replied, 3=Resolved, 4=In progress, 5=On hold, or a custom status ID |
date_from | string | Created on or after this date (YYYY-MM-DD) |
date_to | string | Created on or before this date (YYYY-MM-DD) |
The response's data holds tickets, total, page, per_page and total_pages. Each ticket has id, trackid, name, email, subject, status_id, status (its name), priority, category, created_at and updated_at. Text is returned as HESK stores it (HTML-escaped).
/api/v1/?action=search_tickets
Returns tickets whose subject, message, track ID or email contains the query, newest first, 25 per page. The response has the same shape as list_tickets, plus query.
| Parameter | Type | Description |
|---|---|---|
q | string | Search text (required) |
page | int | Page number (default: 1) |
/api/v1/?action=create_ticket
Creates a new HESK ticket. Send the fields form-encoded (application/x-www-form-urlencoded), or as multipart/form-data to attach files; the API reads no JSON request bodies. When Notify customer when a ticket is created via API is on, the customer gets HESK's new-ticket email; HESK's staff alerts are not sent for API tickets. Text is stored the way HESK's own form stores it (HTML-escaped). When email verification is enabled (see below), the ticket is held and this endpoint returns HTTP 202 instead of creating it immediately.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Customer name |
email | string | Yes | Customer email |
subject | string | Yes | Ticket subject |
message | string | Yes | Ticket message body |
category | int | Yes | HESK category ID |
priority | int | No | 0=Critical, 1=High, 2=Medium, 3=Low (default: 3) |
client_ip | string | No | Real end-user IP of the submitter (e.g. from a contact form behind Cloudflare). When passed, it is stored on the ticket and checked against HESK's banned-IP list instead of the calling server's IP. Falls back to the caller IP if omitted. |
customN | string | No | Value for an active custom field in this category (custom1, custom2, ...). Always optional. Dates use YYYY-MM-DD; send a checkbox field as customN[] once per item. A value that does not fit the field type is skipped and listed in custom_fields_skipped. |
attachment | file | No | Any file field in a multipart request (for example attachment or attachment[]). Used when attachments are on in HESK, within HESK's allowed types, maximum size and maximum number of files; other files are dropped, and data.attachments lists the files accepted. Files sent with a submission held for email verification are discarded. |
admin/api_manager.php, create_ticket holds the ticket:
it stores the submission, emails the sender a single-use confirmation link, and returns:
HTTP 202 Accepted
{"success":true,"message":"Please check your email to confirm your request. ...","data":{"status":"pending_verification","method":"link","email":"[email protected]"}}
The ticket is created when the sender opens the link and presses Confirm (see verify_ticket). Links expire
after the link expiry set on the API Manager page (1 to 168 hours, default 72), confirmation emails are rate-limited per address
(excess returns HTTP 429), and files sent with a held submission are discarded. Modes: Off, All tickets, or Unknown emails only
(addresses already known to the desk skip verification).
create_ticket then returns a
confirmation_id and emails a numeric code, which you submit to confirm_ticket
to create the ticket. Use it when your integration keeps the user on your own form:
HTTP 202 Accepted
{"success":true,"message":"Please check your email for a 6-digit confirmation code, ...","data":{"status":"pending_verification","method":"code","confirmation_id":"a1b2...","email":"[email protected]","expires_in_hours":72}}/api/v1/?action=update_ticket
Updates fields on an existing ticket (subject, message, priority, or category).
| Field | Type | Required | Description |
|---|---|---|---|
trackid | string | Yes | Ticket track ID (e.g. ABC-123-DEFG) |
subject | string | No | New subject |
message | string | No | Replaces the ticket's original message |
priority | int | No | New priority (0-3) |
category | int | No | New category ID (ignored if no category has that ID) |
/api/v1/?action=close_ticket
Marks a ticket as resolved.
| Field | Type | Required | Description |
|---|---|---|---|
trackid | string | Yes | Ticket track ID |
/api/v1/?action=verify_ticket&token=...
The browser-facing confirmation link emailed to a submitter when email verification is enabled. No API key: the single-use token is the credential. Opening the link shows a page with a Confirm button, plus the desk's own CAPTCHA when CAPTCHA on confirmation page is on and HESK's Anti-SPAM CAPTCHA is set up. Pressing the button POSTs the token back, creates the held ticket, and shows a confirmation page (or redirects to the admin-configured success URL). Opening the link alone changes nothing, so mail scanners that open every link in a message cannot confirm a submission. Expired or already-used links show a message. You never call this directly; it is the link embedded in the confirmation email.
| Field | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Single-use confirmation token from the email. It expires after the link expiry set on the API Manager page (default 72 hours). |
/api/v1/?action=confirm_ticket
Confirms a submission created under the 6-digit code verification method and creates the held ticket. API key required. Submit the confirmation_id returned by create_ticket together with the code the sender received by email. On success it returns HTTP 201 with data holding trackid, id and status (confirmed). A wrong code returns 400 with data.attempts_remaining. The code is single-use, and after 5 wrong tries the submission is discarded.
| Field | Type | Required | Description |
|---|---|---|---|
confirmation_id | string | Yes | The handle returned by create_ticket in code mode |
code | string | Yes | The 6-digit code from the confirmation email |
Error codes
Every response is JSON with a success flag. Errors and write actions include a readable message, and successful calls return their results in data:
{"success":true,"message":"Ticket created successfully.","data":{"trackid":"ABC-123-DEFG","id":42,"attachments":[]}}
{"success":false,"message":"Ticket 'ABC-123-DEFG' not found."}
Check the HTTP status to tell errors apart; the message text is for people and can change.
| HTTP Status | When |
|---|---|
| 200 / 201 | Success. create_ticket and confirm_ticket return 201 when a ticket is created. |
| 202 | create_ticket is holding the ticket for email verification (data.status is pending_verification). |
| 400 | A required field is missing or invalid (for example an invalid email, an unknown category or action, or a wrong confirmation code). |
| 401 | The API key is missing or wrong. |
| 403 | The IP address or email address is banned in HESK, the email domain is off HESK 3.8's allowed list, a held submission was refused at confirmation, or the license file does not match this domain. |
| 404 | The track ID does not exist, or a confirmation is invalid, expired or already used. |
| 405 | The endpoint needs a different HTTP method (for example create_ticket requires POST). |
| 409 | Two confirm_ticket requests for the same submission arrived together, and the other one created the ticket. |
| 429 | Rate limit exceeded (see the Retry-After header), too many confirmation emails for one address, or too many wrong codes. |
| 500 | An unexpected server error. The cause is written to the server's PHP error log. |
| 502 | The confirmation email or code could not be sent. |
| 503 | The API is disabled, HeskAPI is not set up yet (open admin/api_manager.php once), or the database is unreachable. |
Code examples
PHP: list tickets
$ch = curl_init('https://yoursite.com/hesk/api/v1/?action=list_tickets');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-HESK-API-Key: your_api_key_here'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
PHP: create a ticket
$ch = curl_init('https://yoursite.com/hesk/api/v1/?action=create_ticket');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'name' => 'Jane Smith',
'email' => '[email protected]',
'subject' => 'Login issue',
'message' => 'I cannot log in since yesterday.',
'category' => 1, // required: target HESK category ID
'client_ip' => $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['REMOTE_ADDR'], // real end-user IP
],
CURLOPT_HTTPHEADER => ['X-HESK-API-Key: your_api_key_here'],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Node.js (server side): list tickets
Call the API from your server and keep the key out of browser code: the key grants full ticket access, and the API sends no CORS headers.
const res = await fetch('https://yoursite.com/hesk/api/v1/?action=list_tickets', {
headers: { 'X-HESK-API-Key': 'your_api_key_here' },
});
const data = await res.json();
Discord and Slack webhooks
The webhooks are separate drop-in scripts that post new ticket alerts to your Discord or Slack workspace. They run from cron and read your HESK database directly, without the API.
View Webhook Docs