• Patrick Ogbuitepu
  • APIs

Enterprise integration partners rarely want to create one record at a time. They want to push a whole batch, fifty purchase orders from a buying system, a thousand stock updates from a warehouse system, in a single call. Most APIs are not designed for this from the start, and adding bulk support later usually produces an endpoint that behaves differently from the single record API it is meant to support. Here is the plan we follow when designing one properly.

The biggest risk in a bulk endpoint is rebuilding checking and saving logic that already exists for the single record path, since the two versions will eventually drift apart, a rule fixed in one place and forgotten in the other. The safer pattern is a bulk endpoint that is simply a thin loop around the exact same checking and saving functions the single record API already uses, so a fix made to either path applies automatically to both.

When a batch of fifty records includes three with bad data, what happens. Does the whole batch fail, or do forty seven succeed while three get reported as errors. Both are reasonable choices, but the behaviour needs to be clear and written down, not simply whatever the code happens to do by accident. Integration partners build their own retry logic around your answer, and a behaviour that is undocumented or inconsistent breaks their error handling in ways that are hard for them to figure out from their side.

A response that simply says "batch processed, three errors," with no way to tell which three items failed and why, forces the partner to guess, or to resend the entire batch just to isolate the problem. Returning a result for every single item, success or failure, with a clear error message for each one that failed, matched to its place in the request, is what actually makes a bulk API usable for the person calling it.

A batch size with no upper limit invites a partner to eventually send something large enough to time out or use up server resources. A documented, enforced maximum, with a clear error when it is crossed, protects your own infrastructure and gives the partner something solid to design their own batching around, instead of discovering the limit by accident when a large batch fails for no obvious reason.

It is easy to focus a bulk endpoint's design entirely on shape and speed, and forget that every single item in the batch still needs the same permission check a single record request would get. A bulk endpoint that checks permission once for the whole batch, instead of once per item, can let a user touch records they were never meant to access on their own.


Maybeach Tech designs bulk APIs built for actual partner traffic, not just a demo. Get in touch and let us talk about your integration layer.

Related Post

Background Job Processing in PHP: Patterns for Long-Running Tasks

PHP was built to answer one web request and then stop. Most PHP applications eventually need to do s...

Defending Web Apps Against Bots Without Hurting Human Users

Stopping bots has a bad name, because the version most people have actually seen, a puzzle that fail...