Build the whole flow before you own a camera
Test keys are free and repeatable, and a simulated camera opens and closes an incident on a fixed script. How to write and test a camera integration with no camera at all.
Camera projects have an awkward first week. The code needs pictures, the pictures need a camera, the camera needs a site, and the site needs someone with a ladder. Meanwhile nothing can be tested, and the first incident your webhook handler ever sees is a real one.
The Camly API is built so that this week does not exist. Everything, webhooks included, can be written and tested with a test key and a camera that is not there.1
What a test key does
A key that starts with cmly_sk_test_ is free and never calls the model. The answer is derived from the bytes of the picture, so the same picture always gives the same answer.
That last property is the one that matters for automated tests. A real vision model can change its mind between two runs on a borderline picture, and a test suite that fails one time in twenty is a test suite people stop reading. With a test key, pick one picture that comes back flagged and one that comes back clear, commit both to your repository, and your tests are deterministic.
Test and live are two separate worlds. Cameras, monitors, incidents and events belong to one mode, and a test key sees only test objects. Nothing you do while building can touch production data or spend money.
A camera that is not there
With a test key you can create a camera whose source is simulated:
curl https://api.camly.ai/v1/cameras \
-H "Authorization: Bearer $CAMLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Test dock", "source": "simulated" }'
It makes its own pictures on a fixed script of eight ticks: two clear, four flagged, two clear, then again. Attach a monitor with a saved agent, as you would on a real camera, and run the ticks yourself:
curl https://api.camly.ai/v1/cameras/cam_123/simulate \
-H "Authorization: Bearer $CAMLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "ticks": 8 }'
With the default rules, two flagged checks in a row to open and two clear ones to close, here is what the script produces.
| Tick | Script | What happens |
|---|---|---|
| 1, 2 | Clear | Nothing |
| 3 | Flagged | First flagged check: nothing opens yet |
| 4 | Flagged | Second in a row: the incident opens, incident.opened goes out |
| 5, 6 | Flagged | The incident counts its checks |
| 7 | Clear | First clear check |
| 8 | Clear | Second in a row: the incident closes, incident.closed goes out |
You know in advance, to the tick, when each webhook fires. That makes an end-to-end test a short thing to write: run eight ticks, assert that your system recorded exactly one incident with a start and an end.
Four tests worth writing
The happy path. Eight ticks, one incident opened, one closed. This proves the wiring: key, camera, monitor, endpoint, signature, storage.
The passing forklift. Change the monitor to confirm_checks: 5 and run eight ticks. The script only has four flagged checks in a row, so nothing should open. This proves your system stays quiet when the rules say it should.
The duplicate. After the happy path, call POST /v1/events/evt_.../redeliver on the incident.opened event. Your handler receives it a second time; your system should still show one incident. Delivery is at least once in production, so this test is not optional. The reasons are in webhooks you can trust.
The bad signature. Post a body to your own endpoint with a wrong Camly-Signature. It should answer 400 and store nothing.
Pushed pictures work too
A camera with source push accepts pictures with a test key as well, with the same deterministic verdict. That lets you test the sender side: the loop that takes a picture, posts it, reads next_frame_seconds and waits.
A look-back, the search through past pictures, can be tested the same way: a simulated camera answers it at once, going through four sample pictures of which the third matches.
Two things a test key will not tell you
It will not tell you whether your question is good. The verdict comes from the bytes of the picture, not from what the picture shows, so a test key cannot tell a blocked exit from a clear one. Whether “is the marked exit blocked?” works on your camera, at your angle, in your light, is a question for a live key and real pictures. Budget an afternoon for it; at €0.005 a check, a hundred trial pictures cost fifty cents.1
It will not run for ever unattended. A simulated camera with an active monitor ticks by itself every 15 minutes, so a test incident opens and closes without you. A test monitor left alone for 7 days, with no change, no sign-in and no call from your keys, is paused; resume it when you need it.
The order that works
- Test key, simulated camera: write the webhook handler and the four tests above.
- Test key, pushed pictures: write the sender.
- Live key, a handful of real pictures sent by hand: tune the question.
- Live key, the real camera.
Steps 1 and 2 need no hardware and cost nothing. By the time someone climbs the ladder, the only unknown left is the question.
Sources
- Camly API, all guides as plain text: Testing without cameras, Keys, Monitoring, Limits and prices. platform.camly.ai
- Camly API contract (OpenAPI). api.camly.ai