Report runs
A report run is one report file over a period you choose. You create it, it is prepared in the background, and you download its file when it has succeeded: wait for the webhook event reporting.report_run.succeeded, or read the run again.
A run your key creates covers your key’s account. Your key also reads the runs of its account that your team asked for in the merchant portal over that account alone; a run over several accounts, and anything our team made, is not your key’s to read: it is 404 resource_missing, as for a run that does not exist.
A test key’s run is of the test environment’s data, with livemode false. Report runs take a secret key (sk_); a CLI key (rk_) gets 403 api_key_permission.
Its life
Section titled “Its life”| Status | |
|---|---|
pending |
Created, and being prepared. |
succeeded |
Ready: result is its file. |
failed |
It could not be prepared: error says why. Create a new run. |
Only a run your key created sends reporting.report_run.succeeded or reporting.report_run.failed, to the webhook endpoints of your key’s account.
Creating one
Section titled “Creating one”report_type and parameters[interval_start] and parameters[interval_end], in seconds since the Unix epoch, are required. The period runs from its start up to, but not including, its end, at most 366 days, within the type’s data_available_start and data_available_end: read them with GET /reporting/report_types/{id}.
The other parameters are optional:
| Parameter | |
|---|---|
timezone |
An IANA time zone, such as Asia/Kolkata, for the times in the file and the dates in its name. Etc/UTC when absent. |
columns |
The file’s columns, in their order. The type’s default_columns when absent. |
date_basis |
finalized, the default, or created: see Which rows are in the period. |
status, method, traffic_type |
Only the rows with this value: status a status of the type’s rows (a payment’s created, awaiting_payer, processing, succeeded, failed or expired); method a payment method of your market (upi in India); traffic_type ftd or std. A type’s filters name those it takes; any other value is 400 parameter_invalid. |
amount_min, amount_max |
Only the payments of at least, or at most, this amount, in major units as a string, e.g. "1000.00". |
Idempotency-Key is optional: a retry with the same key answers the same run, with the header Idempotent-Replayed: true, and makes no new one (see Idempotent requests). As a payment’s, the key is your account’s, whichever of its secret keys sends it, and is kept for 24 hours: after them the same key makes a new run. It is kept with the run alone: a key you used on another endpoint is another key here. A retry sent while the first is still being created waits for it and gets the same run, with Idempotent-Replayed: true. Nothing is made when a request is refused:
| Answer | When |
|---|---|
400 parameter_missing |
report_type, parameters or one end of the interval is absent. |
400 parameter_unknown |
The body has a parameter the request does not take, such as parameters[foo]: param names it. |
400 parameter_invalid |
report_type is not one your key can ask for, or a parameter is wrong: param names it, a parameter of parameters in brackets, parameters[columns]. An Idempotency-Key that is not one is too: see Choosing a key. |
400 report_interval_invalid |
The interval ends before it starts, is longer than 366 days, or falls outside the type’s data. param names the end to change: parameters[interval_start] when it is not before the end or is before data_available_start, parameters[interval_end] when it is after data_available_end or the interval is too long. |
409 report_runs_in_progress |
Too many reports are still being prepared: 3 of your key’s, or 5 of your merchant’s. |
400 idempotency_error |
The key was used for another request in the last 24 hours. It is checked before the parameters: another request with a wrong parameter gets this, not parameter_invalid. |
Downloading the file
Section titled “Downloading the file”A succeeded run’s result is its file. Its url is a path on the API’s host, /files/{id}/contents, not a full address: put the base URL before it, https://api.dev.novaro.ink/files/{id}/contents. Call it with your key: the answer is a 302 to the file itself, a link good for 60 seconds. Follow the redirect at once, without your key, and call the URL again for a new link; with curl, -L follows it. Its Location may be a path on the API’s host rather than a full address: resolve it against the base URL, as a browser and curl do. Every download is recorded.
The file is kept for 7 days after the run succeeds, until result.expires_at; after it, the download is 400 file_expired, and you create a new run with the same parameters.
The report run object
Section titled “The report run object”| Field | |
|---|---|
id |
Unique id, frr_<market>_…. |
object |
reporting.report_run. |
report_type |
The type of the run. |
status |
pending, succeeded or failed. |
parameters |
What the run was asked for, its defaults filled in. |
result |
Its file once it has succeeded; null before. |
error |
Why it failed; null otherwise. |
data_as_of |
The moment the data is fixed at: see Data as of. |
created, succeeded_at |
In seconds since the Unix epoch; succeeded_at is null until it has succeeded. |
livemode |
true for a live key’s run, false for a test key’s. |
The file object, result:
| Field | |
|---|---|
id |
Unique id, file_<market>_…. |
object |
file. |
purpose |
finance_report_run. |
type |
csv. |
filename |
The file’s name. |
size |
In bytes. |
created, expires_at |
When it was made, and until when it can be downloaded. |
url |
/files/{id}/contents: a path on the API’s host, to call after the base URL with your key. |
The reporting.report_run.* webhook events carry the same run object.
Endpoints
GET/reporting/report_runsListReportRunsPOST/reporting/report_runsCreateReportRunGET/reporting/report_runs/{id}GetReportRun
Loading the reference…