REST API
Learn the foundations for using the REST API, starting with authentication and some endpoint examples.
Overview
The easiest way to familiarise yourself with the API is through cURL. For most applications however, we recommend to use a wrapper library:
Authentication
The SupportPal API uses Basic Authentication via API tokens.
Use the -u flag to provide the API token. Note, the password field is ignored, so you can use
a value of your choice, in this case we're using X. Replace $token with the value of
your API token.
$ curl -i -u '$token:X' -X GET https://www.example.com/api/selfservice/type
Authentication Errors
Failed to authenticate because of bad credentials or an invalid authorization header.
Apache
HTTP Authorisation should work out of the box on Apache using the predefined .htaccess. If you're having problems, please check the following:
mod_rewriteis enabled on Apache.- AllowOverride directive is set to
Allin your Apache configuration to permit user defined.htaccessfiles. - Switch away from the
cgiApache handler toSuPHPorFPM.
Other Web Servers
Please consult the web server documentation on how to enable HTTP Authorization headers.
Endpoints
To view all supported endpoints, please browse to https://api.supportpal.com.
Changing Locale
If you use Multilingual Content the API will return the default value of content
and translations will be accessible as a relation in the results. You can force the API to replace default
content with a specific translation (if available) by appending a lang parameter to the request.
Below is an example of fetching the Open status with and without the language param (set to French).
http://www.mydomain.com/api/ticket/status/1
{
"status": "success",
"message": null,
"data": {
"id": 1,
"name": "Open",
"colour": "#35a600",
"auto_close": 1,
"order": 1,
"created_at": 1486732738,
"updated_at": 1486732738,
"translations": [
{
"status_id": 1,
"name": "Ouvrir",
"locale": "fr"
}
]
}
}
http://www.mydomain.com/api/ticket/status/1?lang=fr
{
"status": "success",
"message": null,
"data": {
"id": 1,
"name": "Ouvrir",
"colour": "#35a600",
"auto_close": 1,
"order": 1,
"created_at": 1486732738,
"updated_at": 1486732738,
"translations": [
{
"status_id": 1,
"name": "Ouvrir",
"locale": "fr"
}
]
}
}