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

# Create report

> Creates a saved report configuration.

The source (`flowId` or `dataTypeId`), every hub and every field are checked against your organization; an unknown one returns `400`.

Requires permission `add/report`.



## OpenAPI

````yaml /openapi/public/openapi-analytics.json post /report
openapi: 3.0.0
info:
  title: API - Analytics
  version: 3.0.0
  description: API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Dashboard
    description: >-
      Dashboard lets a user compose their own dashboard from any number of
      cards, start from a template, duplicate a dashboard, share it with roles,
      and save it back as an organization template. Each card owns its own
      widget row (a chart type plus a query spec), cloned from the widget
      catalogue (built-in widgets plus the organization's custom widgets), so
      renaming or editing a card never touches the catalogue or another
      dashboard. Dashboards are owned by their creator: roles they are shared
      with can view, duplicate and save as template, but only the owner can edit
      or delete. Every write reuses the dashboard permission family (view, add,
      edit and delete dashboard).


      The numbers behind each card come from one generic aggregation endpoint
      instead of one endpoint per chart: the client sends a batch of up to 12
      declarative query specs, the server injects the caller's organization, hub
      and soft-delete scope from the session, runs each spec read-only, and
      returns a flat columns and rows table per item. The catalog endpoints
      describe the data sources, fields and limits a client may use.
  - name: Report
    description: >-
      A report is a saved table definition over tasks of one task type or
      records of one data type: which fields to show, which hubs to include, and
      the default filters.
  - name: Insight Report
    description: >-
      Insight reports are written summaries of your operations, generated from
      your task and data records: findings, a summary and suggested actions. You
      set the context once per task type, then generate reports on demand or on
      a schedule.
paths:
  /report:
    post:
      tags:
        - Report
      summary: Create report
      description: >-
        Creates a saved report configuration.


        The source (`flowId` or `dataTypeId`), every hub and every field are
        checked against your organization; an unknown one returns `400`.


        Requires permission `add/report`.
      operationId: createReport
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportCreateRequest'
        required: true
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  data:
                    description: Created report configuration.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  code: 201
                  message: Report successfully created.
                  data:
                    _id: 66f1a2b3c4d5e6f7a8b9c0d1
                    organizationId: 64d99303be0ad015c461c932
                    name: Monthly delivery report
                    type: string
                    flowId: 64e5b1c2d3e4f5a6b7c8d9e0
                    fields:
                      - title
                      - assignee
                      - status
                      - doneTime
                    hubIds:
                      - 64d9932e2beb9037735ff022
                    defaultFilters:
                      datePreset: monthly
                      status:
                        - DONE
                      assignee: []
                    createdBy: admin@example.com
                    updatedBy: admin@example.com
                    updatedTime: '2026-10-01T03:15:20.000000Z'
                    createdTime: '2026-10-01T03:15:20.000000Z'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Bad request - invalid parameters provided.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Internal server error, please contact support@mile.app.
      deprecated: false
      security:
        - bearerAuth: []
components:
  schemas:
    ReportCreateRequest:
      type: object
      required:
        - name
        - type
        - fields
      properties:
        name:
          type: string
          maxLength: 255
          description: |-
            Name of the report. Maximum 255 characters.
            **Example:** `Monthly delivery report`
        inputType:
          type: string
          description: The input type of the component (e.g., string, number, date, etc.)
        flowId:
          type: string
          description: >-
            Flow whose tasks the report reads. Required when `type` is `task`.
            Must be a 24-character id of a flow in your organization.

            **Example:** `64e5b1c2d3e4f5a6b7c8d9e0`
        dataTypeId:
          type: string
          description: >-
            Data type whose records the report reads. Required when `type` is
            `data`. Must be a 24-character id of a data type in your
            organization.

            **Example:** `64f0a1b2c3d4e5f6a7b8c9d0`
        hubIds:
          type: array
          items:
            type: string
          description: >-
            Hubs the report covers. Required for task reports and for data types
            that are not common data; ignored (saved as empty) for common data
            types. Every id must be a distinct hub of your organization.

            **Example:** `["64d9932e2beb9037735ff022"]`
        fields:
          type: array
          items:
            type: string
          description: >-
            Columns of the report, at least one, no duplicates. Each value must
            be a component id of the chosen flow (task report) or a field id of
            the chosen data type (data report).

            **Example:** `["title", "assignee", "status"]`
        defaultFilters:
          type: object
          description: >-
            Starting filters when the report is run. Task reports only; ignored
            for data reports. When omitted, a task report gets `{"datePreset":
            "monthly", "status": [], "assignee": []}`.
          properties:
            datePreset:
              type: string
              enum:
                - daily
                - weekly
                - monthly
              description: |-
                Date range preset. Required when `defaultFilters` is sent.
                **Example:** `monthly`
            status:
              type: array
              items:
                type: string
                enum:
                  - UNASSIGNED
                  - ONGOING
                  - DONE
              description: >-
                Task statuses to include. Distinct values from `UNASSIGNED`,
                `ONGOING`, `DONE`.

                **Example:** `["DONE"]`
            assignee:
              type: array
              items:
                type: string
              description: |-
                Assignee emails to include. Distinct, valid emails.
                **Example:** `["driver@example.com"]`
      example:
        name: Monthly delivery report
        type: string
        flowId: 64e5b1c2d3e4f5a6b7c8d9e0
        hubIds:
          - 64d9932e2beb9037735ff022
        fields:
          - title
          - assignee
          - status
          - doneTime
        defaultFilters:
          datePreset: monthly
          status:
            - DONE
          assignee: []
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````

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