AlmondTill/G3N API

reportRun

query · in the family Reading your records

What it does

Run a report — group and total the last step’s records (count, sums, smallest, largest, average per currency) or list chosen columns of them, newest first.

Run ONE report synchronously, as you, inside your tenant. The reports program slice: name the report exactly one way — spec (an ad hoc report), reportId (a saved report) or catalogKey + params (a catalogue report: see reportCatalog — the period presets today · yesterday · this_week · last_week · this_month · last_month · this_quarter · year_to_date or yyyy-mm-dd..Yyyy-mm-dd of at most 366 UTC days; a catalogue report your role may not run refuses AUTHZ/FORBIDDEN with its why). The ad hoc grammar: a report wraps a search plan (the SearchPlanInput grammar verbatim — the start, up to 3 hops, the limit; the plan gate and the budget rule of searchPlanRun apply unchanged: a plan that would examine more than 5000 records (measured keys only before the first read), a step over 1000 matches, or a run past 8 s refuses before partials exist — a plan too large for this lane says so and names the other one: start it as a background report) and says what to say about the last step's records — either columns (a projection: 1..24 fields of the terminal family — its declared filter roster plus the header leaves id · sysId · caption · status · createdAt · updatedAt; one row per record, newest first (updatedAt desc, id tiebreak), up to the plan's limit; a money column brings its currency column, a reference column brings its <field>.caption) OR groupBy + measures (an aggregate: 1..4 keys — enum, reference, text, flag or bucketed date fields (a date key needs a bucket: day · week · month · quarter · year) — and up to 8 measures over money or number fields (sum · min · max · avg; count is always the first measure whether named or not); a money measure joins the row's currency to the group implicitly and renders decimals by the currency's exponent, so two currencies are never summed together; at most 1000 distinct groups — past it the run refuses and asks for a coarser bucket or a condition) — never both, never neither. An optional sort names an output column (totalMinor.sum, createdAt.month, count, …). The answer: the report in words, the terminal family, the output plan (columns — name + kind; the CSV header in this order), the rows as one JSON array text (rowsJson — parse it; a row's keys are the column names), rowCount · groupCount (0 for a projection) · the records examined · the pre-read estimate · the elapsed ms, and captionsOmitted — the reference families whose .caption column was dropped because you may not list them (the id column stands; no refusal). Every refusal is VALIDATION/INVALID in the teaching voice — the legal fields named. The report named one way — exactly one of spec (an ad hoc report) or reportId (a saved Report definition, run as YOU, its spec re-validated now): both or neither refuses VALIDATION/INVALID; an inactive or doomed definition refuses CONFLICT/REF_STATE naming its state. AS you: a family you may not list refuses the whole plan before any read; the tenant rides every key. A JSON null on an optional input field reads as absent. The paged run: a ready-made report over the daily sales, stock or order rows reads in pages. One call reads at most 5000 rows and stock positions under the clock. A cut call answers partial true with a nextToken and the page's partial rows. The summed columns carry signed partials; the derived columns read null. Pass params.nextToken back for the next page. Add the pages by their first column — the sums add. Recompute the derived columns over the added rows: sell-through % = units sold ÷ (units sold + on hand at close) · days of supply = on hand at close × the period's days ÷ units sold · margin % = margin ÷ net · the average ticket = net ÷ orders. A whole answer says partial false and nextToken null. A cursor minted under other parameters, another period or a changed facility roster refuses VALIDATION/INVALID naming the field. A call cut before its first read refuses in words, never an empty page. params.facility names ONE active facility on stock on hand and shrink. Requires authentication.

Before you call

A bearer session from an API key (see Authentication and key hygiene) or a signed-in user.

Capability area: Reading your records — Looking up and listing the records of your organization.

Roles that may call it:

What happens

Read-only and bounded: it runs as you, inside your organization, over records you may already list. A report that would read too much stops before it starts and tells you what to narrow; nothing is saved.

Arguments

NameTypeRequiredNotes
specReportSpecInputnoThe whole report spec: the plan (the SearchPlanInput grammar verbatim — its defaults apply, its limit bounds a projection's rows on the synchronous lane), then exactly one of columns (1..24 — a pr
reportIdIDno
catalogKeyStringno
paramsReportParamsInputnoThe catalogue parameters: period — a preset (today · yesterday · this_week · last_week · this_month · last_month · this_quarter · year_to_date) or yyyy-mm-dd..Yyyy-mm-dd (inclusive UTC days, at most 3

Returns

ReportRows ReportRows! — A finished synchronous report run: the report in words, the terminal family, the output plan, the rows as one JSON array text (rowsJson — the planJson carrier idiom: a row's shape is the column plan's, so the receiver parses; money renders as a decimal string by the currency's exponent, a missing group key reads (none)), rowCount · groupCount (0 for a projection), the records examined (the walks plus every caption hydrated — cumulative across the pages of a paged run), the pre-read estimate, the elapsed ms, and the reference families whose .caption column was omitted because the caller may not list them. The paged run: partial reads true when the clock or the page bound cut a ready-made report's walk. The rows are then the page's partial sums. nextToken carries the cursor to pass back as params.nextToken for the next page, null when the answer is whole.

Example request

graphql
query ExampleReportRun($spec: ReportSpecInput) {
  reportRun(spec: $spec) {
    words
    terminalFamily
    rowsJson
    rowCount
    groupCount
    examined
    elapsedMs
    captionsOmitted
    partial
    nextToken
  }
}

Variables:

json
{
  "spec": {
    "plan": {
      "start": {
        "family": "<family>",
        "filter": {
          "clauses": [
            {
              "field": "<field>",
              "op": "<op>",
              "values": [
                "<values>"
              ]
            }
          ]
        }
      },
      "hops": [
        {
          "direction": "outbound",
          "field": "<field>",
          "family": "<family>",
          "filter": {
            "clauses": [
              {
                "field": "<field>",
                "op": "<op>",
                "values": [
                  "<values>"
                ]
              }
            ]
          }
        }
      ]
    },
    "columns": [
      "<columns>"
    ]
  }
}

Example response

json
{
  "data": {
    "reportRun": {
      "words": "<words>",
      "terminalFamily": "<terminal family>",
      "rowsJson": "<rows json>",
      "rowCount": 1,
      "groupCount": 1,
      "examined": 1,
      "elapsedMs": 1,
      "captionsOmitted": [
        "<captions omitted>"
      ],
      "partial": true,
      "nextToken": "<the cursor from the previous page>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer