When to use batch
- Processing a set of photos from a single store visit
- Analyzing images uploaded by field teams throughout the day
- Running periodic audits across multiple locations
- Any workflow where you have multiple images ready to submit at once
Submitting a batch
Send aPOST request to the batch analyses endpoint with an array of images:
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
images | array | Yes | Array of image objects (1-20 items). |
images[].imageUrl | string | Yes | Publicly accessible URL of the shelf image. |
images[].metadata | object | No | Arbitrary key-value pairs to attach to this analysis. |
images[].idempotencyKey | string | No | Unique key to prevent duplicate submissions (see below). |
callbackUrl | string | No | URL to receive a webhook for each completed analysis. |
Response
Credit handling
Batch analysis uses an all-or-nothing credit check:- Each image costs 1 credit (same as a single analysis).
- Before processing begins, Shelfforce verifies you have enough credits for the entire batch.
- If you do not have enough credits, the entire request is rejected — no images are analyzed and no credits are consumed.
Retrieving results
Each analysis in the batch has its own ID. Poll individual analyses for results:callbackUrl in the batch request, you will receive a separate webhook for each image as it finishes.
Checking batch status
You can also query the batch endpoint to see the status of all analyses in the batch:status is one of:
processing— All analyses are still running.partial— Some analyses have completed, others are still running.completed— All analyses have finished (either completed or failed).
Idempotency keys
Use idempotency keys to safely retry batch requests without creating duplicate analyses. If a request with the same idempotency key is submitted again, Shelfforce returns the existing analysis instead of creating a new one.Idempotency keys are scoped to your organisation and expire after 24 hours. Use a combination of store, location, and date to create meaningful keys.
Best practices
Group by store visit
Submit all photos from a single store visit in one batch. This makes it easy to correlate results and reduces API calls.
Use metadata
Attach store IDs, aisle numbers, and dates as metadata so you can filter and group results later.
Use idempotency keys
Always include idempotency keys, especially when retrying failed requests or when your pipeline might submit the same image twice.
Combine with webhooks
Set a
callbackUrl on the batch or register a persistent webhook for analysis.completed to avoid polling each analysis individually.Limits
| Constraint | Value |
|---|---|
| Maximum images per batch | 20 |
| Maximum image file size | 20 MB |
| Supported formats | JPEG, PNG, WebP |