Generate (report)

POST/api/v1/reports/generate
Requires anorganization API keywith the scopereports:read

Request body

  • template_idstringrequiredemail-delivery | domain-health | engagement | volume-trends | security

    Which report: delivery, domain health, engagement, volume over time or security.

  • formatstringrequiredpdf | csv | json

    The file type of the report.

  • parametersobject

    Optional. Extra settings for this kind of report, as GET /reports/templates lists them; for example {"granularity": "day"} on volume-trends.

  • date_rangeobject

    Optional. The period the report covers. Defaults to the last month.

    • startstring

      The first day, ISO 8601.

    • endstring

      The last day, ISO 8601.

Request

POST/api/v1/reports/generate
curl -X POST 'https://app.mailyte.com/api/v1/reports/generate' \
  -H 'Authorization: Bearer mk_live_YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "template_id": "email-delivery",
    "format": "pdf"
  }'
The key names its own organization, so no X-Organization-ID header is needed.

Response

Success.

  • dataobject
    • objectstringreport_generation
    • idstring

      The report's ID, a ULID. The same ID is returned by POST /reports/generate.

    • template_idstringemail-delivery | domain-health | engagement | volume-trends | security

      Matches the id of a row from GET /reports/templates. Note security is accepted here but is not advertised by that endpoint.

    • formatstringpdf | csv | json

      The format you asked for. Reports are stored as JSON for now; PDF and CSV are not available yet.

    • statusstringpending | processing | completed | failed

      Where the report is: poll until it is completed or failed.

    • parametersobject

      The settings the report was asked for with. Always an object.

    • errorstring

      Why the report failed. Set only when status is failed.

    • resultany

      The report, in the same shape as the live endpoint. Null while it is being made, when it failed, or for a report type without a live endpoint. Its period is always null.

    • requested_atstring

      When the report was asked for.

    • completed_atstring

      When the report finished. Set only when it succeeded; read status to tell a running report from a failed one.

Returned inside the standard envelope.

Errors

StatusWhen
401The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist.
403The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys.
404No such resource in this organization.
422The request was understood but the values were not acceptable.
429Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait.

Every status, with what causes it and what to do, is on the error reference.