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

# Generate report from data

> Using this endpoint with the query parameter **save** set to true, will result in an **201**
response, otherwise, the response will be **200**.

#### Generate PDF report for transaction:

First, fetch the transaction from [Get transaction](/api-reference/transactions/transactions_id_get).

Store the transaction in the `transaction` variable and send this payload:

    [
      {
        "key": "transaction",
        "path": "/checkout/v1/transactions/{transaction.id}",
        "data": transaction
      }
    ]

with these query parameters set:

- template_id=checkout_transaction_order
- template_data_path=/checkout/v1/transactions/{transaction.id}
- template_accept=application/pdf
- template_accept_language=en

**scopes**:
  - admin:reports
  - write:reports
  - read:reports




## OpenAPI

````yaml /mintlify-docs/openapi/spec-reports.yaml post /accounts/{aid}/reports/generation
openapi: 3.0.0
info:
  title: Reports API
  contact:
    name: API Integration Support
    email: integration@dintero.com
  description: >
    # Changelog

    All notable changes to the API.


    ## 2021-12-01


    > Updated returned report metadata to reflect the additional data stored pr.
    report


    ## 2021-09-23


    > Removed not implemented endpoint from spec \

    > Added admin:reports scope to endpoints


    ## 2021-08-31


    > Added new endpoint for fetching reports metadata

    > - [GET
    /v1/accounts/{aid}/reports/metadata](/reports-api/reports/api_reports_metadata_list_get)


    ## 2021-08-26


    > Removed not implemented endpoint from spec \

    > Added new save flag for persisting reports \

    > Added new response for when the save flag is used to persist reports
  version: LATEST
  license:
    name: UNLICENSED
    url: https://dintero.com
  x-logo:
    url: https://docs.dintero.com/img/dintero-dark-padded.svg
    altText: Dintero Logo
servers:
  - url: https://api.dintero.com/v1
security:
  - JWT: []
paths:
  /accounts/{aid}/reports/generation:
    post:
      tags:
        - reports
      summary: api_reports_generation_post
      description: >
        Using this endpoint with the query parameter **save** set to true, will
        result in an **201**

        response, otherwise, the response will be **200**.


        #### Generate PDF report for transaction:


        First, fetch the transaction from [Get
        transaction](/api-reference/transactions/transactions_id_get).


        Store the transaction in the `transaction` variable and send this
        payload:

            [
              {
                "key": "transaction",
                "path": "/checkout/v1/transactions/{transaction.id}",
                "data": transaction
              }
            ]

        with these query parameters set:


        - template_id=checkout_transaction_order

        - template_data_path=/checkout/v1/transactions/{transaction.id}

        - template_accept=application/pdf

        - template_accept_language=en


        **scopes**:
          - admin:reports
          - write:reports
          - read:reports
      operationId: api_reports_generation_post
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: template_id
          in: query
          required: true
          description: |
            The template to generate report from

            example:
              - checkout_transaction_order
          schema:
            type: string
        - name: template_data_path
          in: query
          required: true
          description: |
            Path to the data for the report

            examples:
              - /checkout/v1/transactions/{transaction.id}
          schema:
            type: string
        - name: template_accept
          in: query
          required: true
          description: |
            The Content-Type for the report

            examples:
              - application/pdf
          schema:
            type: string
        - name: template_accept_language
          in: query
          required: true
          description: |
            The Content-Language for the report

            examples:
              - no
              - en
          schema:
            type: string
        - name: template_accept_timezone
          in: query
          required: false
          description: >
            The timezone for the report

            List of timezones:
            https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

            Defaults to Europe/Oslo


            examples:
              - Europe/Stockholm
              - Europe/London
              - Europe/Helsinki
          schema:
            type: string
            format: iana-timezone
        - name: data_from
          in: query
          description: |
            The start of the data interval
          required: false
          schema:
            type: string
            format: date-time
        - name: data_to
          in: query
          description: |
            The end of the data interval
          required: false
          schema:
            type: string
            format: date-time
        - name: schedule
          in: query
          description: Schedule for the report
          required: false
          schema:
            type: string
            enum:
              - monthly
              - weekly
              - daily
              - custom
              - none
        - name: save
          in: query
          required: false
          description: >-
            Whether to save the generated report in s3 or not, if set to true
            returns **201**
          schema:
            type: boolean
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                required:
                  - key
                  - path
                  - data
                properties:
                  key:
                    type: string
                  path:
                    type: string
                  data:
                    type: object
        required: true
      responses:
        '200':
          $ref: '#/components/responses/ReportFile'
        '201':
          $ref: '#/components/responses/SignedUrl'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    accountId:
      name: aid
      description: |
        An id that uniquely identifies the account.
      in: path
      required: true
      schema:
        type: string
        format: ^[PT]{1}\d{8}$
        minLength: 9
        maxLength: 9
  responses:
    ReportFile:
      description: Report file
      content:
        application/json:
          schema:
            type: string
    SignedUrl:
      description: SignedUrl
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SignedUrl'
    BadRequest:
      description: Bad / Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Unexpected Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    SignedUrl:
      type: object
      properties:
        signed_url:
          type: string
          description: |
            Signed url used to download the report from s3
        id:
          type: string
          description: Id of the report
        template_id:
          type: string
          description: Id of the template used to create the report
        template_data_path:
          type: string
          description: Path to the resource, if no template is used
          example: /checkout/v1/transactions/{transaction_id}
        content_type:
          type: string
          description: Report content type
          example: application/pdf
        content_language:
          type: string
          description: Report content language
          example: en
        created_by:
          type: string
          example: 1c92f7e1-2897-4d46-bdcc-c127a914fb4e
          description: |
            The ID of the user/client that created the report
          readOnly: true
        created_at:
          type: string
          format: date-time
          description: |
            The date-time when the report was created
          readOnly: true
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            code:
              type: string
              description: The code used to identify the error/warning
            errors:
              type: array
              description: The nested error(s) encountered during validation
              items:
                type: object
            message:
              type: string
              description: The human readable description of the error/warning
  securitySchemes:
    JWT:
      type: http
      description: >
        Bearer authentication (token authentication) should be used for
        accessing the API.


        Use [Get Token](/api-reference/authenticate/aid_auths_oauth_token_post)
        to get an access token for client credentials.

        Pass the token in the request header:

            Authorization: Bearer {access_token}

        where the **access_token** is JSON Web Tokens (JWT).
      scheme: bearer
      bearerFormat: JWT

````