Get User Activity History
This endpoint returns a comprehensive history of all activities completed by a specific user, giving you a complete picture of their engagement with your gamification features.
Endpoint
GET /user/{userId}/history
Authentication
⚠️
Authentication Required
This endpoint requires a valid JWT token with appropriate permissions.
See our JWT Authentication guide for more details.
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
userId | string | Yes | The unique identifier of the user |
Query Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
limit | integer | No | 20 | Number of items to return (max 100) |
offset | integer | No | 0 | Number of items to skip (for pagination) |
from | string | No | - | Start date in ISO format (e.g. "2025-01-01") |
to | string | No | - | End date in ISO format (e.g. "2025-04-07") |
types | string | No | - | Filter by activity types (comma-separated list) |
lang | string | No | en | Language code for localized content |
Valid types for filtering:
event
- User completed eventsredemption
- Point redemption activitieschallenge
- Challenge completionsstreak_milestone
- Streak milestone achievementsstreak_points
- Points credited through streaks
Example Request
curl -X GET "https://api.lynesloyalty.com/v1/user/user_123/history?limit=10&types=event,challenge&lang=en" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json"
Response
Success Response (200 OK)
{
"data": [
{
"id": "act_123abc",
"title": "First Purchase",
"description": "You made your first purchase in our store",
"points": 50,
"type": "event",
"timestamp": 1712491425000,
"image": "https://assets.lynesloyalty.com/icons/purchase.png"
},
{
"id": "act_124def",
"title": "First Week Champion",
"description": "You've completed the first week challenge",
"points": 200,
"type": "challenge",
"timestamp": 1712405130000,
"image": "https://assets.lynesloyalty.com/badges/week_champion.png"
},
{
"id": "act_125ghi",
"title": "10% Discount Coupon",
"description": "You redeemed points for a discount coupon",
"points": -500,
"type": "redemption",
"timestamp": 1712318532000,
"image": "https://assets.lynesloyalty.com/rewards/discount.png"
},
{
"id": "act_126jkl",
"title": "One Week Streak",
"description": "You've logged in for 7 days in a row",
"points": 0,
"type": "streak_milestone",
"timestamp": 1712231122000,
"image": "https://assets.lynesloyalty.com/streaks/week.png"
},
{
"id": "act_127mno",
"title": "Daily Login Bonus",
"description": "You received points for maintaining your login streak",
"points": 25,
"type": "streak_points",
"timestamp": 1712231122000,
"image": "https://assets.lynesloyalty.com/streaks/points.png"
}
],
"pagination": {
"total": 42,
"limit": 10,
"offset": 0,
"has_more": true
}
}
Error Responses
401 Unauthorized
{
"error": {
"code": "unauthorized",
"message": "Invalid or expired authentication token"
}
}
403 Forbidden
{
"error": {
"code": "forbidden",
"message": "Insufficient permissions to access this resource"
}
}
404 Not Found
{
"error": {
"code": "not_found",
"message": "User with ID 'user_123' not found"
}
}
History Event Structure
Each history event in the response follows this structure:
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the history event |
title | string | Localized title of the event (based on lang parameter) |
description | string | Localized description (may be null, based on lang parameter) |
points | integer | Points earned (positive) or spent (negative) |
type | string | Event type (see below for available types) |
timestamp | number | Unix timestamp in milliseconds |
image | string | URL to an image representing the event (may be null) |
Activity Types
The history endpoint returns different types of activities:
Event
Records when a user has completed an event:
{
"title": "First Purchase",
"description": "You made your first purchase in our store",
"points": 50,
"type": "event",
"timestamp": 1712491425000,
"image": "https://assets.lynesloyalty.com/icons/purchase.png"
}
Redemption
Records when a user has redeemed points for a reward:
{
"title": "10% Discount Coupon",
"description": "You redeemed points for a discount coupon",
"points": -500,
"type": "redemption",
"timestamp": 1712318532000,
"image": "https://assets.lynesloyalty.com/rewards/discount.png"
}
Challenge
Records when a user has completed a challenge:
{
"title": "First Week Champion",
"description": "You've completed the first week challenge",
"points": 200,
"type": "challenge",
"timestamp": 1712405130000,
"image": "https://assets.lynesloyalty.com/badges/week_champion.png"
}
Streak Milestone
Records when a user has reached a milestone in their streak:
{
"title": "One Week Streak",
"description": "You've logged in for 7 days in a row",
"points": 0,
"type": "streak_milestone",
"timestamp": 1712231122000,
"image": "https://assets.lynesloyalty.com/streaks/week.png"
}
Streak Points
Records when a user has earned points from continuing a streak:
{
"title": "Daily Login Bonus",
"description": "You received points for maintaining your login streak",
"points": 25,
"type": "streak_points",
"timestamp": 1712231122000,
"image": "https://assets.lynesloyalty.com/streaks/points.png"
}