Amba

Streaks

Manage streak definitions — daily or weekly cadence, grace windows, and optional freezes.

Streak definitions describe the rules that user streaks follow. The actual user_streaks rows are written by the Temporal streak evaluation workflow and the POST /client/streaks/:streakId/qualify endpoint.

Source: apps/api/src/routes/admin/streaks.ts.

Endpoints

MethodPathDescription
POST/admin/projects/:projectId/streaksCreate a streak definition.
GET/admin/projects/:projectId/streaksList streak definitions.
PATCH/admin/projects/:projectId/streaks/:streakIdPartial update.
DELETE/admin/projects/:projectId/streaks/:streakIdDelete a streak definition.

POST /admin/projects/:projectId/streaks

Request

FieldTypeRequiredDefaultDescription
namestringyes
descriptionstringnonull
qualifying_eventstringyesEngagement event that counts toward the streak.
period"daily" | "weekly"no"daily"
grace_period_hoursnumberno0Extra hours after period end before the streak breaks.
freeze_enabledbooleannofalseAllow freezes to save a broken streak.
max_freezesnumberno1Per-user freeze cap.

Response 201

{
  "data": {
    "id": "…",
    "name": "…",
    "qualifying_event": "workout_completed",
    "period": "daily",
    "grace_period_hours": 0,
    "freeze_enabled": false,
    "max_freezes": 1,
    "created_at": "…"
  }
}

Try it:

POST/admin/projects/%7B%7BprojectId%7D%7D/streaks
developer auth
curl -X POST 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/streaks'
Loading auth… Configure auth in the settings drawer (top-right) to run this request.

Curl:

curl -X POST '${BASE_URL}/admin/projects/{projectId}/streaks' \
  -H 'Authorization: Bearer ${DEV_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{}'

GET /admin/projects/:projectId/streaks

{ "data": [{ "id": "…", "name": "…", "qualifying_event": "…", "period": "daily" }] }

Try it:

GET/admin/projects/%7B%7BprojectId%7D%7D/streaks
developer auth
curl -X GET 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/streaks'
Loading auth… Configure auth in the settings drawer (top-right) to run this request.

Curl:

curl -X GET '${BASE_URL}/admin/projects/{projectId}/streaks' \
  -H 'Authorization: Bearer ${DEV_TOKEN}'

PATCH /admin/projects/:projectId/streaks/:streakId

Updatable fields: name, description, qualifying_event, period, grace_period_hours, freeze_enabled, max_freezes.

Errors

  • 404 NOT_FOUND.
  • 500 UPDATE_FAILED.

Try it:

PATCH/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D
developer auth
curl -X PATCH 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D'
Loading auth… Configure auth in the settings drawer (top-right) to run this request.

Curl:

curl -X PATCH '${BASE_URL}/admin/projects/{projectId}/streaks/{streakId}' \
  -H 'Authorization: Bearer ${DEV_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{}'

DELETE /admin/projects/:projectId/streaks/:streakId

{ "data": { "deleted": true } }

Try it:

DELETE/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D
developer auth
curl -X DELETE 'https://api.amba.dev/admin/projects/%7B%7BprojectId%7D%7D/streaks/%7B%7BstreakId%7D%7D'
Loading auth… Configure auth in the settings drawer (top-right) to run this request.

Curl:

curl -X DELETE '${BASE_URL}/admin/projects/{projectId}/streaks/{streakId}' \
  -H 'Authorization: Bearer ${DEV_TOKEN}'

On this page