Streaks
Manage streak definitions — daily or weekly cadence, grace windows, and optional freezes.
Streak definitions describe the rules that user streaks follow. Per-user streak state is created and updated automatically by the streak evaluator and the POST /client/streaks/:streakId/qualify endpoint.
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /admin/projects/:projectId/streaks | Create a streak definition. |
| GET | /admin/projects/:projectId/streaks | List streak definitions. |
| PATCH | /admin/projects/:projectId/streaks/:streakId | Partial update. |
| DELETE | /admin/projects/:projectId/streaks/:streakId | Delete a streak definition. |
| POST | /admin/projects/:projectId/streaks/:streakId/reset | Reset or correct a user's streak (support). |
| POST | /admin/projects/:projectId/users/:userId/streaks/:streakDefinitionId/grant-shield | Grant 1+ shields (freezes) to a user streak. |
POST /admin/projects/:projectId/streaks
Request
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | yes | — | Stable human-readable identifier (e.g. "daily_workout"). Used by clients to qualify by key. Immutable after creation. |
name | string | yes | — | |
description | string | no | null | |
qualifying_event | string | yes | — | Engagement event that counts toward the streak. |
period | "daily" | "weekly" | no | "daily" | |
grace_period_hours | number | no | 0 | Extra hours after period end before the streak breaks. |
freeze_enabled | boolean | no | false | Allow freezes (shields) to save a streak on a missed period. |
max_freezes | number | no | 1 | Per-user freeze cap. |
freezes_per_n_events | number | null | no | null | Auto-grant rule. When set, every N consecutive qualifying events grants 1 freeze, capped at max_freezes. |
Response 201
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/streakscurl -X POST 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/streaks'Curl:
GET /admin/projects/:projectId/streaks
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/streakscurl -X GET 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/streaks'Curl:
PATCH /admin/projects/:projectId/streaks/:streakId
Updatable fields: name, description, qualifying_event, period, grace_period_hours, freeze_enabled, max_freezes, freezes_per_n_events.
key is immutable — it cannot be changed after creation. Clients that qualify by key rely on the key being stable; changing it would silently break their qualify calls.
Errors
404 NOT_FOUND.500 UPDATE_FAILED.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7Dcurl -X PATCH 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D'Curl:
DELETE /admin/projects/:projectId/streaks/:streakId
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7Dcurl -X DELETE 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D'Curl:
POST /admin/projects/:projectId/streaks/:streakId/reset
Per-user streak correction for support — fix a wrongly-broken streak (for example, a grace-period miss caused by an outage). Sets the user's current_count and marks the streak active again. The update and its audit row commit atomically; a streak_events row with event_type = "reset" is written for the trail.
- Omit
set_countto zero the streak — a clean restart. - Pass
set_countto restore the streak to a specific value;longest_countis bumped ifset_countexceeds it.
This is a correction primitive, not a provisioning one: it won't create a user's first-touch streak state (the streak evaluator owns that on the first qualifying event), so it returns 404 when no per-user streak row exists yet.
Request (ResetStreakInput)
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
app_user_id | uuid | yes | — | User whose streak to reset. |
set_count | number | no | 0 | Non-negative integer. Restore the streak to this count; omit to zero it entirely. |
Response 200
Errors
400 VALIDATION_ERROR—app_user_idmissing.400 INVALID_COUNT—set_countisn't a non-negative integer.400 INVALID_ID—app_user_idorstreakIdisn't a UUID.404 USER_STREAK_NOT_FOUND— no per-user streak row exists for this (user, streak definition) pair yet.500 RESET_FAILED.
Try it:
/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D/resetcurl -X POST 'https://api.amba.dev/v1/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D/reset'Curl:
POST /admin/projects/:projectId/users/:userId/streaks/:streakDefinitionId/grant-shield
Grant N shields (freezes) to a specific user's streak. Increases freezes_remaining by count, clamped at the streak definition's max_freezes.
The endpoint refuses to provision a user's first-touch streak state — the streak evaluator does that automatically on the user's first qualifying event. Grant-shield is meant for top-ups, not first-touch provisioning.
Request
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
count | number | no | 1 | Positive integer. Clamped at cap. |
Response 200
Errors
400 INVALID_COUNT—countmust be a positive integer.400 INVALID_ID—userIdorstreakDefinitionIdis not a UUID.404 STREAK_DEFINITION_NOT_FOUND— no streak definition matchesstreakDefinitionId.404 USER_STREAK_NOT_FOUND— the user hasn't qualified for this streak yet (no state exists to grant against).
Curl: