Home / Blog

Salesforce API limits for high-frequency writes: REST, Bulk, and where an agent loop stalls

Abstract artwork in Fathom's colours

Salesforce meters writes as API calls drawn from a rolling 24 hour allocation that belongs to the whole org, sized by edition and licence count rather than per integration user. A single record write, POST /services/data/vXX.X/sobjects/Contact, spends one call. The sObject Collections endpoint, PATCH /services/data/vXX.X/composite/sobjects, accepts an array of records and spends one call for the entire array. Bulk API 2.0 takes a CSV upload, splits it into batches server side, and is metered per batch rather than per record, so the per record cost of a large load rounds towards nothing. If the question is only "how do I write a lot without exhausting the allocation", the structural answer is to stop making one call per record and start making one call per set.

That answer often fails to help an agent, because the unit of an agent's work is a turn, not a set. A loop that reads a reply, decides the lead is qualified, and writes the decision produces exactly one write, and it needs the result of that write before it composes the next message. Bulk API 2.0 does not give you a result. It gives you a job id, a state machine, and a completed results file you fetch later. So for high frequency writes originating in an agent loop, the limit that bites first is usually not the daily call allocation at all. It is the cap on concurrent long running synchronous requests, the row lock contention created by parallel batches, and the latency you introduce the moment you queue a write whose outcome the agent has to reason over on its next turn.

Three write paths, three cost models

Single record REST. One call per record, synchronous, and the response body carries the created id and any field level error. This is the only path whose cost model matches an agent's turn exactly, and the only one that will exhaust an org allocation if your loop is chatty. An agent that logs every inbound email as an Interaction, every stage guess as a Task, and every score change as a field update is writing three times per turn for reasons no human ever asked for.

Collections and composite. composite/sobjects bundles a couple of hundred records into one call and returns a per record success or error array, which is the important part: you still get individual results. composite and composite/graph go further and let you chain dependent writes in one round trip, referencing the id of an earlier subrequest. This is the underused middle ground. It is synchronous, it returns per record outcomes, and it collapses the call count for anything you can assemble before you send.

Bulk API 2.0. Asynchronous, CSV in, job id out, batching decided by Salesforce. Metered per batch, which is why it is the only sane path for a backfill or a nightly reconciliation. It also has its own parallel processing behaviour, which is where lock errors appear when many records in one job roll up to the same parent Account or the same Opportunity owner.

When Bulk is the right answer

Bulk is right when the write is genuinely a set fact rather than a decision. Importing a list into Leads. Reconciling stage after a nightly model run. Backfilling last_touch_at across ten thousand Contacts because you changed how you compute it. In all of those cases nothing downstream is waiting on any individual row, and a delay of minutes is not a delay at all. You submit, you poll the job, you read the failed results file, and you retry the rows that failed.

Bulk is also right when the alternative is a loop that would burn a meaningful share of the org allocation before lunch. If your agent fleet is producing tens of thousands of low value writes a day, the correct fix is usually not a bigger allocation. It is deciding which of those writes were ever worth persisting individually, then batching the remainder.

When batching is just latency the agent cannot reason about

Here is the failure mode. You hit the call ceiling, you move writes to a queue that flushes to Bulk every thirty seconds, and the loop keeps working in staging because staging is empty. In production the agent qualifies a lead, gets back a 202 and a job id, and then has to answer the next question: has the record been written? It has three options, all bad. It can poll the job, which reintroduces the calls you were saving. It can assume success, which means the agent's model of the pipeline diverges from the database, and the divergence is invisible until a second agent picks up the same lead. Or it can be told to wait, which turns a one second turn into a thirty second turn and pushes the tool call past whatever timeout your orchestrator enforces.

The deeper problem is that a batched write destroys the error channel. A field level validation failure, a duplicate rule, a required custom field on a page layout, a UNABLE_TO_LOCK_ROW on a contended parent: in a synchronous write, each of these comes back as a status code and a message the agent can read and act on. In a Bulk job, they come back later, in a results file, keyed to a row number in a CSV the model never saw. An agent cannot repair an error it was never handed. It will report success instead, because success is what its tool call returned.

So the rule is not "batch when the volume is high". It is batch when nothing is waiting on the individual outcome, and stay synchronous when the outcome is the input to the next decision. Volume tells you the cost. Dependency tells you the shape.

The limit that breaks the loop is usually not the daily cap

Before you re-architect around Bulk, confirm which limit you are actually hitting. Salesforce enforces several at once: the 24 hour org allocation, a cap on concurrent long running synchronous requests, per transaction governor limits inside any Apex your write triggers, and row level locking during parallel processing. A loop that stalls at ten concurrent agents is almost certainly hitting concurrency or locks, not the daily cap, and moving to Bulk will make lock contention worse rather than better because Bulk processes batches in parallel by default.

The diagnosis is cheap. Log the status code and the error name on every write, not just the failures your wrapper decided were retryable. If you see REQUEST_LIMIT_EXCEEDED, the allocation is the problem. If you see UNABLE_TO_LOCK_ROW, serialise by parent key. If you see nothing but timeouts, the queue you added is the problem.

What a write path shaped for agents looks like

The reason this trade-off is so sharp in Salesforce is that the write model was designed for a form, then extended for nightly integrations, and an agent loop is neither. Fathom is built for the third case. Its CRUD endpoints for Leads, Contacts, Accounts, Deals and Interactions have no required UI fields, so a single record write does not fail because a page layout wanted a value the agent has no opinion about. Malformed write bodies to those endpoints return a 400 with a field level message naming the field, rather than a 500 or a silent partial write, which means the error is something a model can read and correct on the next turn.

Above CRUD there are six action endpoints, qualify_lead, advance_deal_stage, log_interaction, create_contact, flag_churn_risk and assign_owner, exposed both as REST and as OpenAI function calling and Anthropic tool use schemas generated from one action definition source, so the schema the agent sees and the contract the server enforces come from the same file. Three of those six, qualify_lead, flag_churn_risk and assign_owner, take human_review_ack and lawful_basis as required fields, and the server validates both on those three endpoints: omit either one and the response is a 422 naming which field was missing rather than a generic rejection. Those are required fields the server checks on those three endpoints, not a policy document you hope someone reads.

For the work that genuinely should not block a turn, there is a webhook subscription system: register a hook per event type, and deliveries are queued and logged with retry, exponential backoff, attempt count and status tracking you can inspect. Usage is metered per API key for records stored and actions executed, and the developer dashboard shows those counters against the tier limit alongside read only schema inspection, so you can see which key your loop is spending on before you start guessing. Fathom is on a waitlist today, so none of this is a claim about someone else's production traffic. It is a claim about what the write path is built to do when it launches.

The honest summary for Salesforce: batch the sets, keep the decisions synchronous, instrument the error names, and accept that some of your high frequency writes were never facts worth storing one at a time.

Does a Bulk API 2.0 job count as one Salesforce API call?

No, it is metered per batch rather than per job or per record, with Salesforce forming the batches from your uploaded CSV. That makes the effective per record cost of a large load very low, which is why Bulk is the right path for imports and backfills rather than for single decisions.

Can I use Bulk API for an agent that writes on every turn?

You can, but you lose the thing the agent needs most, which is a synchronous per record result it can act on. Either the agent polls the job and gives back the calls you saved, or it assumes success and its model of the pipeline quietly diverges from the database.

Which Salesforce limit usually breaks an agent loop first?

Concurrency and row locking, not the 24 hour org allocation. A loop that stalls once you run ten agents in parallel is typically hitting the concurrent long running request cap or UNABLE_TO_LOCK_ROW on a shared parent record, and moving to Bulk can make lock contention worse.

What is the middle ground between one call per record and Bulk?

The composite endpoints. composite/sobjects takes an array and returns per record success or error entries in one call, and composite/graph lets you chain dependent writes that reference earlier subrequest ids. You keep synchronous per record errors while collapsing the call count.