Skip to main content
When a price list version goes live on a connection whose write-back your system pulls, such as a Custom ERP connection, Elastly queues each changed price. Your system claims the queued prices, applies them and reports a result for each one. This page covers the three endpoints of the queue and the worker in the TypeScript client.

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-Key header. See Idempotency.
The Writeback queue card on the connection page shows the state of each queued price.

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 with POST /v1/writeback/leases. A lease never runs past 12 hours from its claim.
Each result is extended with the new leaseExpiresAt, or lease_lost when the claim has already ended.

Report results

Report the result of each claimed price with POST /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
Call shutdown.abort() to stop after the current batch. See Client libraries.

Know when prices are ready

Elastly records a writeback.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.