Before you start
- Write-back must be authorised for the connection. See Authorise and revoke write-back.
- Use a connector key created on the connection page. See Connect a custom ERP. A connector key created before write-back was available for the connection does not reach the queue; create a new key.
- Every request needs an
Idempotency-Keyheader. See Idempotency.
Claim queued prices
POST /v1/writeback/claims returns up to 100 queued prices and holds each one for your worker under a lease.
A connection can hold four waiting claims at a time. A fifth is refused with
too_many_claims.
Each claimed price carries these fields.
A price whose lease ends without a result returns to the queue. After 10 claims without a result it is dead-lettered and is no longer handed out.
Extend a lease
When applying takes longer than the lease, extend it withPOST /v1/writeback/leases. A lease never runs past 12 hours from its claim.
extended with the new leaseExpiresAt, or lease_lost when the claim has already ended.
Report results
Report the result of each claimed price withPOST /v1/writeback/acks, up to 100 results in one request.
The response gives the state of each price after your report.
Use the TypeScript worker
drainWriteback in the TypeScript client runs this loop for you. It claims, calls your function for each price, extends leases while your function runs, reports every result in one request and repeats a report under the same idempotency key when the API is unavailable.
TypeScript
shutdown.abort() to stop after the current batch. See Client libraries.
Know when prices are ready
Elastly records awriteback.ready event when prices are queued. A worker that waits on the claim request does not need it. See Webhooks and events.
Errors
Every other code is listed in Errors.