Skip to content
NovaroPayDocs
2026-11-22.acaciacurrent
Theme
Merchant portal(opens in a new tab)

Get reports through the API

A report is prepared in the background: you ask for it, we make its file, and you download the file when it is ready. Through the API that is four calls of your server: choose the report type, create a report run, wait for it, and download its file. This page takes you through them with curl; Reports tells you what the file holds.

  • A secret key of the account, sk_live_… or sk_test_… (API keys). A CLI key, rk_…, gets 403 api_key_permission.
  • A key reports on its own account’s payments: payments.itemized.1; and, on a market that has payouts, on its own account’s payouts: payouts.itemized.1. The steps below use payments; a payouts report is asked for the same way. A key cannot ask for the reports of settlements and of the balance: people ask for them in the merchant portal, under Reports › New report, which is on its way. Settlements and the balance summary are your whole merchant’s; the balance changes are every line for whoever sees your whole balance, and an account’s lines for an admin or operator of it.
  • A webhook endpoint that listens to reporting.report_run.succeeded and reporting.report_run.failed, so you learn when a run ends. Without one, read the run until it ends (step 3).
  1. Choose the report type. Read the type with its columns and the period its data covers now:

    The payments report type
    curl https://api.dev.novaro.ink/reporting/report_types/payments.itemized.1 \
    -H "Authorization: Bearer sk_test_in_…"
    Response · 200 OK (shortened)
    {
    "id": "payments.itemized.1",
    "object": "reporting.report_type",
    "name": "Itemized payments",
    "version": 1,
    "default_columns": ["payment_id", "parent_id", "merchant_reference", "…", "merchant_name", "account_id"],
    "columns": ["payment_id", "parent_id", "merchant_reference", "…", "account_id", "account_name"],
    "filters": ["status", "method", "traffic_type", "amount_min", "amount_max"],
    "data_available_start": 1759300000,
    "data_available_end": 1793520000,
    "updated": 1793520000,
    "livemode": false
    }

    A run’s period must fall within data_available_start, when your account’s first payment was made, and data_available_end, one minute ago. So the period of the month your first payment was made in starts at data_available_start, not at the month’s start: a run from the month’s start is refused. An account with no payment yet has no data_available_start, and nothing to report. columns are the ones your key may ask for; GET /reporting/report_types lists every type your key can ask for.

  2. Create the run. Send the type and the period, in seconds since the Unix epoch, its end not included. To report a calendar month of your market, start and end it at midnight in its time zone: October 2026 in India is 2026-10-01T00:00:00+05:30 to 2026-11-01T00:00:00+05:30, 1790793000 to 1793471400 (date -d '2026-10-01T00:00:00+05:30' +%s with GNU date, date -j -f '%Y-%m-%dT%H:%M:%S%z' 2026-10-01T00:00:00+0530 +%s on macOS). If your first payment was made after the month’s start, start at your data_available_start instead.

    A run over October
    curl https://api.dev.novaro.ink/reporting/report_runs \
    -H "Authorization: Bearer sk_test_in_…" \
    -H "Idempotency-Key: 3f2a1b00-0000-4000-8000-000000000001" \
    -H "Content-Type: application/json" \
    -d '{
    "report_type": "payments.itemized.1",
    "parameters": {
    "interval_start": 1790793000,
    "interval_end": 1793471400,
    "timezone": "Asia/Kolkata",
    "date_basis": "finalized",
    "columns": ["payment_id", "merchant_reference", "account_id", "currency", "status",
    "finalized_at", "amount_credited", "fee_amount", "net_amount", "fee_status"]
    }
    }'
    Response · 201 Created
    {
    "id": "frr_in_01K8RC…",
    "object": "reporting.report_run",
    "report_type": "payments.itemized.1",
    "status": "pending",
    "parameters": {
    "interval_start": 1790793000,
    "interval_end": 1793471400,
    "timezone": "Asia/Kolkata",
    "columns": ["payment_id", "merchant_reference", "account_id", "currency", "status", "finalized_at", "amount_credited", "fee_amount", "net_amount", "fee_status"],
    "date_basis": "finalized",
    "status": null,
    "method": null,
    "traffic_type": null,
    "amount_min": null,
    "amount_max": null
    },
    "result": null,
    "error": null,
    "livemode": false,
    "created": 1793520000,
    "succeeded_at": null,
    "data_as_of": 1793519940
    }

    Left out, timezone is Etc/UTC, date_basis is finalized and columns are the type’s default_columns. The filters status, method, traffic_type, amount_min and amount_max keep the payments of that value alone (Report runs). The file holds the data as of data_as_of, a minute before you asked.

    Send an Idempotency-Key, and the same key when you send the request again after a timeout: if the first request made a run, you get that run, with Idempotent-Replayed: true, never a second one (Idempotent requests). A refused request, such as a 409, made none: the same request sent again makes the run, 201 without Idempotent-Replayed.

  3. Wait for the run. A run is pending while its file is made, usually for seconds, longer for a long period. It then ends succeeded, with its file in result, or failed, with error saying why.

    By webhook. A run your key created sends reporting.report_run.succeeded or reporting.report_run.failed to your account’s endpoints, with the run in data.object:

    reporting.report_run.succeeded (shortened)
    {
    "id": "evt_in_01K8RD…",
    "object": "event",
    "type": "reporting.report_run.succeeded",
    "data": {
    "object": {
    "id": "frr_in_01K8RC…",
    "object": "reporting.report_run",
    "report_type": "payments.itemized.1",
    "status": "succeeded",
    "result": {
    "id": "file_in_01K8RC…",
    "object": "file",
    "purpose": "finance_report_run",
    "type": "csv",
    "filename": "payments_acme_IN_2026-10-01_2026-10-31_frr_in_01K8RC….csv",
    "size": 950,
    "created": 1793520012,
    "expires_at": 1794124812,
    "url": "/files/file_in_01K8RC…/contents"
    }
    }
    },
    "livemode": false
    }

    Check its signature, answer 200 at once, and download the file after that, not inside the request. A run your team asked for, not your key, sends no event.

    By reading the run. Without a webhook, read it until it is no longer pending, with a backoff: wait 2 seconds, then twice as long each time, at most a minute apart.

    Read the run
    curl https://api.dev.novaro.ink/reporting/report_runs/frr_in_01K8RC… \
    -H "Authorization: Bearer sk_test_in_…"

    A run not prepared within 24 hours after you asked fails, with error “The report was not prepared within a day: try again.” and its reporting.report_run.failed event; create a new one.

  4. Download the file. result.url is a path on the API’s host: put the API’s base URL before it, and call it with your key. The answer is a 302 to the file itself, a link good for 60 seconds, which -L follows:

    Download the file
    curl -L https://api.dev.novaro.ink/files/file_in_01K8RC…/contents \
    -H "Authorization: Bearer sk_test_in_…" \
    -o payments_october.csv

    Follow the link at once, and call the URL again for a new one; every download is recorded. curl sends your key to the API’s host alone, never to the link’s: don’t use --location-trusted, and in your own HTTP client don’t pass the Authorization header on to the link. The Location may be a path on the API’s host rather than a full address: resolve it against the base URL, as curl does. The file is kept for 7 days after the run succeeded, until result.expires_at.

The script below does the four steps for a payments report. It reads the type and starts the period no earlier than data_available_start; creates the run with one Idempotency-Key, and sends it again a minute after a 409, a 429, a 5xx or no answer, five times at most; reads the run with the backoff above, for an hour at most, through a 429 or a 5xx; and downloads the file under its filename, again after a 429 or a 5xx. Any other error stops it with the API’s code and message. PSP_TZ is the time zone of the file’s times, Asia/Kolkata unless you set it. It needs curl and jq, and is tested against our API’s answers: the report type and runs its test is answered with are the objects our API writes, field for field:

get-report.sh
#!/bin/sh
# Get a payments report through the API: read the report type, create a
# report run, wait for it with backoff, and download its file. Needs curl
# and jq.
#
# PSP_API=https://api.example PSP_KEY=sk_test_in_… \
# sh get-report.sh 1790793000 1793471400 [file.csv]
#
# The interval is in seconds since the Unix epoch, its end not included.
# PSP_TZ is the time zone of the file's times, Asia/Kolkata unless set.
set -eu
api=${PSP_API:?set PSP_API to the base URL of the API}
key=${PSP_KEY:?set PSP_KEY to your secret key}
tz=${PSP_TZ:-Asia/Kolkata}
start=${1:?interval_start}
end=${2:?interval_end}
out=${3:-}
run=$(mktemp)
got=$(mktemp)
trap 'rm -f "$run" "$got"' EXIT
# Print the API's error, {"error": {"code", "message"}}, of file $1 and stop;
# any other answer, as a proxy's, as it came.
fail() {
[ -s "$1" ] || { echo "no answer from the API" >&2; exit 1; }
jq -er '.error | select(type == "object") | "\(.code // .type): \(.message)"' "$1" >&2 2>/dev/null || cat "$1" >&2
exit 1
}
# GET path $1 with your key into $got; its HTTP status in $code, 000 when
# there was no answer.
get() {
: > "$got"
code=$(curl -sS -o "$got" -w '%{http_code}' "$api$1" -H "Authorization: Bearer $key") || code=000
}
# Whether status $1 is worth trying again: rate limited, or the API could
# not answer.
again() {
case $1 in 429 | 5* | 000) return 0 ;; *) return 1 ;; esac
}
# 1. Read the report type: a period starts no earlier than your first
# payment, data_available_start, so the first month starts there.
get /reporting/report_types/payments.itemized.1
[ "$code" = 200 ] || fail "$got"
first=$(jq -r '.data_available_start // empty' "$got")
if [ -z "$first" ]; then
echo "your account has no payment yet: nothing to report" >&2
exit 1
fi
if [ "$start" -lt "$first" ]; then
echo "starting at $first, your first payment" >&2
start=$first
fi
body=$(jq -n --argjson start "$start" --argjson end "$end" --arg tz "$tz" '{
report_type: "payments.itemized.1",
parameters: {
interval_start: $start,
interval_end: $end,
timezone: $tz,
date_basis: "finalized",
columns: ["payment_id", "merchant_reference", "account_id", "currency", "status", "finalized_at",
"amount_credited", "fee_amount", "net_amount", "fee_status"]
}
}')
# 2. Create the run. One Idempotency-Key for all its tries: a retry after
# a timeout gets the run the first try made, never a second one.
idem=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)
tries=0
while :; do
# Emptied first: an attempt that gets no answer leaves no older body.
: > "$run"
code=$(curl -sS -o "$run" -w '%{http_code}' "$api/reporting/report_runs" \
-H "Authorization: Bearer $key" \
-H "Idempotency-Key: $idem" \
-H "Content-Type: application/json" \
-d "$body") || code=000
[ "$code" = 201 ] && break
# 409: too many of your reports are being prepared, and no run was made;
# 429, 5xx, no answer: wait a minute, then send the same request again.
# Anything else (report_interval_invalid, parameter_invalid...): change
# the request.
if [ "$code" = 409 ] || again "$code"; then
tries=$((tries + 1))
[ "$tries" -le 5 ] || fail "$run"
sleep 60
else
fail "$run"
fi
done
id=$(jq -r .id "$run")
echo "created $id" >&2
# 3. Wait while it is pending: 2 s, then twice as long each time, at most
# a minute apart, for an hour. The reporting.report_run.succeeded webhook
# tells you too.
wait=2
waited=0
while [ "$(jq -r .status "$run")" = pending ]; do
if [ "$waited" -ge 3600 ]; then
echo "$id is still pending: read it again later" >&2
exit 1
fi
sleep "$wait"
waited=$((waited + wait))
wait=$((wait * 2 > 60 ? 60 : wait * 2))
get "/reporting/report_runs/$id"
if [ "$code" = 200 ]; then
cp "$got" "$run"
elif ! again "$code"; then
fail "$got"
fi
done
if [ "$(jq -r .status "$run")" != succeeded ]; then
echo "$id failed: $(jq -r .error "$run")" >&2
exit 1
fi
# 4. Download the file: a 302 to a link good for 60 seconds, which -L
# follows. curl sends your key to the API's host alone, never to the link.
file=${out:-$(jq -r .result.filename "$run")}
tries=0
while :; do
: > "$got"
code=$(curl -sS -L -o "$got" -w '%{http_code}' "$api$(jq -r .result.url "$run")" \
-H "Authorization: Bearer $key") || code=000
[ "$code" = 200 ] && break
# file_expired: create the run again. 429, 5xx: try again.
again "$code" && [ "$tries" -lt 5 ] || fail "$got"
tries=$((tries + 1))
sleep 60
done
cp "$got" "$file"
echo "$file" >&2
October's payments report
PSP_API=https://api.dev.novaro.ink PSP_KEY=sk_test_in_… sh get-report.sh 1790793000 1793471400

The example integration does the same in Node.js, with no packages: REPORTS.md walks through it. npm run report creates a run and reads it until it ends. With --wait webhook it stops once the run is created, and the example’s shop downloads the file: soon after reporting.report_run.succeeded, or when it next checks the runs it created, every few minutes. It leaves other keys’ runs and your team’s alone. Both follow the link without the key, read the CSV with its byte order mark and CRLF, and handle the errors below.

A refused request makes no run. The error says what to change:

Error When What to do
400 report_interval_invalid The period ends before it starts, is longer than 366 days, starts before the type’s data_available_start or ends after its data_available_end. param names the end to change. Read the type again. Start the period no earlier than data_available_start, when your account’s first payment was made: the month of your first payment starts there. End it no later than data_available_end: a month that ended less than a minute ago is not reportable yet. Split a longer period into several runs.
409 report_runs_in_progress 3 runs of your key, or 5 of your merchant’s, are still being prepared. Wait for one of them to end, by its webhook or by reading it, then send the same request again: no run was made, so it makes one. Ask for one report at a time.
400 file_expired The file is past its expires_at, 7 days after the run succeeded. Create a new run with the run’s report_type and parameters. Download a file when its run ends, and keep it.
400 parameter_invalid A parameter is wrong, such as a column the type does not have, a time zone that is not an IANA name or a date_basis of finalized with a status that is not final. param names it. Fix the parameter.
400, type idempotency_error The Idempotency-Key was used for another request in the last 24 hours. Use a new key for a new report; send a retry with exactly the first request’s body.
404 resource_missing The run or file is not your key’s account’s, or does not exist: a run your team asked for over several accounts too. Read the runs your key sees with GET /reporting/report_runs.

A run that fails has status failed and error in words: “The file is over 1.5 GB: choose a shorter period or fewer columns.” Create a new run as it says; the one that failed is not tried again.

With a test key, sk_test_…, every call above works the same way on the test environment: the report holds your test payments, every object has livemode false, and the run’s events go to your test mode endpoints (Test mode).

  • Make test payments of every status with the magic UTRs first: the type’s data_available_start is when your first test payment was made, so a test report of a month starts there, not at the month’s start.
  • Test payments are deleted 90 days after they were made: a test report holds those still kept.
  • Test keys share the test mode rate limit: read a run with the backoff above, not in a tight loop.

Switching to live is switching the key: a live key’s report holds your live payments.