All posts

What it costs, and how to keep it that way: keys, budgets and retries

A per-check price is easy to estimate and easy to overrun. The price list, the three kinds of key, the budgets that cap a month and the retry rules that stop you paying twice.

By Oussama Messai Published 2 December 2026 7 min read Lire cet article en français
A supermarket aisle with a milk spill on the floor, seen from a ceiling camera

Usage-based pricing has one good property and one bad one. The good one: a project that looks at ten pictures a day pays for ten pictures. The bad one: a bug that looks at ten pictures a second pays for those too.

This last post of the series is about making the first property true and the second one harmless. It covers what each call costs, which key to put where, how to cap a month, and how to retry without paying twice. The figures are those published at the time of writing; the documentation has the current ones.1

The price list

WhatPriceNote
A direct check: one picture, one question€0.005
A check made by a monitor€0.006The monitor keeps state, opens incidents and keeps evidence
A tracker, or a calibrated measure2 checksTwo pictures are compared
A burst of 2 to 6 pictures3 checks
A look-back picture1 checkDoes not count against the rate limit
A chat message€0.02Whatever the length of the history
The pictures of a window€0.01 per requestRefunded when nothing comes back; keeping a picture is free
A live camera with an active monitor€2 a monthBridges, cameras without a monitor and everything in test mode are free

The balance is prepaid. Test keys are free.

What is never charged

Knowing this list matters as much as knowing the prices, because it tells you what is safe to do liberally.

  • A skipped picture. A picture that reaches a monitor too soon after the last check, outside its hours, or while it is paused makes no check.
  • A failed check. When no usable answer could be given, the API answers 502 and charges nothing.
  • A message without a picture sent by a camera to its upload URL, such as a heartbeat.
  • Anything done with a test key.

The first line is the one that protects you from chatty equipment: a camera that sends ten pictures on one motion event costs one check, because the nine others arrive inside the monitor’s minimum interval.

Estimating a project

The arithmetic fits on one line: checks a day, times the price, times thirty, plus the camera fee.

ScenarioChecks a dayPer month
One camera, a monitor, a check every 15 minutes, 12 hours a day4848 × 0.006 × 30 + 2 = €10.64
The same, every 5 minutes144144 × 0.006 × 30 + 2 = €27.92
A device calling directly, every hour, around the clock2424 × 0.005 × 30 = €3.60
Twenty look-backs a month that each stop at 40 pictures20 × 40 × 0.005 = €4.00

The lever is always the same: how often. Ask how fast the thing you watch can change, and how long a problem may last before someone must know. A blocked exit that must be reported within fifteen minutes does not need a check every thirty seconds. Limiting the hours is the second lever: a monitor with opening hours makes no checks at night.

Three kinds of key

KeyCan doPut it
Full accessRuns checks; manages agents, cameras, monitors and webhooks; reads incidents and past checksOn your back end, and nowhere else
Run onlyRuns checksIn a device that calls the API directly
Push onlySends pictures to camerasIn a gateway or a service on a customer’s site

The rule behind the table: anything that leaves your servers gets a key that can do one thing. A board on a shelf can be picked up; a gateway in a cabinet can be opened. If the key inside can only run checks or only send pictures, losing it costs you at most some balance, and a budget caps even that. It cannot read a single incident or picture of your customers.

A key is never for a browser or a phone app. Anything shipped to a user’s device can be read by that user. Call the API from your server and serve the results yourself.

Budgets: the cap that works while you sleep

A budget limits what a key, a project or the whole organisation spends in a month. A hard budget refuses checks once the amount is reached, with a 402 for direct calls; a monitor that would pass it pauses, and resumes when the month turns or the budget changes.

Three budgets are worth setting on day one.

  1. On each device key, a little above its expected month. A board stuck in a loop then stops at a known amount.
  2. On each project, so that a test environment cannot spend like production.
  3. On the organisation, as the last line.

Budgets also send a budget.threshold_reached webhook on the way up, and billing.balance_low warns when the balance falls under €1. Route both to a person: they are the difference between “we topped up on Tuesday” and “monitoring stopped on Saturday night and nobody knew”. An automatic top-up exists for the same reason.

Retries that do not pay twice

A network call can fail in a way that leaves you unsure whether it happened: the request left, the answer never came. Retrying blindly may pay for the same picture twice.

Send an Idempotency-Key header with each direct check, any unique string, such as the picture’s own id:

curl https://api.camly.ai/v1/runs \
  -H "Authorization: Bearer $CAMLY_API_KEY" \
  -H "Idempotency-Key: dock-3-000412" \
  -F agent=agt_123 \
  -F [email protected]

A retry with the same key returns the first answer and is charged once.

Then sort errors by what they ask of you.

StatusMeaningDo
429Too many checks this minuteWait the seconds in Retry-After, then retry
502No usable answer; not chargedRetry with a growing pause
401, 403The key is unknown, revoked or lacks the rightStop and alert someone
402The balance or a budget cannot payStop; top up or raise the budget
404, 422The object or the request is wrongFix the request; do not resend it as it is

The mistake to avoid is a loop that retries everything. A 422 retried a thousand times is a thousand refusals; a 401 retried all night hides the fact that a key was revoked. Every error carries a request_id: log it, and quote it when you write to support.

Pictures pushed to a camera are a different case. That call takes no idempotency key, and needs none: a picture sent twice is not checked twice while it falls inside the monitor’s minimum interval. And when a push fails, do not resend the same picture later. Take a fresh one. The reasons are in five ways to get a picture to the API.

A checklist before going live

  • The Full access key is on the back end only, read from the environment, never committed.
  • Every device and gateway has its own Run only or Push only key.
  • A budget is set on each key, each project and the organisation.
  • billing.balance_low and monitor.paused reach a person.
  • Direct checks send an Idempotency-Key.
  • The retry code stops on 401, 402, 403, 404 and 422.
  • GET /v1/balance is read by something that will tell you before it reaches zero.

None of it is specific to cameras. It is what makes a metered API boring to operate, which is the goal.

Sources

  1. Camly API, all guides as plain text: Limits and prices, Keys, Retries, Errors, Monitoring, Webhooks. platform.camly.ai
  2. Camly API contract (OpenAPI). api.camly.ai