Zap Competitions REST API – Key Endpoints
Zap Competitions REST API – Key Endpoints
Base URL
https://your-domain.com/wp-json/
Authentication Protected endpoints require WordPress authentication (cookie, Application Password, or OAuth) and appropriate capability (typically manage_woocommerce).
1. Find Winner
Method: GET
Endpoint:
/wc/zap/v1/find-winnerPurpose: Retrieve winning entries for a competition, optionally filtered by user or ticket number.
Request Parameters (query)
Name | Type | Required | Description |
|---|---|---|---|
| integer | Yes | ID of the competition product |
| integer | No | WordPress user ID |
| string | No | Specific ticket number |
Response
200 OK: Returns an array of winner objects. Example:
[
{
"id": 123,
"product_id": 42,
"user_id": 99,
"ticket_number": "ABC123",
"date_won": "2025-06-15"
// ... other columns from winners table
}
]
404 Not Found: No matching winners or invalid competition. Error object:
{
"code": "no_winners_found",
"message": "No winners found for the given criteria.",
"data": { "status": 404 }
}
Example
curl "https://your-domain.com/wp-json/wc/zap/v1/find-winner?competition_id=42&ticket_number=ABC123"
2. Add Credit
Method: POST
Endpoint:
/wc/zap/v1/add-creditPurpose: Add funds to a user's cashier account.
Request Body (application/json)
Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | Account slug (e.g. |
| integer | Yes | WordPress user ID |
| number | Yes | Amount in major units (e.g. 1.23 for £1.23) |
| string | Yes | Transaction description |
| string | Yes | External reference or transaction ID |
Response
200 OK:
{
"result": "success",
"added_pence": 123,
"new_balance": "45.67"
}
400 Bad Request: Parameter validation failed or invalid account. Example:
{
"code": "invalid_parameters",
"message": "One or more required string parameters are empty after sanitization.",
"data": { "status": 400 }
}
Example
curl -X POST https://your-domain.com/wp-json/wc/zap/v1/add-credit \
-H "Authorization: Basic base64encoded" \
-H "Content-Type: application/json" \
-d '{
"account":"main",
"user_id":123,
"amount":1.23,
"description":"Promotional credit",
"reference":"TXN-789"
}'
3. Get Tickets
Method: GET
Endpoint:
/wc/zap/v1/get-ticketsPurpose: Retrieve ticket entries for a competition, optionally filtered by user, with pagination.
Request Parameters (query)
Name | Type | Required | Description |
|---|---|---|---|
| integer | Yes | ID of the competition product |
| integer | No | WordPress user ID |
| integer | No | Page number (default: 1) |
| integer | No | Items per page (default: 20) |
Response
200 OK:
{
"competition_id": 42,
"user_id": 123,
"sold_ticket_entries": [
{
"ticket_number": "ABC123",
"date_created": "2025-06-01T12:34:56"
// ... other ticket fields
},
…
],
"page": 1,
"per_page": 20,
"total_pages": 5,
"total_items": 100,
"price": "0.50",
"currency_symbol": "£",
"currency_code": "GBP"
}
Example
curl "https://your-domain.com/wp-json/wc/zap/v1/get-tickets?competition_id=42&user_id=123&page=1&per_page=20"
4. Get Instant Win Prizes
Method: GET
Endpoint:
/wc/zap/v1/instant-win-prizesPurpose: Fetch paginated list of instant-win prizes for a competition.
Request Parameters (query)
Name | Type | Required | Description |
|---|---|---|---|
| integer | Yes | ID of the competition product |
| integer | No | Page number (default: 1) |
| integer | No | Items per page (max: 100, default: 20) |
Response
200 OK:
{
"page": 1,
"per_page": 20,
"total_pages": 3,
"total_items": 45,
"items": [
{
"id": 1,
"product_id": 42,
"user_id": null,
"prize_meta": { /* ... */ }
// ... other prize table columns
},
…
]
}
Example
curl "https://your-domain.com/wp-json/wc/zap/v1/instant-win-prizes?competition_id=42&page=1&per_page=20"