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/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/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: