Consumers API
Consumers represent end users in the Fanfare platform. Use these endpoints to create, manage, and query consumer records.Create Consumer
Create a new consumer.POST /api/v1/consumers
Authentication
- Secret key required
Request Body
Response
Example
Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | Validation failed | Invalid request data |
| 400 | Email already exists | Duplicate email |
| 401 | Authentication required | Missing authentication |
List Consumers
List consumers with pagination, search, and filtering.GET /api/v1/consumers
Authentication
- Secret key required
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
first | number | 20 | Number of items per page (max 100) |
after | string | - | Cursor for forward pagination |
before | string | - | Cursor for backward pagination |
last | number | - | Items for backward pagination |
search | string | - | Search by email, phone, or name (min 2 chars) |
sortBy | string | createdAt | Field to sort by |
sortDir | string | desc | Sort direction (asc or desc) |
createdAfter | string | - | Filter by creation date |
createdBefore | string | - | Filter by creation date |
audienceId | string | - | Filter by audience membership |
include | string | - | Relations to include (audiences) |
Response
Example
Get Consumer
Get a single consumer by ID.GET /api/v1/consumers/:id
Authentication
- Secret key required
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The consumer ID |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
include | string | Relations to include (audiences, orders) |
Example
Error Responses
| Status | Error | Description |
|---|---|---|
| 404 | Consumer not found | Consumer ID does not exist |
Update Consumer
Update an existing consumer.PUT /api/v1/consumers/:id
Authentication
- Secret key required
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The consumer ID |
Request Body
Example
Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | Validation failed | Invalid request data |
| 404 | Consumer not found | Consumer ID does not exist |
Delete Consumer
Delete a consumer.DELETE /api/v1/consumers/:id
Authentication
- Secret key required
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The consumer ID |
Example
Response
Returns the deleted consumer.Batch Create Consumers
Create multiple consumers in a single request.POST /api/v1/consumers/batch
Authentication
- Secret key required
Request Body
Example
Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | Max batch size is 500 | Too many consumers in batch |
Batch Update Consumers
Update multiple consumers in a single request.PUT /api/v1/consumers/batch
Authentication
- Secret key required
Request Body
Example
Search Consumers
Search consumers with additional search options.GET /api/v1/consumers/search
Authentication
- Secret key required
Query Parameters
| Parameter | Type | Description |
|---|---|---|
q | string | Search query (min 2 chars) |
email | string | Exact email match |
phone | string | Exact phone match |
externalId | string | Exact external ID match |
first | number | Page size |
Example
Sortable Fields
| Field | Description |
|---|---|
createdAt | Consumer creation date (default) |
email | Email address (alphabetical) |
fullName | Full name (alphabetical) |
lastOrderAt | Most recent order date |
totalOrderValue | Lifetime order value |
totalOrders | Total order count |