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

# List reports

> List reports

export const ListAPIInfo = ({info: {query_fields, allowed_combinations, search_fields, sort_fields, default_sort}, show_filter_combinations}) => {
  return <AccordionGroup>
    {query_fields != null && query_fields.length > 0 ? <Accordion title="Query Parameters">
      {query_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
    </Accordion> : ''}

    {allowed_combinations != null && allowed_combinations.length > 0 ? <Accordion title="Filterable Fields">
      {[...new Set(allowed_combinations.flat())].map(field => <ParamField key={field} query={field} type="string" />)}
      {show_filter_combinations ? <>
        <h3 style={{
    marginTop: "0em"
  }}>Allowed filter combinations</h3>
        <ul>
          {allowed_combinations.map(comb => <li key="a">
              {comb.map((e, i) => <><code>{e}</code>{i != comb.length - 1 ? ", " : ""}</>)}
            </li>)}
        </ul>
        </> : ''}
    </Accordion> : ''}

    {search_fields != null && search_fields.length > 0 ? <Accordion title="Searchable Fields">
      Fields that can be searched on using <code>_search</code> query param
      {search_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
    </Accordion> : ''}

    {sort_fields != null && sort_fields.length > 0 ? <Accordion title="Sortable Fields">
      Fields with which the list response can be sorted using <code>_sort</code> query param
      {sort_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
      {default_sort ? <Note>
            Default sort order:<code>{Object.entries(default_sort).map(e => e[0] + " " + e[1]).join(', ')}</code>
          </Note> : ''}
    </Accordion> : ''}

      
  </AccordionGroup>;
};

export const listReportsQueryFields = {
  query_fields: [{
    name: "id",
    type: "string",
    description: "Unique identifier of the report"
  }, {
    name: "account_id",
    type: "string",
    description: "Unique identifier of the account associated with the report"
  }, {
    name: "status",
    type: "enum",
    description: "Status of the report"
  }, {
    name: "type",
    type: "enum",
    description: "Type of the report"
  }],
  allowed_combinations: [["id"], ["account_id"], ["account_id", "status"], ["account_id", "status", "type"], ["report_template_id"], ["report_template_id", "status"], ["account_id", "report_template_id", "status"]],
  search_fields: [{
    name: "id",
    type: "string",
    description: "Search by  Unique identifier of the reports"
  }, {
    name: "name",
    type: "string",
    description: "Search by name of the reports"
  }, {
    name: "file_id",
    type: "string",
    description: "Search by file id of the reports"
  }, {
    name: "account_id",
    type: "string",
    description: "Search by account id of the reports"
  }, {
    name: "report_template_id",
    type: "string",
    description: "Search by report template id of the reports"
  }],
  sort_fields: [{
    name: "id",
    type: "string",
    description: ""
  }, {
    name: "account_id",
    type: "string",
    description: ""
  }, {
    name: "report_template_id",
    type: "string",
    description: ""
  }],
  default_sort: {
    "id": "DESC"
  }
};

<ListAPIInfo info={listReportsQueryFields} show_filter_combinations />

<Tip>
  **Downloading Reports:**

  Reports can be downloaded using the `fileId` parameter of the `Report` entity using the [Files API](/api-reference/file-storage/get-a-file).
</Tip>

<Tip>
  **Sharing Reports:**

  Sharable links can be generated using the [Generate download URL API](/api-reference/file-storage/get-a-download-url-for-a-file)
  which are S3 signed URLs valid for 1 hour and do not require authentication.
</Tip>


## OpenAPI

````yaml get /reports
openapi: 3.0.3
info:
  version: '1.0'
  title: Togai Apis
  contact:
    email: engg@togai.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: APIs for Togai App
servers:
  - description: Api endpoint
    url: https://api.togai.com/
  - description: Sandbox api endpoint
    url: https://sandbox-api.togai.com/
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: Customer level calls
  - name: Accounts
    description: Account level calls
  - name: Event Schemas
    description: Event Schema level calls
  - name: Usage Meters
    description: Usage Meter level calls
  - name: Price Plans
    description: (DEPRECATED) Price Plan level calls
  - name: PricePlanV2
    description: Price Plan V2 level calls
  - name: Schedules
    description: Account Schedule level calls
  - name: Pricing Rules
    description: Pricing Rules level calls
  - name: Settings
    description: Settings
  - name: Price Experimentation
    description: Price Experimentation apis
  - name: InvoiceGroups
    description: Invoice Group level calls
  - name: Organization
    description: Organization level calls
  - name: FileStorage
    description: File Storage level calls
  - name: Aliases
    description: Alias level calls
  - name: Reports
    description: Report level calls
  - name: ReportTemplates
    description: Report Template level calls
  - name: Customer Portal
    description: Portal level calls
  - name: Alerts
    description: Alert level calls
  - name: Event Management
    description: APIs for getting events ingested in Togai
    externalDocs:
      description: docs
      url: https://togai.com/docs/billing/events
  - name: Metrics
    description: APIs for getting Togai metrics
    externalDocs:
      description: docs
      url: https://togai.com/docs/metrics
  - name: Licenses
    description: APIs for getting or updating license records in Togai
  - name: Entitlements
    description: APIs related to entitlements
  - name: Invoices
    description: Invoices API
  - name: Credits
    description: Credits API
  - name: Wallet
    description: Wallet API
  - name: InvoiceTemplates
    description: InvoiceTemplates API
  - name: InvoiceSequence
    description: InvoiceSequence API
  - name: Payments
    description: Payments API
  - name: Authentication
    description: Authentication API
externalDocs:
  description: Find out more about Togai
  url: https://docs.togai.com/docs
paths:
  /reports:
    get:
      tags:
        - Reports
      summary: List reports
      description: List reports
      operationId: listReports
      parameters:
        - $ref: '#/components/parameters/next_token'
        - $ref: '#/components/parameters/page_size'
        - $ref: '#/components/parameters/fetch_for'
      responses:
        '200':
          $ref: '#/components/responses/ReportsPaginatedResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  parameters:
    next_token:
      in: query
      name: nextToken
      required: false
      schema:
        type: string
        example: >-
          eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==
    page_size:
      in: query
      name: pageSize
      required: false
      schema:
        type: number
        example: 10
    fetch_for:
      name: fetchFor
      in: query
      required: false
      description: |
        Fetch for flag used to get the reports from:
        1. ALL: Both the organization and accounts
        2. ORGANIZATION: Only the organization
        3. ACCOUNTS: Only accounts, works with account_id filter only.
      schema:
        type: string
        enum:
          - ALL
          - ORGANIZATION
          - ACCOUNTS
        default: ORGANIZATION
  responses:
    ReportsPaginatedResponse:
      description: Response for List Report requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ReportsPaginatedResponse'
          examples:
            ReportsPaginatedResponse:
              $ref: '#/components/examples/ReportsPaginatedResponse'
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            ErrorResponse:
              summary: Error message
              value:
                message: <Reason message>
  schemas:
    ReportsPaginatedResponse:
      type: object
      description: Represents a list response for reports
      additionalProperties: false
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Report'
        nextToken:
          type: string
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: error description
          maxLength: 500
    Report:
      type: object
      description: Represents a Report
      additionalProperties: false
      required:
        - id
        - name
        - status
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
        name:
          type: string
        account_id:
          type: string
        status:
          $ref: '#/components/schemas/ReportStatus'
        fileId:
          type: string
        queryInput:
          $ref: '#/components/schemas/QueryInput'
        reportTemplateId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        preSignedUrl:
          type: string
        type:
          $ref: '#/components/schemas/ReportType'
    ReportStatus:
      type: string
      enum:
        - QUEUED
        - RUNNING
        - FAILED
        - UPLOAD_PENDING
        - COMPLETED
    QueryInput:
      type: object
      required:
        - selects
        - baseDataSource
        - limit
        - sort
      properties:
        selects:
          type: array
          items:
            $ref: '#/components/schemas/QueryColumn'
        queryFilters:
          type: array
          items:
            $ref: '#/components/schemas/QueryFilter'
        baseDataSource:
          type: string
        sort:
          type: array
          items:
            type: object
            required:
              - column
              - sortOrder
            properties:
              column:
                $ref: '#/components/schemas/QueryColumn'
              sortOrder:
                type: string
        seekValues:
          type: array
          items:
            type: string
        limit:
          type: integer
    ReportType:
      type: string
      enum:
        - TEMPLATE
        - QUERY
        - CUSTOM
    QueryColumn:
      type: object
      required:
        - columnName
      properties:
        dataSource:
          type: string
        columnName:
          type: string
        alias:
          type: string
        functions:
          type: array
          items:
            $ref: '#/components/schemas/QueryFunction'
        aggregator:
          type: string
    QueryFilter:
      type: object
      required:
        - column
        - operator
        - args
      properties:
        column:
          $ref: '#/components/schemas/QueryColumn'
        operator:
          type: string
        args:
          type: array
          items:
            type: string
    QueryFunction:
      type: object
      required:
        - name
        - args
      properties:
        name:
          type: string
        args:
          type: array
          items:
            type: string
  examples:
    ReportsPaginatedResponse:
      value:
        data:
          - id: report.23Xx0Jkc2DM.FgysO
            name: acme-2024-09-18.csv
            status: COMPLETED
            createdAt: '2024-09-18T01:30:08.216867Z'
            updatedAt: '2024-09-18T01:30:08.350259Z'
            accountId: null
            fileId: file.23Xx0JkTljo.4JN5B
            queryInput: null
            reportTemplateId: null
            preSignedUrl: null
            type: CUSTOM
          - id: report.231kfXmrPq7.YJkpy
            name: Demo Report
            status: COMPLETED
            createdAt: '2024-06-28T16:38:05.517189Z'
            updatedAt: '2024-06-28T16:38:20.533519Z'
            accountId: null
            fileId: file.231kfo14hqu.7ejfb
            queryInput:
              selects:
                - columnName: name
                  dataSource: null
                  alias: ' cus1-account'
                  functions: null
                  aggregator: null
              baseDataSource: customers
              sort:
                - column:
                    columnName: name
                    dataSource: null
                    alias: ' cus1-account'
                    functions: []
                    aggregator: null
                  sortOrder: ASC
              limit: 1000,
              queryFilters: null
              seekValues: null
            reportTemplateId: report_template.231kfPGCpoQ.SSeyY
            preSignedUrl: null
            type: TEMPLATE
        nextToken: >-
          eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````