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

# Create a Report

> Use this endpoint to generate reports asynchronously using pre-registered templates. You can apply custom filters to define specific criteria by domain, like account IDs in onboarding.   

The request returns a unique reportId to track status and download the report when ready.



## OpenAPI

````yaml /en/openapi/v3-current/reporter.yaml post /v1/reports
openapi: 3.1.0
info:
  title: Reporter
  description: ''
  version: 1.2.0
servers:
  - url: https://reporter.sandbox.lerian.net
security: []
tags: []
paths:
  /v1/reports:
    post:
      tags:
        - Reports API
      summary: Create a Report
      description: >-
        Use this endpoint to generate reports asynchronously using
        pre-registered templates. You can apply custom filters to define
        specific criteria by domain, like account IDs in onboarding.   


        The request returns a unique reportId to track status and download the
        report when ready.
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/XOrganizationId'
        - $ref: '#/components/parameters/XIdempotency'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportRequest'
              description: Details of the request to generate the report.
            example:
              templateId: 01953d09-e6cb-7c1c-a01a-272855a9ffb7
              filters:
                midaz_onboarding:
                  account:
                    created_at:
                      between:
                        - '2025-08-02'
                        - '2025-08-03'
      responses:
        '200':
          description: >-
            Indicates that the resource was successfully created and the
            operation was completed as expected.


            The response includes the `X-Idempotency-Replayed` header.


            If the value is false, the transaction was just processed. If the
            value is true, the response is a replay of a previously processed
            request.


            See [Retries and idempotency](/en/reference/retries-idempotency) for
            more details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReportResponse'
              example:
                id: 0196c5c0-5044-724f-95f3-4b32076e7ad7
                templateId: 01953d09-e6cb-7c1c-a01a-272855a9ffb7
                filters:
                  midaz_onboarding:
                    account:
                      created_at:
                        between:
                          - '2025-08-02'
                          - '2025-08-03'
                completedAt: null
                createdAt: '2025-05-12T18:27:17.188156815Z'
                updatedAt: '2025-05-12T18:27:17.188156815Z'
                deletedAt: null
          headers:
            X-Idempotency-Replayed:
              $ref: '#/components/headers/XIdempotencyReplayed'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0004:
                  $ref: '#/components/examples/Error0004'
                Error0012:
                  $ref: '#/components/examples/Error0012'
                Error0013:
                  $ref: '#/components/examples/Error0013'
                Error0014:
                  $ref: '#/components/examples/Error0014'
                Error0015:
                  $ref: '#/components/examples/Error0015'
                Error0016:
                  $ref: '#/components/examples/Error0016'
                Error0017:
                  $ref: '#/components/examples/Error0017'
                Error0018:
                  $ref: '#/components/examples/Error0018'
                Error0019:
                  $ref: '#/components/examples/Error0019'
                Error0026:
                  $ref: '#/components/examples/Error0026'
                Error0027:
                  $ref: '#/components/examples/Error0027'
                Error0028:
                  $ref: '#/components/examples/Error0028'
                Error0030:
                  $ref: '#/components/examples/Error0030'
                Error0031:
                  $ref: '#/components/examples/Error0031'
                Error0033:
                  $ref: '#/components/examples/Error0033'
          headers: {}
      security: []
components:
  parameters:
    Authorization:
      name: Authorization
      in: header
      description: >-
        The authorization token in the 'Bearer <token>' format.  


        **Important:** This header is required if your environment has Access
        Manager enabled. For more information, refer to the [Access
        Manager](/en/access-manager) documentation.
      required: false
      schema:
        type: string
    XOrganizationId:
      name: X-Organization-id
      in: header
      description: The unique identifier of the Organization associated with the request.
      required: true
      example: 019c96a0-0a98-7287-9a31-786e0809c769
      schema:
        type: string
    XIdempotency:
      name: X-Idempotency
      in: header
      description: >-
        Optional idempotency key for safe retries. If omitted, the server may
        generate one automatically.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      required: false
      schema:
        type: string
  schemas:
    ReportRequest:
      type: object
      properties:
        templateId:
          type: string
          description: Unique identifier of the template used to generate the report.
        filters:
          type: object
          description: >-
            Object that defines the filtering criteria applied to the data used
            in the report. Now supports advanced filtering operators including
            `equality`, `comparison`, `range`, and list-based conditions.  


            **Important**: The `filters` object **must** be included in the
            request body, even if **empty**.
          additionalProperties:
            $ref: '#/components/schemas/DatabaseFilters'
      required:
        - templateId
        - filters
      description: Details of the request to generate the report.
    ReportResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the report generation request.
        templateId:
          type: string
          description: Unique identifier of the template used to generate the report.
        filters:
          type: object
          description: >-
            Object that defines the filtering criteria applied to the data used
            in the report. Now supports advanced filtering operators including
            `equality`, `comparison`, `range`, and list-based conditions.
          additionalProperties:
            $ref: '#/components/schemas/DatabaseFilters'
        status:
          type: string
          description: Current status of the report
        completedAt:
          type: string
          description: Timestamp marking when the report processing was completed.
        createdAt:
          type: string
          description: Timestamp marking when this report request was created.
        updatedAt:
          type: string
          description: Timestamp marking the last update to this report request.
        deletedAt:
          type: string
          description: >-
            Timestamp marking when this report request was soft deleted, if
            applicable.
      description: Details about the report that was created.
    Error:
      type: object
      properties:
        code:
          type: string
          description: A unique, stable identifier for the error.
        title:
          type: string
          description: A brief summary of the issue.
        message:
          type: string
          description: Detailed guidance for resolving the error.
      description: Response message error.
      required:
        - code
        - title
        - message
    DatabaseFilters:
      type: object
      description: >-
        Object where the key is the exact identifier of the data source to be
        filtered. Use the specific source ID configured in your organization —
        for example, use 'midaz_onboarding' for Onboarding data or 'plugin_crm'
        for CRM data, rather than generic labels like 'database_name'.  


        This identifier must match the name of a connected and accessible data
        source within your environment.  


        **Important**: This object is **optional**, but if provided, it **must**
        contain all necessary nested structures (`table`, `field` and
        `conditionals`) to ensure valid filtering. Partial or incomplete filter
        definitions will result in an error.
      additionalProperties:
        $ref: '#/components/schemas/TableFilters'
      example:
        midaz_onboarding:
          account:
            created_at:
              between:
                - '2025-08-02'
                - '2025-08-03'
    TableFilters:
      type: object
      description: >-
        **Mandatory** object where the key is the exact table name to be
        filtered within the selected data source. Use the precise name as
        defined in the database schema — for example, 'organization', 'account',
        'transaction', or 'fee', rather than a generic placeholder like
        'table_name'. This name must exactly match a table registered in the
        selected data source.
      additionalProperties:
        $ref: '#/components/schemas/FieldFilters'
      example:
        account:
          id:
            eq:
              - abc-123
          createdAt:
            between:
              - '2024-01-01'
              - '2024-12-31'
    FieldFilters:
      type: object
      description: >-
        **Mandatory** object whose key corresponds to the exact column name
        where the filtering conditions are applied. Use the field `name` exactly
        as defined in the table schema — e.g., 'accountId', 'status',
        'createdAt', or 'amount' — rather than a generic placeholder like
        'field_name'. This key must match the column name precisely to ensure
        proper query resolution.
      propertyNames:
        pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
      additionalProperties:
        $ref: '#/components/schemas/FilterOperators'
      example:
        id:
          eq:
            - abc-123
        createdAt:
          between:
            - '2024-01-01'
            - '2024-12-31'
    FilterOperators:
      type: object
      description: >-
        Object that specifies which logical operator(s) to apply to the selected
        field. Supports both simple and compound expressions. Each key is an
        operator name and its value is an array of operands.
      properties:
        eq:
          type: array
          description: >-
            Equal to — matches rows where the field value equals any of the
            provided values.
          items:
            oneOf:
              - type: string
              - type: number
        gt:
          type: array
          description: >-
            Greater than — matches rows where the field value is greater than
            the provided value.
          items:
            oneOf:
              - type: string
              - type: number
        gte:
          type: array
          description: >-
            Greater than or equal to — matches rows where the field value is
            greater than or equal to the provided value.
          items:
            oneOf:
              - type: string
              - type: number
        lt:
          type: array
          description: >-
            Less than — matches rows where the field value is less than the
            provided value.
          items:
            oneOf:
              - type: string
              - type: number
        lte:
          type: array
          description: >-
            Less than or equal to — matches rows where the field value is less
            than or equal to the provided value.
          items:
            oneOf:
              - type: string
              - type: number
        between:
          type: array
          description: >-
            Range filter — matches rows where the field value falls between two
            boundary values (inclusive). Expects exactly two items.
          minItems: 2
          maxItems: 2
          items:
            oneOf:
              - type: string
              - type: number
        in:
          type: array
          description: >-
            List inclusion — matches rows where the field value is one of the
            provided values.
          items:
            oneOf:
              - type: string
              - type: number
        nin:
          type: array
          description: >-
            List exclusion — matches rows where the field value is not one of
            the provided values.
          items:
            oneOf:
              - type: string
              - type: number
      additionalProperties: false
  headers:
    XIdempotencyReplayed:
      description: >-
        Indicates whether the response was replayed from cache (`true`) or is a
        fresh response (`false`). Always check this header to avoid processing
        the same operation twice on your side.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      schema:
        type: boolean
      example: false
  examples:
    Error0004:
      summary: Invalid header
      value:
        code: TPL-0004
        title: Invalid header
        message: >-
          One or more header values are missing or incorrectly formatted. Please
          verify required headers %VALUE.
    Error0012:
      summary: Invalid templateId
      value:
        code: TPL-0012
        title: Invalid templateId
        message: >-
          The specified templateId is not a valid UUID. Please check the value
          passed.
    Error0013:
      summary: Invalid ledgerId
      value:
        code: TPL-0013
        title: Invalid ledgerId
        message: >-
          The specified ledgerId inside ledger Id list is not a valid UUID.
          Please check the value passed %v.
    Error0014:
      summary: Missing required fields
      value:
        code: TPL-0014
        title: Missing required fields
        message: >-
          The fields mapped on template file is missing on tables schema. Please
          check the fields passed '%v'.
    Error0015:
      summary: Unexpected Fields in the Request
      value:
        code: TPL-0015
        title: Unexpected Fields in the Request
        message: >-
          The request body contains more fields than expected. Please send only
          the allowed fields as per the documentation. The unexpected fields are
          listed in the fields object.
    Error0016:
      summary: Missing Fields in Request
      value:
        code: TPL-0016
        title: Missing Fields in Request
        message: >-
          Your request is missing one or more required fields. Please refer to
          the documentation to ensure all necessary fields are included in your
          request.
    Error0017:
      summary: Bad Request
      value:
        code: TPL-0017
        title: Bad Request
        message: >-
          The server could not understand the request due to malformed syntax.
          Please check the listed fields and try again.
    Error0018:
      summary: Internal Server Error
      value:
        code: TPL-0018
        title: Internal Server Error
        message: >-
          The server encountered an unexpected error. Please try again later or
          contact support.
    Error0019:
      summary: Invalid Query Parameter
      value:
        code: TPL-0019
        title: Invalid Query Parameter
        message: >-
          One or more query parameters are in an incorrect format. Please check
          the following parameters '%v' and ensure they meet the required format
          before trying again.
    Error0026:
      summary: Metadata Key Length Exceeded
      value:
        code: TPL-0026
        title: Metadata Key Length Exceeded
        message: >-
          The metadata value %v exceeds the maximum allowed length of %v
          characters. Please use a shorter value.
    Error0027:
      summary: Metadata Value Length Exceeded
      value:
        code: TPL-0027
        title: Metadata Value Length Exceeded
        message: >-
          The metadata value %v exceeds the maximum allowed length of %v
          characters. Please use a shorter value.
    Error0028:
      summary: Invalid Metadata Nesting
      value:
        code: TPL-0028
        title: Invalid Metadata Nesting
        message: >-
          The metadata object cannot contain nested values. Please ensure that
          the value %v is not nested and try again.
    Error0030:
      summary: Missing Schema Table
      value:
        code: TPL-0030
        title: Missing Schema Table
        message: >-
          There is a schema table missing. Please check your template file
          passed.
    Error0031:
      summary: Missing Data Source Table
      value:
        code: TPL-0031
        title: Missing Data Source Table
        message: The data source %v is missing. Please check the value passed.
    Error0033:
      summary: Encryption data error Tag Detected
      value:
        code: TPL-0033
        title: Encryption data error Tag Detected
        message: 'Error to make the encryption of CRM data. Err: key is invalid.'

````