Audience API (Beta)
Complete Audience API documentation including public user-facing endpoints and private backend-to-backend APIs for bulk operations and data exports.
The Audience API is a dual-interface system providing comprehensive loyalty and gamification features through two distinct APIs:
Public API: User-facing endpoints for self-service profile management (JWT authenticated)
Private API: Backend-to-backend endpoints for bulk operations and admin tasks (API key authenticated)
Architecture
Public API (User-Facing)
JWT token authentication
User-scoped operations (users can only access their own data)
Rate limit: 100 requests/minute per user
Endpoints: Profile, Transactions, Challenges, Notifications, Product Redemption
Private API (Backend-to-Backend)
API key + secret authentication
Organization-scoped operations (full access to org data)
Rate limit: 10,000 requests/minute per API key
Endpoints: Bulk operations, User search, Data exports
Base URL
https://api.monterosa.cloud/v1/api/audience
All requests require the X-Monterosa-Org-ID header with your organization ID.
Public API Endpoints
User Profile
GET /profile
Get the authenticated user's complete profile including loyalty metrics and active challenges.
Authentication: JWT Bearer token (required)
Response:
PATCH /profile
Update the authenticated user's profile. Users can update displayName, preferences, and custom fields only.
Authentication: JWT Bearer token (required)
Request Body:
Response:
Transactions
GET /transactions
List the authenticated user's transaction history with optional filters and pagination.
Authentication: JWT Bearer token (required)
Query Parameters:
limit(optional): Records per page (default: 50, max: 100)type(optional): Filter bycreditordebitcurrency(optional): Filter bypoints,xp, orcoinslastEvaluatedKey(optional): Pagination token from previous response
Example: /transactions?type=credit¤cy=points&limit=20
Response:
Challenges
GET /challenges
List the authenticated user's challenges with optional status filter.
Authentication: JWT Bearer token (required)
Query Parameters:
status(optional): Filter byin_progress,completed, orfailedlimit(optional): Records per page (default: 20)
Response:
Notifications
GET /notifications
List the authenticated user's notifications with optional unread filter.
Authentication: JWT Bearer token (required)
Query Parameters:
unread(optional): Iftrue, show only unread notificationslimit(optional): Records per page (default: 50, max: 50)lastEvaluatedKey(optional): Pagination token
Response:
POST /notifications/{notificationId}/read
Mark a specific notification as read.
Authentication: JWT Bearer token (required)
Response:
Products
GET /products
List products available for redemption (only shows in-stock items).
Authentication: JWT Bearer token (required)
Response:
POST /products/{productId}/redeem
Redeem a product using loyalty currency (points, XP, or coins).
Authentication: JWT Bearer token (required)
Request Body:
Response (201 Created):
Private API Endpoints
Private endpoints require API key authentication via X-API-Key and X-API-Secret headers.
User Actions
POST /internal/actions
Report a single user action for processing by the loyalty rules engine.
Authentication: API Key (required)
Permissions: actions:write
Request Body:
Response (202 Accepted):
POST /internal/actions/bulk
Submit multiple user actions in bulk (max 1,000 actions per request).
Authentication: API Key (required)
Permissions: actions:write
Request Body:
Response (202 Accepted):
User Profiles
GET /internal/profiles
Retrieve multiple user profiles in batch (max 100 users per request).
Authentication: API Key (required)
Permissions: users:read
Query Parameters:
user_ids(required): Comma-separated list of user IDs
Example: /internal/profiles?user_ids=alice,bob,charlie
Response:
POST /internal/profiles/update-batch
Update multiple user profiles in bulk (max 1,000 updates per request).
Authentication: API Key (required)
Permissions: users:write
Request Body:
Response:
Rewards
POST /internal/rewards/bulk
Distribute rewards to multiple users (max 1,000 rewards per request).
Authentication: API Key (required)
Permissions: rewards:write
Request Body:
Response:
User Search & Export
POST /internal/users/search
Search users with advanced filtering and pagination.
Authentication: API Key (required)
Permissions: users:read
Request Body:
Response:
POST /internal/users/export
Create an encrypted export job for users matching search criteria. Exports are encrypted with AES-256-GCM and auto-expire after 24 hours.
Authentication: API Key (required)
Permissions: users:export
Request Body:
Response (202 Accepted):
GET /internal/exports/{exportId}
Get export job status and download information.
Authentication: API Key (required)
Permissions: users:read
Response:
Download URL and password are only included when status is completed and export is not expired.
Authentication
Public API - JWT Tokens
Public endpoints require a JWT Bearer token:
JWT tokens should include:
sub: User IDorgId: Organization IDscope: Permissions array (e.g.,["audience:read", "audience:write"])
Private API - API Keys
Private endpoints require API key and secret:
Never expose API keys or secrets in client-side code. Private endpoints are for backend-to-backend communication only.
Rate Limits
Public
100
1,000
20
Private
10,000
100,000
200
Batch Operation Limits
User IDs per batch get
100
Profile updates per batch
1,000
Actions per bulk submit
1,000
Rewards per bulk distribute
1,000
Users per export
1,000,000
Error Responses
All endpoints return errors in this format:
Common HTTP Status Codes:
400- Bad Request (invalid parameters)401- Unauthorized (missing or invalid auth)403- Forbidden (insufficient permissions)404- Not Found429- Too Many Requests (rate limit exceeded)500- Internal Server Error
Export Feature Details
Encryption
Exports are encrypted using AES-256-GCM with:
Auto-generated 32-character password
Random salt and initialization vector
Authentication tag for integrity verification
File Format
Encrypted files use the format: {salt}:{iv}:{authTag}:{encryptedData}
Expiration
Exports expire 24 hours after creation (configurable)
DynamoDB TTL automatically deletes expired job records
S3 lifecycle policy deletes files after 2 days
Processing
Export job created with status
processingScheduled Lambda (every 5 minutes) processes pending exports
Users queried and data formatted (CSV or JSON)
Content encrypted if requested
File uploaded to S3
Email sent with download URL and password
Job status updated to
completed
Decryption
See the Data Export Guide for decryption instructions.
SDK Support
The Monterosa SDK provides wrapper functions for all Audience API endpoints with automatic:
Token refresh and management
Error handling and retry logic
Request rate limiting
Response caching
Recommended: Use the SDK for production applications instead of calling the API directly.
Additional Resources
Last updated

