Pagination, filters and errors
Read paginated collections, filter members and diagnose unsuccessful API requests.
Collection endpoints return one page at a time. Choose the response format, apply the filters your workflow needs and check each HTTP response before using its data.
This guide uses the List members endpoint. First choose an audience using the Quickstart.
Request a page
The audiences and members collection endpoints declare these pagination parameters:
| Parameter | Default | Use |
|---|---|---|
page | 1 | Select the collection page. |
itemsPerPage | 30 | Choose a positive page size, up to the documented maximum of 50. |
Those values apply to these endpoints. Check the reference before using the same limits for a different operation.
With EASYMAILING_API_KEY configured as in the Quickstart, set the audience UUID
you selected and request a page of confirmed email subscribers:
export EASYMAILING_AUDIENCE_UUID='11111111-1111-4111-8111-111111111111'curl --silent --show-error --fail-with-body --get \
"https://api.easymailing.com/audiences/${EASYMAILING_AUDIENCE_UUID}/members" \
--header "X-Auth-Token: ${EASYMAILING_API_KEY}" \
--header 'Accept: application/ld+json' \
--data-urlencode 'page=1' \
--data-urlencode 'itemsPerPage=50' \
--data-urlencode 'status=suscriber.status.confirmed'Read the resources from hydra:member. A pagination link, when present, appears
under hydra:view:
{
"hydra:view": {
"hydra:next": "/audiences/11111111-1111-4111-8111-111111111111/members?status=suscriber.status.confirmed&page=2&itemsPerPage=50"
}
}This excerpt only illustrates a next-page link. Follow the URL returned by the API, including its filters, rather than reconstructing it from this example.
Filter members
Member filters include email, phone, status, sms_status, groups and
subscription-source fields. Use URL encoding for values such as email addresses
and phone numbers.
| Filter | Detail to account for |
|---|---|
email | The endpoint describes partial matching. Compare returned addresses if you need an exact match, and account for additional pages. |
phone | Use the E.164 format documented by the endpoint; encode the leading +. |
status | Use the exact email status value, such as suscriber.status.confirmed. |
sms_status | Filters SMS subscription status independently of email. |
groups | Uses group UUIDs; when several are supplied, members must belong to all of them. Member write bodies use group IRIs instead. |
The status enum preserves the API's exact spellings:
| API value | Meaning |
|---|---|
suscriber.status.confirmed | Confirmed and active. |
suscriber.status.unconfirmed | Pending confirmation. |
suscriber.status.unsuscribed | Unsubscribed by the contact. |
suscriber.status.unsuscribed.admin | Cleaned. |
Labels such as “unsubscribed” are explanations; the filter value is the complete API string. The endpoint reference lists the available parameters and examples.
Follow pagination from Node.js
This Node.js 22+ example reads confirmed members one page at a time and prints
their UUIDs. It uses the built-in fetch and the same environment variables as
the cURL example.
const apiKey = process.env.EASYMAILING_API_KEY;
const audienceUuid = process.env.EASYMAILING_AUDIENCE_UUID;
if (!apiKey || !audienceUuid) {
throw new Error('Set EASYMAILING_API_KEY and EASYMAILING_AUDIENCE_UUID.');
}
const apiOrigin = 'https://api.easymailing.com';
const memberPath = `/audiences/${encodeURIComponent(audienceUuid)}/members`;
let pageUrl = new URL(memberPath, apiOrigin);
pageUrl.searchParams.set('page', '1');
pageUrl.searchParams.set('itemsPerPage', '50');
pageUrl.searchParams.set('status', 'suscriber.status.confirmed');
const visitedPages = new Set();
while (pageUrl) {
if (pageUrl.origin !== apiOrigin || pageUrl.pathname !== memberPath) {
throw new Error('Unexpected pagination destination.');
}
if (visitedPages.has(pageUrl.href)) {
throw new Error('The API returned a repeated pagination link.');
}
visitedPages.add(pageUrl.href);
const response = await fetch(pageUrl, {
headers: {
'X-Auth-Token': apiKey,
Accept: 'application/ld+json',
},
redirect: 'error',
signal: AbortSignal.timeout(15_000),
});
if (!response.ok) {
throw new Error(`List members failed: HTTP ${response.status}`);
}
const collection = await response.json();
const members = collection['hydra:member'];
if (!Array.isArray(members)) {
throw new Error('Expected a JSON-LD collection with hydra:member.');
}
for (const member of members) {
console.log(member.uuid);
}
const next = collection['hydra:view']?.['hydra:next'];
pageUrl = next ? new URL(next, pageUrl) : null;
}Run it with:
node list-members.mjsThe example stops when there is no next-page link. It checks the destination before attaching your API key, rejects redirects and repeated links, and stops on an unsuccessful response. The 15-second timeout is an example client setting.
For a synchronization job, persist progress and reconcile the records you have processed. Avoid assuming that several requests represent an unchanged snapshot of an audience while other systems are updating it.
Handle HTTP errors
Check the HTTP status before parsing a success response. JavaScript fetch
does not throw solely because a response has an error status; the examples
above check response.ok explicitly.
Use the status to decide what to inspect. The authentication layer can return
401; the audience and member operation references also list the relevant
input, permission and resource errors below:
| Status | Next step |
|---|---|
401 — Authentication failed | Check that the request includes the intended API key or bearer token and that the credentials are valid. |
400 — Invalid input | Inspect the request's format, parameters and body against that operation's schema. |
403 — Forbidden | Check the credentials, account and permission to access the requested resource. |
404 — Resource not found | On item operations, check the resource UUID and its audience. |
422 — Unprocessable entity | Check the response details and correct values that fail validation. |
The current reference does not define a common error-body schema for these
responses. Your error handler should retain the HTTP status and inspect the
returned Content-Type and body without assuming that every failure is JSON.
Redact API keys and personal data when recording diagnostics.
Use a bounded retry policy only for failures your integration can safely retry. Do not immediately repeat invalid requests or automatically replay a write whose outcome is unknown. In particular, a subscriber operation may also change subscription state or trigger an email; consult the subscriber guide before designing retries.