Reconcile request receipts with credit usage
Reconcile Scraipe request records with daily credit usage using matching UTC windows, complete pagination and a tested account-export checker.
By Codex. Checked 2026-11-16.
Your saved API receipts add up to 3.15 credits, but the account’s daily usage shows 6.15. Before treating that as a billing error, check whether the account also ran crawls, watches or playground requests. The comparison needs the same account, time window and complete set of recorded operations.
This guide reconciles the account request log with the daily usage response. Its downloadable checker uses an actual capture from Scraipe’s local HTTP route tests. The capture contains 19 records across seven pages. API activity accounts for 3.15 credits and crawl activity for another three. You can reproduce the comparison offline with Node 22, then use the same input format for your own saved account responses.
Select one account and one UTC window
Choose a completed UTC day within the request log’s retention period. Scraipe documents 30 days of request history. Retrieve the evidence while it is available and record when you captured it. If work is still being logged for the selected period, repeat the export after that work has settled. Account activity contract
The usage endpoint accepts day strings and includes both endpoints of its date range. The request-list filters use timestamps, with an inclusive start and exclusive end. For 15 November, the matching queries are as follows.
| View | Start | End |
|---|---|---|
| Usage | from=2026-11-15 | to=2026-11-15 |
| Requests | from=2026-11-15T00:00:00.000Z | to=2026-11-16T00:00:00.000Z |
Use the account’s signed-in session token for these account endpoints. Keep it in a local environment variable and out of saved exports. For example, with SCRAIPE_SESSION_TOKEN set, these read-only requests save the usage response and the first request page.
bash
curl --fail-with-body -sS --get \
https://scraipe-fc66a552921e.herokuapp.com/api/account/usage \
-H "Authorization: Bearer ${SCRAIPE_SESSION_TOKEN}" \
--data-urlencode 'from=2026-11-15' \
--data-urlencode 'to=2026-11-15' \
-o usage.json
curl --fail-with-body -sS --get \
https://scraipe-fc66a552921e.herokuapp.com/api/account/requests \
-H "Authorization: Bearer ${SCRAIPE_SESSION_TOKEN}" \
--data-urlencode 'from=2026-11-15T00:00:00.000Z' \
--data-urlencode 'to=2026-11-16T00:00:00.000Z' \
--data-urlencode 'limit=200' \
-o requests-001.jsonReplace the example dates with your chosen period. Request both views with the same authenticated account. Omit host, key, source, outcome and cost filters when comparing with account-wide usage.
Collect every request page once
If the first response has a non-null nextCursor, repeat the request with that value supplied as cursor, using --data-urlencode. Preserve the date filters and save the response under a new filename. Continue until the API returns nextCursor: null. A short page alone is insufficient evidence that you reached the end.
Keep each page’s query alongside its response. The checker expects one JSON file with usage and pages at the top level. Each page contains its recorded query and response. The included export demonstrates the complete structure. Preserve these fields when preparing your own copy.
- The usage response’s
success,rangeandtotals. - Each request query’s
from,to,limitandcursor. Usecursor: nullfor the first page. - Each page response’s
success,requestsandnextCursor. - Every request record’s
id,at,sourceandcredits, including explicit zero charges.
The saved query metadata describes how you obtained the response. Preserve it accurately. The checker validates that declaration and the records it receives. It cannot establish which account supplied an export or recover records that the service never stored.
Use the original request ID to identify a record. If your client captured an idempotent replay, resolve it to the original operation before comparing client-side receipts. Replaying a stored success can return its original positive credit fields. When using the account log export, avoid adding another copy from your client log or a batch summary. Understand a request receipt
Run the account usage comparison
Download the checker, captured account export and tests into the same directory.
bash
node --test audit.test.mjs
node audit.mjs export.jsonThe tests pass. The second command reports seven pages and these results.
| Measure | Request records | Usage response | Difference |
|---|---|---|---|
| Requests | 19 | 19 | 0 |
| Compile credits | 6.00 | 6.00 | 0.00 |
| Network credits | 0.15 | 0.15 | 0.00 |
| Total credits | 6.15 | 6.15 | 0.00 |
The bySource output contains nine API records costing 3.15 credits, nine crawl records costing three credits, and one playground record costing zero. Filtering the export to API activity would leave out the crawl spending.
These values came from the repository’s local account route harness, with simulated accounts, Mongo storage and extraction transport. The harness saved the HTTP responses while its test state was stable. The example exercises the reporting contract without issuing hosted customer requests.
All credit calculations use integer millicredits internally. The script compares record count as well as compile, network and total credits. Matching the total alone could conceal a missing zero-cost request or a disagreement between charge components.
Distinguish incomplete evidence from a discrepancy
The checker has three exit codes.
| Exit | Meaning | Next action |
|---|---|---|
| 0 | The supplied complete request pages match usage | Retain the export and its capture time |
| 1 | The pages are valid but counts or credits differ | Inspect the signed differences and compare capture scope |
| 2 | The input is incomplete or inconsistent | Repair the export before interpreting its totals |
Run two controls on copies of the sample. Remove its final page first. The checker reports that more request pages remain and exits with status 2, emitting no cost report. Skipping a middle page breaks the cursor chain and also fails validation.
For a discrepancy example, leave the pages intact and change usage.totals.creditsEgress to 0.10 and usage.totals.credits to 6.10. The checker exits with status 1 and reports a +0.05-credit difference in both network and total credits. Its differences are request-record amounts minus usage amounts.
For your own discrepancy, first verify the account, UTC boundaries, omitted filters, terminal cursor and export times. Then inspect the individual request IDs at GET /api/account/requests/:id. The detailed receipt includes network attempts and the original input. Preserve the reported charges while investigating. A missing amount needs resolution before it can be treated as zero.
Explain the remaining balance separately
The daily totals.credits field describes recorded spending during the selected window. The available account balance also reflects grants, purchases, refunds and adjustments. Inspect GET /api/account/ledger when a spending comparison agrees but the balance still needs explanation. Follow that endpoint’s own cursor through the required entries.
Charge entries are grouped by UTC day and category. Their signed credit amounts reduce the balance. One line can therefore represent many requests, while a receipt containing compile and residential costs can contribute to more than one category. Compare the appropriate date and credit amounts before comparing row counts. Account ledger contract
The request log and usage view share the same underlying request records. Agreement establishes that those saved views reconcile. It does not independently verify every balance mutation or the quality of the extracted data. Keep any unresolved account movement with its ledger entry, time window and relevant request IDs for investigation.
If the task is to find which planning assumption caused an overspend, use the workload pilot comparison after reconciling the recorded charges.