Generate (report)
/api/v1/reports/generateRequest body
template_idstringrequiredemail-delivery | domain-health | engagement | volume-trends | securityWhich report: delivery, domain health, engagement, volume over time or security.
formatstringrequiredpdf | csv | jsonThe file type of the report.
parametersobjectOptional. Extra settings for this kind of report, as
GET /reports/templateslists them; for example{"granularity": "day"}onvolume-trends.date_rangeobjectOptional. The period the report covers. Defaults to the last month.
startstringThe first day, ISO 8601.
endstringThe last day, ISO 8601.
Request
/api/v1/reports/generatecurl -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"
}'const response = await fetch('https://app.mailyte.com/api/v1/reports/generate', {
method: 'POST',
headers: {
Authorization: 'Bearer mk_live_YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"template_id": "email-delivery",
"format": "pdf"
}),
});
const { data } = await response.json();import requests
response = requests.post(
"https://app.mailyte.com/api/v1/reports/generate",
headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
json={
"template_id": "email-delivery",
"format": "pdf"
},
)
data = response.json()["data"]<?php
$response = Http::withToken('mk_live_YOUR_API_KEY')
->post('https://app.mailyte.com/api/v1/reports/generate', [
'template_id' => 'email-delivery',
'format' => 'pdf',
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://app.mailyte.com/api/v1/reports/generate")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer mk_live_YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = {
"template_id": "email-delivery",
"format": "pdf"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Success.
dataobjectobjectstringreport_generationidstringThe report's ID, a ULID. The same ID is returned by
POST /reports/generate.template_idstringemail-delivery | domain-health | engagement | volume-trends | securityMatches the
idof a row fromGET /reports/templates. Notesecurityis accepted here but is not advertised by that endpoint.formatstringpdf | csv | jsonThe format you asked for. Reports are stored as JSON for now; PDF and CSV are not available yet.
statusstringpending | processing | completed | failedWhere the report is: poll until it is
completedorfailed.parametersobjectThe settings the report was asked for with. Always an object.
errorstringWhy the report failed. Set only when
statusisfailed.resultanyThe 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
periodis always null.requested_atstringWhen the report was asked for.
completed_atstringWhen the report finished. Set only when it succeeded; read
statusto tell a running report from a failed one.
Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist. |
403 | The 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. |
404 | No such resource in this organization. |
422 | The request was understood but the values were not acceptable. |
429 | Too 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.