> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowpayroll.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Queue an asynchronous CSV or JSONL export (row cap 5,000,000)



## OpenAPI

````yaml /api-reference/specs/report.json post /exports
openapi: 3.0.1
info:
  title: Report Service
  description: >-
    Customisable reporting for FlowPayroll. Callers describe a report as a
    report-definition document, then run it, export it as a file or schedule it.
  contact:
    name: FlowPayroll
    email: support@flowpayroll.com
  version: v1
servers:
  - url: https://api.sandbox.flowpayroll.ai/v1/report
security: []
tags:
  - name: Datasets
    description: >-
      Discover what you can query: list the available datasets and inspect each
      field catalog — types, filterability, groupability, and supported
      aggregations.
  - name: Run reports
    description: >-
      Run a report synchronously — either an inline report definition or a saved
      one — and get columns and rows back in the response.
  - name: Report definitions
    description: >-
      Save a report definition under a name so it can be re-run, exported, and
      scheduled. Create, list, retrieve, replace, and delete definitions.
  - name: Exports
    description: >-
      Queue large result sets as asynchronous exports (CSV or JSONL, up to
      5,000,000 rows) and poll for a presigned download URL.
  - name: Schedules
    description: >-
      Run a saved definition on a cron schedule and deliver the export by
      webhook or email.
  - name: Run history
    description: Audit trail of every report run — synchronous, export, and scheduled.
paths:
  /exports:
    post:
      tags:
        - Exports
      summary: Queue an asynchronous CSV or JSONL export (row cap 5,000,000)
      operationId: createExport
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/CreateExportRequest'
              description: Exactly one of definitionId (saved) or definition (inline).
        required: true
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExportResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: >-
            No organisation context: the token is missing, invalid, expired, or
            grants no access to an organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceError'
components:
  schemas:
    CreateExportRequest:
      type: object
      properties:
        definitionId:
          type: string
          nullable: true
        definition:
          allOf:
            - $ref: '#/components/schemas/ReportDefinition'
          description: >-
            The report-definition document: one contract drives sync runs,
            exports, saved definitions and schedules. select holds 1 to 50
            entries.
          nullable: true
        format:
          enum:
            - CSV
            - JSONL
          type: string
          default: CSV
      description: Exactly one of definitionId (saved) or definition (inline).
    ExportResponse:
      required:
        - exportId
        - requestedAt
        - status
      type: object
      properties:
        exportId:
          type: string
        status:
          enum:
            - QUEUED
            - RUNNING
            - COMPLETED
            - FAILED
          type: string
        format:
          type: string
          nullable: true
        rowCount:
          type: integer
          format: int64
          nullable: true
        downloadUrl:
          type: string
          description: >-
            Signed download link, 12-hour expiry; refetch this resource to
            re-issue
          nullable: true
        expiresAt:
          type: string
          description: When the download link stops working
          format: date-time
          nullable: true
        error:
          type: string
          nullable: true
        requestedAt:
          type: string
          format: date-time
        completedAt:
          type: string
          format: date-time
          nullable: true
    ValidationErrorResponse:
      required:
        - error
        - errors
      type: object
      properties:
        error:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorDetail'
    ServiceError:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    ReportDefinition:
      required:
        - dataset
        - select
      type: object
      properties:
        dataset:
          type: string
          description: A dataset name from GET /datasets
        select:
          maxItems: 50
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/SelectEntry'
        filters:
          allOf:
            - $ref: '#/components/schemas/FilterNode'
          description: >-
            Filter tree node: exactly one of and/or/not (branch, nesting depth
            at most 3) or field+op (leaf). value must match the field's type as
            GET /datasets/{name} lists it.
          nullable: true
        groupBy:
          type: array
          items:
            type: string
          description: >-
            Required iff any select entry aggregates; every plain select entry
            must appear here, referenced by field name or alias
          nullable: true
        orderBy:
          type: array
          items:
            $ref: '#/components/schemas/OrderBy'
          nullable: true
        limit:
          type: integer
          description: Clamped to 10,000 (sync) / 5,000,000 (export)
          format: int32
          nullable: true
      description: >-
        The report-definition document: one contract drives sync runs, exports,
        saved definitions and schedules. select holds 1 to 50 entries.
    ValidationErrorDetail:
      required:
        - message
        - path
      type: object
      properties:
        path:
          type: string
          description: JSON pointer into the offending request
        message:
          type: string
    SelectEntry:
      type: object
      properties:
        field:
          type: string
          nullable: true
        aggregate:
          enum:
            - sum
            - avg
            - min
            - max
            - count
          type: string
          nullable: true
        as:
          type: string
          description: >-
            Output column alias (required for aggregations and tag-value
            extractions)
          nullable: true
        distinct:
          type: boolean
          default: false
        tagName:
          type: string
          description: >-
            Extract this tag's value from a tags field as a text column;
            groupable via its alias
          nullable: true
        tagGroup:
          type: string
          description: >-
            Restrict tagName extraction to one tag group; omitted matches any
            group
          nullable: true
      description: >-
        One select entry: a plain field ({"field": ...}), an aggregation
        ({"aggregate": "sum", "field": ..., "as": ...}), or a tag-value
        extraction ({"field": <tags field>, "tagName": ..., "tagGroup": ...,
        "as": ...} — "as" is required, tagGroup omitted matches any group).
        count needs no field; count with a field supports "distinct": true.
    FilterNode:
      type: object
      properties:
        and:
          type: array
          items:
            $ref: '#/components/schemas/FilterNode'
          nullable: true
        or:
          type: array
          items:
            $ref: '#/components/schemas/FilterNode'
          nullable: true
        not:
          allOf:
            - $ref: '#/components/schemas/FilterNode'
          description: >-
            Filter tree node: exactly one of and/or/not (branch, nesting depth
            at most 3) or field+op (leaf). value must match the field's type as
            GET /datasets/{name} lists it.
          nullable: true
        field:
          type: string
          nullable: true
        op:
          enum:
            - eq
            - neq
            - in
            - gt
            - gte
            - lt
            - lte
            - between
            - contains
            - isNull
            - inPeriod
          type: string
          nullable: true
        value:
          description: >-
            Scalar, or array for in/between; omitted for isNull; a
            relative-period token (@currentWeek, @currentMonth, @currentTaxYear)
            for inPeriod on a date field
          nullable: true
      description: >-
        Filter tree node: exactly one of and/or/not (branch, nesting depth at
        most 3) or field+op (leaf). value must match the field's type as GET
        /datasets/{name} lists it.
    OrderBy:
      required:
        - field
      type: object
      properties:
        field:
          type: string
          description: A selected field or aggregation alias
        direction:
          enum:
            - asc
            - desc
          type: string
          default: asc

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.