Resource Reference Introduction
How to access Siren's data through the REST API and PHP data layer. Covers authentication, base URLs, datastores, facades, and conventions.
Last updated: October 28, 2026
This section documents every resource in Siren and how to access it. Each resource page covers the data model, status lifecycle, and relationships in one place, with code examples showing both the REST API and the PHP data layer side by side. Individual REST endpoint pages provide detailed HTTP request and response formats.
REST API
Authentication
On WordPress, the API uses WordPress’s built-in authentication. Requests made through the WordPress admin (via the REST API nonce) are authenticated automatically. All endpoints require authentication unless otherwise noted. Most routes refuse a caller who isn’t signed in, or who lacks access, with 400 and {"error": {"message": "You don't have permission to do that.", "context": []}}. Event ingestion and plan checks answer 401 or 403 in WordPress’s own error shape instead. Response format shows each shape.
Base URL
All Siren endpoints are registered under the siren/v1 namespace using the WordPress REST API. The full URL pattern is:
https://your-site.com/wp-json/siren/v1/{endpoint}
If your site uses a custom REST API prefix or has pretty permalinks disabled, adjust accordingly. On Siren Cloud, the base URL is https://api.sirenaffiliates.com/siren/v1, and your code authenticates with an API key in Authorization: Bearer sk_live_.... A key reaches event ingestion, the ledger reads, webhooks, and records such as products, coupons, collaborators, and programs, each with its scope. Other routes answer 401 with the code api_key_not_accepted. The examples throughout this reference use the short form (GET /siren/v1/programs) without the site URL prefix.
Response format
Single-resource endpoints (get by ID, create, update) return the resource object directly as JSON with a 200 or 201 status code.
List endpoints return a JSON object with the rows in items, plus total, page, perPage, and totalPages. See Pagination, Filtering & Field Selection for the full pagination, sorting, and filtering system.
Errors return JSON with an HTTP status code. A simple error carries only a message:
{
"error": "Unknown event"
}
Most other errors put the message in an object with a context. On WordPress, this is also what most permission refusals look like:
{
"error": {
"message": "You don't have permission to do that.",
"context": []
}
}
Validation errors (status 400) list each failure in error.context.failedValidations. Every item has field, message, and type. A failed rule adds a context with the rule’s details, and a missing required field has no context. Several fields can fail at once, and one field can fail more than one rule:
{
"error": {
"message": "Validations failed.",
"context": {
"type": "VALIDATION_FAILED",
"failedValidations": [
{
"field": "collaboratorId",
"message": "collaboratorId is required.",
"type": "REQUIRED"
},
{
"field": "status",
"message": "status must be one of: draft, approved, rejected, complete, deleted, cancelled.",
"type": "REQUIRES_ANY",
"context": {
"validValues": ["draft", "approved", "rejected", "complete", "deleted", "cancelled"]
}
}
]
}
}
}
On WordPress, event ingestion and plan checks refuse in WordPress’s error shape, with code set to rest_not_logged_in for 401 or rest_forbidden for 403. A plan check’s message is “Your plan does not include this feature.”:
{
"code": "rest_forbidden",
"message": "Your plan does not include this feature.",
"data": {
"status": 403
}
}
An unexpected error answers 500 with a message and no context:
{
"error": {
"message": "An unexpected error occurred. Sorry, that is all I know."
}
}
On Siren Cloud, a refusal answers 401 when no credential was accepted, with “Authentication required.” when nobody signed in, or 403 otherwise. The body is {"error": {"message", "code", "context"}}. code is a stable value such as api_key_not_accepted, missing_scope, not_permitted, or plan_required, and it’s left out when there is none, as on a plain 401. Check the status first, then branch on code rather than the message. API Keys lists the codes a key can get. Cloud also answers 500 with “The request could not be completed, so nothing was saved. Please try again.” when a unit of work fails.
| Status | Meaning |
|---|---|
400 | Bad request. Validation failed, a required parameter is missing, or, on most WordPress routes, the caller isn’t signed in or lacks access |
401 | Unauthorized. On WordPress, event ingestion answers this when nobody is signed in, and WordPress itself answers it on any route when it refuses an application password |
403 | Forbidden. On WordPress, event ingestion and plan checks answer this when the user or the plan lacks access |
404 | Not found — the requested resource ID does not exist |
409 | Conflict. The request can’t be carried out in the record’s current state, such as permanently deleting an obligation a payout still includes |
500 | Internal server error |
REST conventions
Field selection. List and detail endpoints accept an optional fields query parameter naming the fields to include in the response. Without it, each endpoint returns its own default set. Asking for only what you need keeps responses lean and avoids expensive joins for fields you don’t need. Some fields are “extended” and only resolved when explicitly requested. Each resource’s documentation lists its available fields.
Filtering and search. List endpoints support filtering by resource-specific columns (like status or type) and text search via the s parameter. Filters use exact match by default. Passing comma-separated values creates an IN clause. See the pagination and filtering guide for details.
Two-stage deletion. Collaborators, programs, distributors, and conversions use a two-stage pattern. The first DELETE request sets the status to deleted, which puts the record in the Trash. A second DELETE request on a record already in the Trash deletes it permanently. Obligations go to cancelled first, and fulfillments to failed. Program groups, collaborator groups, custom currencies, and the other resources delete in one step. A permanent delete can be refused while money is still owed, with 409, or 422 for a collaborator. Each resource’s delete page says which pattern it uses.
Bulk actions. Several resources support bulk operations via a POST /siren/v1/{resource}/bulk endpoint. Bulk requests accept an action field and an ids array of at most 500 ids. A request with more answers 400 and processes none of them. Each resource’s documentation lists its supported bulk actions.
Owner scoping. Some endpoints (like obligations and reporting) automatically filter results based on the authenticated user’s role. Admin users see all records. Collaborator users only see records associated with their own collaborator ID. This scoping is transparent — the same endpoint serves both roles with different result sets.
Collaborator alias resolution. Several endpoints accept a collaboratorId parameter. Instead of passing a numeric ID, you can pass an alias reference in the format type:code, for example tracking:JNE or coupon:SAVE20. The middleware resolves the alias to the collaborator’s numeric ID before the request is processed. A coupon: reference names a collaborator only when every coupon with that code you can reach credits the same one and none of its copies is unlinked.
PHP data layer
When to access data directly
Siren is built on an event-driven architecture. Most records in the system are created as side effects of the normal event flow — a sale triggers a transaction, which triggers a conversion, which triggers an obligation. You should not manually create these records unless you have a specific reason to bypass the normal pipeline.
The most common reasons to access datastores directly are reading data for display or reporting, looking up records to make decisions in custom logic, and building migration scripts that import data from other systems. If you find yourself creating transactions, conversions, or obligations manually, consider whether firing the appropriate domain event would be more correct.
Accessing a datastore
There are two ways to access any datastore: dependency injection (for extensions and any code running inside Siren’s container) and facades (for external code like theme functions or standalone scripts).
use Siren\Programs\Core\Datastores\Program\Interfaces\ProgramDatastore;
class MyService
{
protected ProgramDatastore $programs;
public function __construct(ProgramDatastore $programs)
{
$this->programs = $programs;
}
public function getActivePrograms(): array
{
return $this->programs->where([
['type' => 'AND', 'clauses' => [
['column' => 'status', 'operator' => '=', 'value' => 'active']
]]
]);
}
} use Siren\Programs\Core\Facades\Programs;
$activePrograms = Programs::andWhere([
['column' => 'status', 'operator' => '=', 'value' => 'active']
]);
$program = Programs::find(42); Dependency injection is the preferred approach for extension code because it makes dependencies explicit and testable. Facades are convenient for one-off scripts, theme functions, or any code running outside Siren’s initializer pipeline. If you find yourself using a facade inside extension code, that usually means the class isn’t properly wired through the initializer system.
Standard datastore methods
Siren’s datastores are built on PHPNomad’s datastore system. The two methods you’ll use most often are find() for fetching a single record by primary key and andWhere() for querying records with filter conditions. Both return model instances.
// Fetch a single program by ID. Throws RecordNotFoundException if missing.
$program = $programs->find(42);
// Query with filter conditions. Returns an array of models.
$active = $programs->andWhere([
['column' => 'status', 'operator' => '=', 'value' => 'active']
]);
For writes, create() accepts an associative array of attributes and returns the new model. update() takes a primary key and an array of changed attributes. delete() removes a record by primary key.
Filters use structured arrays with column, operator, and value keys. Supported operators are =, !=, >, <, >=, <=, LIKE, NOT LIKE, IN, and NOT IN. You can pass multiple clauses to andWhere() and they combine with AND logic.
// Multiple conditions
$filtered = $programs->andWhere([
['column' => 'status', 'operator' => '=', 'value' => 'active'],
['column' => 'incentiveType', 'operator' => '=', 'value' => 'saleTransactionPercentage']
]);
// IN clause
$specific = $programs->andWhere([
['column' => 'id', 'operator' => 'IN', 'value' => [1, 2, 3]]
]);
Counting works with count() and countAndWhere(), which accept the same filter formats but return an integer instead of model arrays.
Some datastores have additional domain-specific methods documented on their individual resource pages.
Resources
Each page in this section covers one resource, including the data model, access patterns (REST and PHP), and relationships to other resources. The resources follow the data flow through Siren’s attribution pipeline:
Programs define the incentive rules. Program groups bundle related programs so only one fires per conversion. Collaborators are the affiliates, partners, or participants who earn rewards. Collaborator groups cluster collaborators under a structure that programs and distributors bind to so cascade calculations can walk the group and credit peers.
When a customer interacts with a collaborator’s referral link or coupon, Siren creates opportunities to track the visitor and engagements to record confirmed attribution. If that customer completes a tracked action, a conversion is created linking the engagement to a transaction.
Each conversion that earns a reward generates an obligation, which becomes payable when the conversion is approved. When it’s time to pay, obligations are grouped into fulfillments and payouts.
For scheduled reward systems based on aggregate metrics, distributors and distributions handle the configuration and execution.
Supporting resources include aliases for tracking codes and coupon codes, coupons and products for the codes and products your stores send, mappings for bridging Siren IDs with external platform IDs, and configs for the key-value configuration system. The enums and constants reference lists the string identifiers used throughout the system. The reporting endpoint provides aggregated analytics. Notes are the activity-feed entries that lifecycle events write and link to the records they touch.
For a complete list of all REST endpoints, see the All REST Endpoints reference.