Skip to content

Area: Developers

POST

Register a browser push subscription

Path
/pushSubscriptions/{accessToken}
Auth
Access token · browser or app, or in the URL path
POST
/pushSubscriptions/{accessToken}
curl --request POST \
--url https://releva.ai/api/v0/pushSubscriptions/YOUR_ACCESS_TOKEN \
--header 'Content-Type: application/json' \
--data '{ "context": { "deviceId": "demo-browser-device-0001", "profile": { "id": "DEMO-CUSTOMER-1001", "email": "maria@example.com" } }, "subscription": { "endpoint": "https://push.example.com/send/demo-subscription-0001", "expirationTime": null, "keys": { "p256dh": "BDemoP256dhKeyForDocsOnly000000000000000000000000000000000000000000000000000000000000", "auth": "DemoAuthSecret0000000A" } } }'

Stores a browser’s Web Push subscription (PushSubscription.toJSON()) for a device and links the device to the profile. The Releva JS SDK calls it after the visitor allows notifications, when Releva.push is called with the serviceWorkerUrl option; subscribe with the VAPID key from push.vapidPublicKey in the Releva.push response. The access token goes in the path (no pre-flight); an authorization header, if present, takes precedence. JSON or form-encoded (formPayload = base64 of the URI-encoded JSON). Writes a pushNotificationSubscribe event, which can trigger campaigns.

accessToken
required
string format: uuid

The shop’s public access token (UUID). Ignored when an authorization header is sent.

Example

YOUR_ACCESS_TOKEN
object
context
required
object
deviceId

Browser device id (SDK cookie rlv_p).

string
profileId

Used as deviceId when deviceId is missing.

string
sessionId
string
group

Control-group bucket. Default 9999.

number
<= 9999
profile
object
id

Your customer id.

string
email
string format: email
phoneNumber

International format with + and country code; normalised with the shop country code first.

string
key
additional properties
any
key
additional properties
any
subscription
required
object
endpoint
required
string format: uri
expirationTime

A number (what some browsers return) is rejected with 400.

string | null
keys
required
object
auth
required
string
p256dh
required
string

Example

{
"context": {
"deviceId": "demo-browser-device-0001",
"profile": {
"id": "DEMO-CUSTOMER-1001",
"email": "maria@example.com"
}
},
"subscription": {
"endpoint": "https://push.example.com/send/demo-subscription-0001",
"expirationTime": null,
"keys": {
"p256dh": "BDemoP256dhKeyForDocsOnly000000000000000000000000000000000000000000000000000000000000",
"auth": "DemoAuthSecret0000000A"
}
}
}

Accepted for asynchronous processing.

Media typeapplication/json
object
0

Example

{}

Authentication or validation error.

Media typeapplication/json
object
message
required

Human-readable error. Several validation errors are joined with a space.

string

Examples

{
"message": "context is missing from request body"
}

The domain is disabled.

Media typeapplication/json
object
message
required

Human-readable error. Several validation errors are joined with a space.

string

Example

{
"message": "Domain is disabled. Please reach out to support@releva.ai to enable it."
}

Request body larger than 800 KB.

Media typeapplication/json
object
message
required

Human-readable error. Several validation errors are joined with a space.

string

Example

{
"message": "request entity too large"
}

Unexpected server error.

Media typeapplication/json
object
message
required

Human-readable error. Several validation errors are joined with a space.

string

Example

{
"message": "An internal error occurred."
}