BricqsBricqs
Documentation

Streaks API

Track consecutive activity streaks (daily logins, weekly workouts, etc.). The API handles period calculation, grace periods, and automatic resets.

Authentication: All endpoints require an X-API-Key header. Base URL: https://YOUR_API_DOMAIN/api/v1/gamify
MethodEndpointDescription
POST/gamify/streaks/recordRecord streak activity. Auto-increment or reset based on period.
GET/gamify/participants/{pid}/streaksAll streak statuses for a participant.

Record Streak Activity

Recording within the same period is idempotent. Missing a period resets the streak count (subject to grace period configuration).

POST /api/v1/gamify/streaks/record

{
  "participant_id": "user_123",
  "streak_code": "daily_login",
  "timestamp": "2026-02-14T08:15:00Z"  // Optional, defaults to now
}

// Day 1 response
{ "streak_code": "daily_login", "new_count": 1, "longest_count": 1,
  "is_new_record": true, "already_recorded": false }

// Same day again → idempotent
{ "streak_code": "daily_login", "new_count": 1, "longest_count": 1,
  "is_new_record": false, "already_recorded": true }

// Next day → increments
{ "streak_code": "daily_login", "new_count": 2, "longest_count": 2,
  "is_new_record": true, "already_recorded": false }

Get All Streaks

GET /api/v1/gamify/participants/user_123/streaks

{
  "participant_id": "user_123",
  "streaks": [
    {
      "code": "daily_login",
      "name": "Daily Login",
      "current_count": 7,
      "longest_count": 21,
      "last_recorded_at": "2026-02-14T08:15:00Z",
      "period": "daily"
    }
  ]
}
← Back to Gamification API