Replace one person’s standing on this site
const url = 'https://your-tenant-host/v1/newsletters/subscriptions';const options = { method: 'PUT', headers: { 'x-edgekit-site-id': 'site_example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"subscribed":["01999b1e-7a40-7c2d-9e51-2a4c8d0f6b31"],"email":"subscriber@example.com","userId":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://your-tenant-host/v1/newsletters/subscriptions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'x-edgekit-site-id: site_example' \ --data '{ "subscribed": [ "01999b1e-7a40-7c2d-9e51-2a4c8d0f6b31" ], "email": "subscriber@example.com", "userId": "example" }'Full replacement, not a patch. Anything this site deploys and subscribed omits becomes unsubscribed. One exception: a list currently pending stays pending, named or omitted. The response echoes the full resulting set, so the client sees everything the replacement changed. 202 rather than 200 when anything is left awaiting confirmation: a fresh confirmation email has just gone out and the standing is not final. Every other outcome is 200. The anonymous path, an email and no credential, adds and never removes: an omitted list is left as it is. Its echo is what a never-seen address would get (named lists pending or subscribed, the rest unknown), whether or not the address already belonged to a user. Removing a standing needs an EdgeKit session, a verified upstream credential, or a site-pinned API key. Safe to retry: a repeat converges on the same standing, but re-sends the confirmation for every list still pending.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.
Example
site_exampleThe site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Full replacement: the list ids that should end up subscribed. Anything this site deploys and this array omits becomes unsubscribed, with one exception: a list currently pending stays pending whether it is named or omitted, because a replacement does not resolve a state the subscriber never answered. An empty array is a complete unsubscribe, allowed under a credential that names the user. With only an email, omission removes nothing: that path only adds, and the echo answers unknown for whatever it did not name.
Example
[ "01999b1e-7a40-7c2d-9e51-2a4c8d0f6b31"]The only way the anonymous browser path names a subject. The address resolves to its existing user, or creates one. A 400 when the credential already names a user: an EdgeKit session or a verified upstream credential already says who this is, and accepting a second answer would let the page write to somebody else unnoticed.
Example
subscriber@example.comAllowed only when the credential is an API key; a 400 otherwise, never ignored. Dropping an identity assertion with no error would let a server-side integration write to the wrong user unnoticed.
Responses
Section titled “Responses”The full resulting set. Nothing is awaiting confirmation.
object
Every deployed list for the site, including those this person has no record on. On a PUT this is the full resulting set, which shows what a full replacement removed: a client that renders four lists and sends four ids has just unsubscribed the fifth.
object
The list’s id (UUIDv7). A list is named by its id, never by its slug.
^[a-z][a-z0-9_]*$, unique per site: two sites in one organization can both run a morning_briefing, so it is not unique per tenant.
What a preference centre renders and what the confirmation email says it is confirming. Tenant-authored, staged and deployed.
A sentence, or null. Shown in the confirmation email beside the label; without it, somebody subscribing to two lists gets two identical emails.
unknown means EdgeKit has no record of this person on this list. pending is double opt-in’s: the address was given and the confirmation link has not been clicked yet. A pending address is never sent to the delivery vendor. Open: render an unknown member as unknown.
Example
{ "subscriptions": [ { "id": "01999b1e-7a40-7c2d-9e51-2a4c8d0f6b31", "slug": "morning_briefing", "label": "The Morning Briefing", "status": "subscribed" } ]}The full resulting set, with at least one list pending. A confirmation email carrying a fresh link has been sent for each.
object
Every deployed list for the site, including those this person has no record on. On a PUT this is the full resulting set, which shows what a full replacement removed: a client that renders four lists and sends four ids has just unsubscribed the fifth.
object
The list’s id (UUIDv7). A list is named by its id, never by its slug.
^[a-z][a-z0-9_]*$, unique per site: two sites in one organization can both run a morning_briefing, so it is not unique per tenant.
What a preference centre renders and what the confirmation email says it is confirming. Tenant-authored, staged and deployed.
A sentence, or null. Shown in the confirmation email beside the label; without it, somebody subscribing to two lists gets two identical emails.
unknown means EdgeKit has no record of this person on this list. pending is double opt-in’s: the address was given and the confirmation link has not been clicked yet. A pending address is never sent to the delivery vendor. Open: render an unknown member as unknown.
Example
{ "subscriptions": [ { "id": "01999b1e-7a40-7c2d-9e51-2a4c8d0f6b31", "slug": "morning_briefing", "label": "The Morning Briefing", "status": "subscribed" } ]}Invalid request.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Missing or invalid credential.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Not allowed.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Resource not found.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Request validation failed.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Too many requests. Retry-After says when to retry.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Unexpected error.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}With Retry-After, briefly unavailable; without it, not configured.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}