Skip to content

Get recommendations

There are two recommendation paths. Both take the same query parameters and answer the same JSON. They differ in who calls them and how the user is named.

Path Use it from Credential
GET /edgekit/v1/recommendations Your pages, in the browser, on your own domain x-edgekit-site-id and the origin
GET /v1/recommendations Your server, and Braze Connected Content An API key pinned to one site

The server path is in the client API reference.

Each request asks about one subject: a signed-in user or an anonymous device.

On the browser path:

  1. The signed-in user, from their EdgeKit session. At a site whose id mode is external_only, the EdgeKit session is ignored and this step is skipped. See Choose who signs users in.
  2. Otherwise the device your page names in domainUserId. EdgeKit asks Personalization about the device under its own device id, so a domainUserId never reads a user’s recommendations, even one that holds a user id.
  3. Neither: the answer is 200 with recommId: null and items: [], and Personalization is not called.

A userId parameter on the browser path is ignored.

On the server path:

  1. userId, taken at face value. Take it from a sign-in your server has checked, never from a value on the incoming request.
  2. Otherwise domainUserId, as a device, as above.
  3. Neither, or an empty userId= with no domainUserId: an empty 200, and Personalization is not called.

The site is the API key’s site. The server path reads no site header.

On either path, a request for a user or device your Personalization database does not hold yet creates it there.

Your page needs the device id the tracker keeps. The tracker from @edgekitcloud/analytics-browser takes Snowplow plugins, and a plugin receives the Snowplow tracker, which has getDomainUserId(). Call the browser path on your own domain, so the sign-in cookie goes with the request:

import {
type BrowserTracker,
createTracker,
} from '@edgekitcloud/analytics-browser';
let tracker: BrowserTracker | undefined;
const analytics = createTracker({
siteId: 'site_example',
plugins: [
{
activateBrowserPlugin: (instance) => {
tracker = instance;
},
},
],
});
analytics.trackPageView();
const query = new URLSearchParams({
scenario: 'read-next',
count: '4',
item: 'ABCDEF1234567890',
});
const domainUserId = tracker?.getDomainUserId();
if (domainUserId) {
query.set('domainUserId', domainUserId);
}
const response = await fetch(`/edgekit/v1/recommendations?${query}`, {
credentials: 'include',
headers: { 'x-edgekit-site-id': 'site_example' },
});
const { items } = await response.json();

The browser path checks the site and the origin as every browser path does. See Select a site on a request and Mount /edgekit/ on your domain.

Terminal window
curl 'https://<tenant>.edgekit.ai/v1/recommendations?scenario=for-you&count=5&userId=0199a4c2-7b1e-7c3d-9a4f-2e8b5d6c1a90&section=/news&section=/business' \
-H 'Authorization: Bearer ek_your_key'
const query = new URLSearchParams({ scenario: 'for-you', count: '5', userId });
query.append('section', '/news');
query.append('section', '/business');
query.append('excludeTag', 'sponsored');
const response = await fetch(
`https://<tenant>.edgekit.ai/v1/recommendations?${query}`,
{ headers: { 'x-api-key': process.env.EDGEKIT_API_KEY! } },
);
const { recommId, items } = await response.json();
Parameter Required What it does
scenario Yes The name of a scenario in your Personalization database, 1 to 200 characters. EdgeKit passes it through
count No How many items, 1 to 20. Default 5
item No The CMS id of the item being read, up to 200 characters. Asks for items to read after this one, for this subject (“read next”), instead of items for the subject alone. An empty value is refused
sourceSystem No The source key of the content source item is from, for example wordpress or news. Leave it out for an item of the source whose source key is arcxp. Only its shape is checked, see below
userId No Server path only: the EdgeKit user id, up to 200 characters
domainUserId No The device id from the tracker, up to 200 characters. Read when no user is
edition No Never read, up to 200 characters. It makes a URL unique, so the server path’s stored answer is shared within one newsletter edition. See Caching

An item is read only when there is a subject: with no user and no device, the answer is empty whatever item says.

A sourceSystem is checked for the shape of a source key only: lowercase letters, digits and single hyphens, up to 64 characters. Any other value is refused with 422. A well-formed key that names none of your content sources is not refused: EdgeKit does not look the source up, and asks Personalization for the item under that key as written.

Every request recommends only items on the request’s site that are not deleted. These parameters narrow that set further:

Parameter Keeps
section Items in any of these sections
tag Items with any of these tags
author Items by any of these authors
contentType Items of any of these types
language Items in any of these languages
excludeSection No item in any of these sections
excludeTag No item with any of these tags
excludeContentType No item of any of these types
publishedAfter Items published at or after this time
publishedBefore Items published at or before this time
excludeAlreadyRead true: no item among the subject’s latest 500 detail views
  • Repeat a parameter for several values: section=/news&section=/business. Values of one parameter are OR-ed, and different parameters are AND-ed. Up to 200 values per parameter.
  • Values match exactly. A section matches only that section, so list each subsection you want. Sections, tags and authors are the ids your CMS gives them. A language matches only that code, so list en and en-GB to get both.
  • A value is 1 to 200 characters and may not hold a double quote, a backslash or a control character. A value that does is refused with 422.
  • publishedAfter and publishedBefore are ISO 8601 timestamps in UTC, such as 2026-10-17T06:00:00Z. They compare with the item’s published_at: its first publication, else its display date. See Item properties.
  • excludeAlreadyRead needs already-read filtering. EdgeKit must first turn on already-read filtering for your database; ask EdgeKit before a request uses it. Until then, every request that sets it fails.
  • Your scenario’s own filters still apply. Personalization adds them on top of these. If the two contradict each other, the answer is empty.
{
"recommId": "0b4f3c2e-8d1a-4f6b-9c3e-2a7d5e1f4b60",
"items": [
{
"id": "ABCDEF1234567890",
"sourceSystem": null,
"headline": "The headline",
"description": "Why it matters.",
"image": "https://www.example.com/images/story.jpg",
"url": "https://www.example.com/news/2026/10/17/story?recomm_id=0b4f3c2e-8d1a-4f6b-9c3e-2a7d5e1f4b60",
"publishedAt": "2026-10-17T06:30:00.000Z"
}
]
}
  • recommId is the id of this answer, or null when there was no subject to ask about.
  • items are best first. Each id is the item’s CMS id, and sourceSystem is its content source’s source key, or is null for an item of the source whose source key is arcxp. Send both back as item and sourceSystem to ask what to read next. See Item ids.
  • url is the item’s canonical URL with recomm_id added, keeping any query the URL already has. Link to it as it is: the next page’s events carry the id back to Personalization, and that attributes the click. The id is in the URL itself, so it reaches the next page from an email too.
  • Every field but id can be null, url included, when the catalog holds no value for it. Skip an item with no url.

The fields are what EdgeKit last sent to your Personalization catalog. Answering reads none of your content items.

  • The browser path is never cached. It answers Cache-Control: private, no-store and Vary: Cookie, and every request asks Personalization.
  • The server path keeps each answer for up to 15 minutes, keyed on the full request URL and the API key’s site. A repeat of exactly the same URL with a key for the same site can get the same items and the same recommId, with no call to Personalization. Parameters in another order make another URL. A failed request is not kept.

The newsletter’s edition parameter uses this: Braze renders a message’s HTML, plain-text and AMP parts separately, and the shared URL gives them the same answer.

Every error has the standard body, { "error": { "code", "message" } }. Your page or template renders its own fallback: EdgeKit has none.

Status Code Message Cause
400 bad_request Missing site id. Browser path, with no x-edgekit-site-id.
401 unauthorized Missing API key. Server path, with no key.
401 unauthorized Invalid or missing API key. Server path, with a key that is unknown, revoked or expired.
403 forbidden This origin is not allowed for the selected site. Browser path, from an origin the site does not allow.
404 not_found Unknown site. The site, from the header or the key, is unknown, disabled or not yet deployed.
422 unprocessable_entity Request validation failed. A parameter is missing or out of range: no scenario, a count outside 1 to 20, a refused filter value. details says which.
422 unprocessable_entity Unknown scenario. Your Personalization database has no scenario with that name.
500 internal_error Something went wrong. Personalization refused the request for any other reason.
503 service_unavailable Recommendations are briefly unavailable. Personalization did not answer within about a second, throttled the request or failed. Carries Retry-After: 60.
503 service_unavailable Recommendations are not configured. Personalization is not set up for your organization. No Retry-After: retrying does not help.
  • No rate limit on either path. The browser path checks the origin and nothing more, and a client outside a browser can call it.
  • Every request that reaches Personalization counts toward your organization’s Personalization usage and limits. An answer the server path serves from its stored copy does not.
  • Up to 20 items per request, and about a second for Personalization to answer.

edgekit.ai