Keep a run’s claim on its import
const url = 'https://api.sloose.com/orgs/org_9f3c/imports/imp_4d1a/runs/run_7c2e/heartbeat';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"leaving":true}'};
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/orgs/org_9f3c/imports/imp_4d1a/runs/run_7c2e/heartbeat \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "leaving": true }'The client that authorised the run renews its claim every thirty seconds, on a two-minute lease — a dry run and a run paused on an error too, since neither writes. A run that is writing renews it too: a write, or a report of the rows it settled, renews the lease once that is 20 seconds old, so a window whose timers run slowly (a tab in the background gets a repeating timer once a minute) keeps a run that is writing; a lapsed lease is still lost, never revived. A lease that ran out is lost, not revived: the import may have been released and changed since, and the answer is 409 LEASE_LOST. Only the session or token that authorised the run may renew it.
A run stopped at its row limit (over_limit) is renewed too, while it finishes the rows it had already counted (#1857): its stop released the import, so it is renewed while nobody else holds it, and its status stays over_limit — the renewal keeps the rows it counted writable, never the run going. Its done ends the lease.
With leaving: true the client says it is going — its page closed with the run going — and the claim is cut to five seconds instead: time for what it sent as it went (its last counts and settled rows) to land, after which the server ends the run abandoned, counted from its records, as it would have two minutes later. From then on the claim only shortens: an ordinary heartbeat landing after it keeps the cut.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The organisation id the session was issued for. A token for one organisation can never read another.
Example
org_9f3cThe organisation id the session was issued for. A token for one organisation can never read another.
The import id.
Example
imp_4d1aThe import id.
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
The client is going (#1649): cut the claim to a few seconds rather than renew it. Anything but true is an ordinary renewal.
Examplegenerated
{ "leaving": true}Responses
Section titled “Responses”Renewed.
object
When the claim lapses now.
Examplegenerated
{ "leaseExpiresAt": "example"}No bearer, or one that no longer resolves: a session that is unknown or expired (code: AUTH_REQUIRED), or an API token that was revoked or expired (TOKEN_REVOKED, TOKEN_EXPIRED), whose organisation is gone (ORG_NOT_FOUND) or whose member or user row is (MEMBERSHIP_GONE).
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"}Not the session or token that authorised this run (code: NOT_YOUR_RUN), or the role is too low. Like every route behind a session: a session signed in but in no organisation is refused code: NO_ORG, a banned person code: BANNED, and a closed organisation code: ORG_CLOSED.
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 import or run, or it is not visible to this session.
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"}The lease ran out and the import was released (code: LEASE_LOST).
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"}The restore switch is on (code: MAINTENANCE): every route but /health and /robots.txt is refused before anything is read, except the operator’s own POST /staff/people/{id}/delete with the ADMIN_TOKEN. Sloose is down for maintenance. Please try again in a few minutes.
object
Example
{ "code": "MAINTENANCE"}Headers
Section titled “Headers”Seconds until asking again is worth it (300 while the switch is on).