Subscribe a profile or update its subscriptions
- Path
/subscribe- Auth
- Secret key · server only
const url = 'https://releva.ai/api/v0/subscribe';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"email":"maria@example.com","firstName":"Maria","lastName":"Example","subscriptions":["marketing"],"tags":["footer-form"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://releva.ai/api/v0/subscribe \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "email": "maria@example.com", "firstName": "Maria", "lastName": "Example", "subscriptions": [ "marketing" ], "tags": [ "footer-form" ] }'Marks the profile as subscribed and updates its subscriptions, creating the profile if the email or
phone number is unknown. Call it from your server only: it uses your secret key.
subscriptions replaces the profile’s list unless addSubscriptions is true; removeSubscriptions
removes entries. If the profile ends up with none of your shop’s user-visible subscriptions and was not
subscribed before (or the request names none), all user-visible subscriptions are added.
tags are added to the profile’s tags. Unknown fields are ignored.
The profile is written before the response is sent; the resulting subscribe or
subscriptionsChanged event is recorded asynchronously.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Send at least one of email or phoneNumber. Unknown fields are ignored.
object
YYYY-MM-DD exactly.
Replaces the profile’s subscriptions, or is added to them when addSubscriptions is true.
Add subscriptions to the current list instead of replacing it.
Subscriptions to remove (also removes the label form of a user-visible subscription).
Absolute URL; per-profile unsubscribe link used when subscription management is External.
ISO 639-1 code. Used by /subscribe/request in Wait for confirmation mode.
Releva profile id (the rlv_u cookie on the frontend).
Added to the profile’s tags.
Answer 409 instead of subscribing when the email has been subscribed or unsubscribed before.
Links the event to the message or campaign that caused it. All values are ids as strings.
object
Example
{ "email": "maria@example.com", "firstName": "Maria", "lastName": "Example", "subscriptions": [ "marketing" ], "tags": [ "footer-form" ]}Responses
Section titled “Responses”Subscribed. userId is the profile id. If neither email nor phoneNumber is sent, nothing is
written and the body is {}.
object
The profile id. Absent when no identifier was sent.
Example
{ "userId": "DEMO-CUST-1001"}Authentication or validation error.
object
Human-readable error. Several validation errors are joined with a space.
Examples
{ "message": "Authorization header is missing."}{ "message": "Domain with the provided secret key cannot be found."}{ "message": "The 'email' field must be a valid e-mail."}{ "message": "phoneNumber must be a valid telephone number starting with + and international code, e.g. +1. Got 12ab instead."}{ "message": "The 'subscriptions' field must be an array."}{ "message": "The 'addSubscriptions' field must be a boolean."}{ "message": "The 'unsubscribeLink' field must be a valid URL."}{ "message": "locale must be a valid ISO-639-1 code! Got english instead."}{ "message": "The 'attributions.campaignId' field must be a string."}{ "message": "The '' field is required."}The domain is disabled.
object
Human-readable error. Several validation errors are joined with a space.
Example
{ "message": "Domain is disabled. Please reach out to support@releva.ai to enable it."}rejectAlreadySubscribed was set and the email has been subscribed or unsubscribed before. Nothing was written.
object
Example
{ "code": "alreadySubscribed"}Request body larger than 800 KB.
object
Human-readable error. Several validation errors are joined with a space.
Example
{ "message": "request entity too large"}