Skip to content

GraphQL API Examples

This section provides practical examples for querying Retarus GraphQL APIs. Each example demonstrates real-world usage scenarios with complete query syntax, variable definitions, and sample responses.

Prerequisites

To run the examples below, you must have already obtained an active access token. You’ll include this token with every API call.

For how to obtain and refresh your token, see the Authentication section.

Common query structure

All Retarus GraphQL queries follow a consistent pattern:

  • Query
    GraphQL document defining the operation, the fields to fetch, and required variables.
  • Variables
    JSON object whose keys match the declared variables (e.g., customer ID, date range, filters).
  • Response
    JSON with data and optional errors.

Common parameters

These parameters are used across all service queries:

ParameterTypeDescriptionExample
customerIdString!Your Retarus customer account identifier"99999"
datePeriodDatePeriod!Time range with UTC timestamps{"fromIncluded": "2025-06-04T08:00:00.000Z"}
{"toExcluded": "2025-06-04T08:54:00.000Z"}
pageIndexIntZero-based page number for pagination0
pageSizeIntMaximum records to return per page (max 10,000)3
sortSortDirectionSort direction for results"ASC" or "DESC"
filterService-specificOptional column filters that narrow results (see Filtering){"statusName": {"values": ["OK"]}}

Enum note: In the query document, enums are unquoted (e.g., ASC). In variables JSON, pass them as strings (e.g., { "sort": "ASC" }).

Filtering

Most reports accept an optional filter argument that narrows results to matching records. The filter type is service-specific (for example, FaxOutColumnUdrFilters or SmsInColumnUdrFilters), but every filterable column uses the same ColumnFilter input:

FieldLogicDescription
valuesORInclude only records whose column matches any of the listed values.
notValuesAND NOTExclude records whose column matches any of the listed values.

You can set values, notValues, or both on a column, and filter on several columns at once. Within a single column, values are combined with OR and notValues with AND NOT; separate columns are combined with AND.

For example, the following filter value keeps only records whose statusName is OK, while excluding two billing codes:

{
  "statusName": { "values": ["OK"] },
  "jobBillingCode": { "notValues": ["ITS065", "ITS099"] }
}

Note
notValues enables AND NOT filtering. Combine it with values to include a set of values and subtract specific exceptions in a single query.

Common response fields

All service responses include these pagination fields:

FieldDescriptionExample
pageIndexCurrent page number0
pageSizeRequested page size3
hasMoreElementsWhether more pages are availabletrue

Date period format

All date periods use ISO 8601 UTC format:

  • fromIncluded
    Start time (inclusive) - "2025-06-04T08:00:00.000Z"
  • toExcluded
    End time (exclusive) - "2025-06-04T08:54:00.000Z"

Data retention limits

  • Maximum query duration: 45 days per request
  • Maximum history: within 90 days of the current UTC time

Product-specific examples