Sirportly

Toggle Menu

Run SPQL Query

This method allows you to execute an SPQL query on your database and returns the results. SPQL is used within the application to generate reports but can also be used to extract specific data if required.

URL

/api/v2/tickets/spql

Access

This method can be accessed by account tokens and user tokens where the associated user has access to the reporting UI.

Supported Parameters

  • spql - the query you wish to execute (required)

For further information about constructing SPQL queries please refer to this documentation.

Returned Data

If the query is executed successfully, you will receive a 200 OK status with the results as shown below. If the query contains an error, you will receive a 422 Unprocessable Entity result which will contain details about the error (see below).

Example JSON

A successful SPQL query

{
  "query": "SELECT COUNT, status.name FROM tickets GROUP BY status.name",
  "fields": [
    "COUNT",
    "status.name"
  ],
  "results": [
    [
      23,
      "New"
    ],
    [
      3,
      "Resolved"
    ],
    [
      2,
      "Waiting for Customer"
    ],
    [
      5,
      "Waiting for Staff"
    ]
  ]
}

A failed SPQL query

{
  "errors": [
    "Invalid column 'tickets.asd' requested in SELECT"
  ]
}