BricqsBricqs
Documentation

Streaks API

Track consecutive activity streaks such as daily logins or weekly workouts. Bricqs handles period calculation, grace periods, and automatic resets. Read a participant’s status with the participant endpoints; create and manage streak definitions through the admin endpoints.

Auth
All endpoints require an X-API-Key header. Production keys are prefixed bq_live_; sandbox keys bq_test_.
Scopes
Participant key Read streak status and record ticks with any valid API key.
Admin scope Manage streak definitions: requires admin or gamify:admin scope.
Base URLhttps://YOUR_API_DOMAIN/api/v1/gamify

Endpoint inventory

MethodEndpointPurpose
GET/gamify/participants/{participant_id}/streaksAll streak statuses for a participant.
POST/gamify/streaks/recordRecord a streak tick. Period-based dedup.
GET/gamify/admin/streaksList streak definitions. Admin scope.
POST/gamify/admin/streaksCreate a streak definition. Admin scope.
GET/gamify/admin/streaks/{streak_id}Get one streak definition. Admin scope.
PATCH/gamify/admin/streaks/{streak_id}Update a streak definition. Admin scope.
DELETE/gamify/admin/streaks/{streak_id}Deactivate (soft-delete) a streak. Admin scope.
GET/api/v1/gamify/participants/{participant_id}/streaks
Participant key

Returns the current and longest counts for every active streak the participant has touched, plus an at-risk flag for streaks whose grace window is about to close.

Path parameters
FieldTypeDescription
participant_idrequiredstrYour participant identifier. 1 to 255 characters.
GET /api/v1/gamify/participants/user_42/streaks
X-API-Key: bq_live_xxxxx
Response fields
FieldTypeDescription
participant_idstrEcho of the requested participant id.
streakslist[StreakStatusEntry]One entry per streak the participant has touched. Fields: code, name, current_count (default 0), longest_count (default 0), last_recorded_at (optional), is_at_risk (default false), period (default "daily").
{
  "participant_id": "user_42",
  "streaks": [
    {
      "code": "daily_login",
      "name": "Daily Login",
      "current_count": 7,
      "longest_count": 21,
      "last_recorded_at": "2026-02-14T08:15:00Z",
      "is_at_risk": false,
      "period": "daily"
    }
  ]
}
Errors
StatusCodeWhen it fires
401unauthorizedX-API-Key header missing, invalid, expired, or revoked.
403forbiddenTenant is disabled.
POST/api/v1/gamify/streaks/record
Participant key

Record a streak tick for the participant. Period-based idempotency: a second tick in the same period returns already_recorded: true with the count unchanged. No Idempotency-Key header needed.

Request body
FieldTypeDescription
participant_idrequiredstrYour participant identifier. 1 to 255 characters.
streak_coderequiredstrCode of the streak definition to record against. 1 to 50 characters. Must match an existing streak for the tenant.
timestampOptional[datetime]ISO-8601 timestamp for the tick. Defaults to server time when omitted.
POST /api/v1/gamify/streaks/record
X-API-Key: bq_live_xxxxx
Content-Type: application/json

{
  "participant_id": "user_42",
  "streak_code": "daily_login",
  "timestamp": "2026-02-14T08:15:00Z"
}
Response fields
FieldTypeDescription
streak_codestrEcho of the recorded streak code.
new_countintCurrent streak length after this tick.
is_new_recordboolTrue when new_count exceeds the participant's previous longest_count for this streak. Default: false
longest_countintLongest streak length the participant has ever reached for this streak.
already_recordedboolTrue when a tick has already been recorded in the current period; new_count is unchanged in that case. Default: false
// First tick of the period
{
  "streak_code": "daily_login",
  "new_count": 1,
  "is_new_record": true,
  "longest_count": 1,
  "already_recorded": false
}

// Same period again, idempotent no-op
{
  "streak_code": "daily_login",
  "new_count": 1,
  "is_new_record": false,
  "longest_count": 1,
  "already_recorded": true
}

// Next period, increments
{
  "streak_code": "daily_login",
  "new_count": 2,
  "is_new_record": true,
  "longest_count": 2,
  "already_recorded": false
}
Errors
StatusCodeWhen it fires
404streak_not_foundNo streak definition exists for the supplied streak_code ("Streak '{streak_code}' not found").
429RATE_LIMIT_PARTICIPANT_EXCEEDEDPer-participant write rate cap exceeded. The Retry-After response header tells you when to retry.
GET/api/v1/gamify/admin/streaks
Admin scope

List streak definitions for the tenant.

Query parameters
FieldTypeDescription
is_activeOptional[bool]When set, filters to definitions where is_active matches.
pageint1-indexed page number. Default: 1
page_sizeintItems per page. Max 100. Default: 50
GET /api/v1/gamify/admin/streaks?is_active=true&page=1&page_size=50
X-API-Key: bq_live_xxxxx   # must carry admin or gamify:admin scope
Response fields
FieldTypeDescription
itemslist[StreakResponse]Page of streak definitions. Each item: id (UUID), tenant_id (UUID), code, name, description (optional), fact_type, fact_filter (optional dict), period, grace_periods, reset_on_miss, icon_url (optional), color (optional), is_active, display_order, created_at, updated_at.
totalintTotal number of definitions matching the filter.
pageintCurrent page number.
page_sizeintItems per page used for the response.
{
  "items": [
    {
      "id": "01HZ...",
      "tenant_id": "01HZ...",
      "code": "daily_login",
      "name": "Daily Login",
      "description": "One tick per calendar day for logging in.",
      "fact_type": "login",
      "fact_filter": null,
      "period": "daily",
      "grace_periods": 0,
      "reset_on_miss": true,
      "icon_url": "https://cdn.example.com/streaks/login.png",
      "color": "#0891B2",
      "is_active": true,
      "display_order": 0,
      "created_at": "2026-01-10T08:00:00Z",
      "updated_at": "2026-02-12T15:30:00Z"
    }
  ],
  "total": 3,
  "page": 1,
  "page_size": 50
}
POST/api/v1/gamify/admin/streaks
Admin scope

Create a streak definition. Returns 201 on success.

Request body
FieldTypeDescription
coderequiredstrUnique streak code for the tenant. 1 to 50 chars. Cannot be changed after creation; downstream ticks reference it.
namerequiredstrDisplay name. 1 to 100 chars.
descriptionOptional[str]Optional long-form description.
fact_typerequiredstrFact type that increments the streak (for example login, activity_completed).
fact_filterOptional[dict]Optional payload filter applied to incoming facts before they count toward the streak.
periodstrCadence used for the dedup window. One of daily, weekly, monthly. Default: "daily"
grace_periodsintNumber of consecutive missed periods tolerated before the streak resets. Must be >= 0. Default: 0
reset_on_missboolWhen true, missing more than grace_periods periods resets current_count to 0. Default: true
icon_urlOptional[str]Optional URL for a streak icon shown in the SDK or dashboards.
colorOptional[str]Optional hex color. Max 20 chars.
display_orderintSort order in admin and SDK listings. Default: 0
POST /api/v1/gamify/admin/streaks
X-API-Key: bq_live_xxxxx   # admin or gamify:admin scope
Content-Type: application/json

{
  "code": "daily_login",
  "name": "Daily Login",
  "fact_type": "login",
  "period": "daily",
  "grace_periods": 1,
  "reset_on_miss": true,
  "color": "#0891B2"
}
Errors
StatusCodeWhen it fires
400streak_code_conflictAnother streak definition already uses that code for this tenant ("Streak with code '{code}' already exists").
403forbiddenAPI key is missing the admin or gamify:admin scope.
GET/api/v1/gamify/admin/streaks/{streak_id}
Admin scope

Retrieve one streak definition by its UUID. Response shape matches the items in the list endpoint.

Errors
StatusCodeWhen it fires
404streak_not_foundNo streak exists for the supplied streak_id ("Streak not found").
PATCH/api/v1/gamify/admin/streaks/{streak_id}
Admin scope

Partial update of a streak definition. All body fields are optional; only supplied fields are changed.

Request body (all optional)
FieldTypeDescription
nameOptional[str]1 to 100 chars.
descriptionOptional[str]Long-form description.
fact_typeOptional[str]Switches which fact type increments the streak.
fact_filterOptional[dict]Replaces fact filter entirely.
periodOptional[str]daily, weekly, or monthly.
grace_periodsOptional[int]Missed periods tolerated before reset. Must be >= 0.
reset_on_missOptional[bool]Toggle reset-on-miss behaviour.
icon_urlOptional[str]
colorOptional[str]Hex color, max 20 chars.
display_orderOptional[int]Sort order in listings.
is_activeOptional[bool]Set false to pause the streak without deleting it.
Errors
StatusCodeWhen it fires
404streak_not_foundNo streak exists for the supplied streak_id ("Streak not found").
DELETE/api/v1/gamify/admin/streaks/{streak_id}
Admin scope

Soft-delete the streak definition by setting is_active to false. Existing participant counts are preserved; new ticks against the streak are rejected.

{ "message": "Streak deactivated" }
Errors
StatusCodeWhen it fires
404streak_not_foundNo streak exists for the supplied streak_id ("Streak not found").
Related
← Back to Gamification API