Subscribe from the browser (double opt-in aware)
- Path
/subscribe/request- Auth
- Access token · browser or app
const url = 'https://releva.ai/api/v0/subscribe/request';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"email":"maria@example.com","firstName":"Maria","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/request \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "email": "maria@example.com", "firstName": "Maria", "subscriptions": [ "marketing" ], "tags": [ "footer-form" ] }'Browser-safe subscribe, authenticated with your access token; the Releva SDK’s requestSubscribe calls it.
With Subscription Request Behavior “Subscribe right away” it subscribes like POST /subscribe
(event tagged request) and returns 200 with the profile id; an existing profile with the same email or
phone number wins over the userId you send. With “Wait for confirmation” it stores the contact
details, records a subscribeRequest event and returns 202 {}; the shopper is subscribed when they open
the {{subscribeLink}} from your confirmation email.
Failed requests with rejectAlreadySubscribed are limited to 30 per 15 minutes per IP.
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", "subscriptions": [ "marketing" ], "tags": [ "footer-form" ]}Responses
Section titled “Responses”Subscribed right away.
object
The profile id. Absent when no identifier was sent.
Example
{ "userId": "DEMO-CUST-1001"}Accepted for asynchronous processing.
object
Example
{}Authentication or validation error.
object
Human-readable error. Several validation errors are joined with a space.
Examples
{ "message": "Authorization header is missing, and accessToken url parameters is also missing. At least one of them is required."}{ "message": "The access token you provided is invalid."}{ "message": "Domain with the provided access token cannot be found."}{ "message": "The 'email' field must be a valid e-mail."}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"}Too many rejected requests from this IP.