Skip to content

Send many changes in one call, step by step

Create, update and delete up to 5,000 records in one request, in order, each with its own checks and audit, and read back exactly which items landed and why any did not.

4 steps·3 min read·Developers

Up to 5,000 creates, updates and deletes in one request, each with its own checks and audit, refused whole and never cut short.

What it is

  • POST /api/v1/execute-multiple with a list of requests, each a Create, Update or Delete on a table, run in the order sent.
  • Each item runs exactly as a single call would: its own transaction, access, checks and audit record.
  • The answer counts what succeeded and failed and gives each item's id or error by its index. continue_on_error (on unless you turn it off) carries on past a refused item.
  • More than 5,000 items, or one item Codossier Office cannot read, refuses the whole request before anything runs.
  • A delete may name a saved view or a filter instead of an id, expanded on the server, with a preview that counts first.

Good to know

  • The answer gives ids, not records: ask with Prefer: return=representation, or read them back.
  • Each item pays its full cost, so a full batch takes minutes: size batches to your patience, not to the limit.
  • For many reads at once, POST /api/v1/data/$batch takes up to 12 list reads in one call.

Before you start

  • Loading or fixing many records one call at a time is slow. POST /api/v1/execute-multiple carries up to 5,000 creates, updates and deletes in one request, in order. Each one still runs exactly as it would alone: its own checks, its own access, its own audit record and its own transaction.
  • The example adds two hearings, changes a third, and includes one hearing with no date, which Codossier Office refuses while the others land. Every request and answer is a real exchange; record ids and support ids are hidden.

1Send the changes in one request

The body has requests, a list in the order to run. Each names its message (Create, Update or Delete), its entity (the table) and, for an update or a delete, the record's id; attributes holds the fields, as in a single create or update.

settings is optional: continue_on_error (true unless you say otherwise) carries on past a refused item; set it to false to stop at the first. return_responses false answers only the counts. A create may carry its own id if you need to know it in advance; a later item may then update or delete it.

Send many changes in one call, step 1: Send the changes in one request (Carry on past a refusal; Create, Update or Delete; This one has no date)
1Carry on past a refusal2Create, Update or Delete3This one has no date

2Read the result of each item

Once the batch is well formed, the answer is 200 and the outcome of each item is inside: is_faulted says whether any failed, succeeded and failed count them, and responses gives each item by its index, with the record's id or the error. Item 1 was refused ('Date and Time' is required); the three others landed.

Each item also carries an outcome, as every operation does. The answer gives ids, not records: read them back through the data API, or send Prefer: return=representation to receive each created or updated record.

Send many changes in one call, step 2: Read the result of each item (Something was refused; Which, and why; The others landed)
1Something was refused2Which, and why3The others landed

3Too many: refused whole, never cut short

A request with more than 5,000 items is refused as a whole with batch_too_large: nothing runs, and Codossier Office never quietly takes the first 5,000. Split the work into calls of 5,000 or fewer.

Size batches to your patience, not to the limit: each item pays its full cost (checks, audit, the reactions it starts), so a full batch runs for minutes.

Send many changes in one call, step 3: Too many: refused whole, never cut short (5,001 items; Refused whole)
15,001 items2Refused whole

4A malformed item stops the whole batch before it starts

Codossier Office reads every item before running any. An item it cannot understand (here a message that is not Create, Update or Delete) refuses the whole batch with a code that names the item: requests[1].message. The first item, a well-formed create, did not run either.

So a refusal per item means the database said no to that record, and a refusal of the request means you fix the request and send it again.

A delete may also name a set instead of an id (a saved view or a filter), expanded on the server into single deletes of what you may see, with settings.preview to count them first. Table, field, user, role and team records cannot be deleted that way.
Send many changes in one call, step 4: A malformed item stops the whole batch before it starts (Not a batch message; Which item, and why)
1Not a batch message2Which item, and why

What next