Quickstart
Make your first API request and choose the audience for your integration.
Start by listing the audiences in your account. This request reads data and gives you the identifiers needed for subscriber operations.
Before you start
You need an Easymailing account, an API key and a terminal. Use the authentication guide to configure your credentials. For the JavaScript example, use Node.js 22 or later on your server.
Keep your API key in your backend environment. The public API is intended for server-side integrations; do not put the key in browser JavaScript.
1. Configure your API key
Set an environment variable, replacing the placeholder with your own key:
export EASYMAILING_API_KEY='YOUR_API_KEY'All examples in these guides use fictitious identifiers and data. Replace them with values from the account you intend to integrate.
2. List your audiences
Request JSON-LD so that the response includes collection metadata:
curl --silent --show-error --fail-with-body --get \
'https://api.easymailing.com/audiences' \
--header "X-Auth-Token: ${EASYMAILING_API_KEY}" \
--header 'Accept: application/ld+json' \
--data-urlencode 'page=1' \
--data-urlencode 'itemsPerPage=10'The endpoint returns HTTP 200 on success. This abbreviated response shows
the fields used in the next step; the identifiers and audience name are examples:
{
"hydra:member": [
{
"@id": "/audiences/11111111-1111-4111-8111-111111111111",
"uuid": "11111111-1111-4111-8111-111111111111",
"title": "Newsletter"
}
],
"hydra:totalItems": 1
}hydra:member contains the audiences on this page. If the collection spans
several pages, follow the pagination links as explained in
Pagination, filters and errors.
An empty hydra:member array means that this request returned no audiences.
Check that you are using the intended account before continuing.
3. Choose an audience
Match the audience by its title and confirm that it is the one your integration
should use. Save its uuid for route parameters such as audienceUuid.
Save its @id when another resource asks for an audience IRI.
For example, this UUID belongs in the URL when listing members:
GET /audiences/11111111-1111-4111-8111-111111111111/membersChoose the audience explicitly rather than automatically using the first result. See Core concepts for the relationship between audiences, members and identifiers.
Use JavaScript on your server
Save this as quickstart.mjs. It makes the same read request using Node's built-in
fetch; no SDK installation is required for this example.
const apiKey = process.env.EASYMAILING_API_KEY;
if (!apiKey || apiKey === 'YOUR_API_KEY') {
throw new Error('Set EASYMAILING_API_KEY to your account API key.');
}
const response = await fetch(
'https://api.easymailing.com/audiences?page=1&itemsPerPage=10',
{
headers: {
'X-Auth-Token': apiKey,
Accept: 'application/ld+json',
},
redirect: 'error',
signal: AbortSignal.timeout(15_000),
},
);
if (!response.ok) {
throw new Error(`List audiences failed: HTTP ${response.status}`);
}
const collection = await response.json();
if (!Array.isArray(collection['hydra:member'])) {
throw new Error('Expected a JSON-LD collection with hydra:member.');
}
for (const audience of collection['hydra:member']) {
console.log({
title: audience.title,
uuid: audience.uuid,
iri: audience['@id'],
});
}Run it from the same terminal where you set the environment variable:
node quickstart.mjsThe 15-second timeout is a choice in this example, not an API response-time guarantee. For HTTP failures, use the status and the endpoint reference to diagnose the request.
Continue your integration
- Create and sync subscribers using the audience you selected.
- Use an official SDK for Node.js / TypeScript or PHP.
- List audiences reference for the complete response schema.