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"

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

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