Report progress on an authorised run
const url = 'https://api.sloose.com/entitlements/runs/run_7c2e/progress';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"rowsWritten":1,"rowsCreated":1,"rowsUpdated":1,"rowsFailed":1,"done":true,"outcome":"complete","modules":["example"],"error":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sloose.com/entitlements/runs/run_7c2e/progress \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "rowsWritten": 1, "rowsCreated": 1, "rowsUpdated": 1, "rowsFailed": 1, "done": true, "outcome": "complete", "modules": [ "example" ], "error": "example" }'Call this in batches as the import writes, and once more with done: true when it finishes. The ledger row is the meter; the D1 run row written alongside is the history.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The run id from POST /entitlements/runs/authorise.
Example
run_7c2eThe run id from POST /entitlements/runs/authorise.
Request Body
Section titled “Request Body”object
Rows written since the last report. Non-negative.
True on the final report. Closes the run and settles the meter.
How the run ended. Only meaningful with done: true.
Modules the run touched. At most 50 are kept.
Failure message, truncated to 2,000 characters.
Responses
Section titled “Responses”The period usage after this report.
object
Examplegenerated
{ "periodStart": "example", "periodEnd": "example", "rowsWritten": 1, "rowsOverage": 1, "creditsUsed": 1, "runs": 1}rowsWritten is negative or not a number.
object
Examplegenerated
{ "error": "example"}No bearer, or one that is expired, revoked or no longer resolves to a member.
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}No such run, or it has already been settled.
object
Examplegenerated
{ "error": "example"}