Widgets
Get Preferences Token
Generate a signed token to embed the subscription preferences widget
POST
/
api
/
v1
/
widgets
/
preferences
/
token
Get Preferences Token
curl --request POST \
--url https://api.sequenzy.com/api/v1/widgets/preferences/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>"
}
'import requests
url = "https://api.sequenzy.com/api/v1/widgets/preferences/token"
payload = { "email": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({email: '<string>'})
};
fetch('https://api.sequenzy.com/api/v1/widgets/preferences/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sequenzy.com/api/v1/widgets/preferences/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sequenzy.com/api/v1/widgets/preferences/token"
payload := strings.NewReader("{\n \"email\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sequenzy.com/api/v1/widgets/preferences/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sequenzy.com/api/v1/widgets/preferences/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid email format"
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Subscriber not found"
}
}
{
"success": false,
"error": {
"code": "SERVER_ERROR",
"message": "Server configuration error"
}
}
Generate a signed token that allows you to embed the subscription preferences widget on your website. This widget lets users manage their email subscription preferences directly from your application.
Security: Call this endpoint from your backend only. Never expose your API
key to the frontend. The token is valid for 1 hour.
Request Body
The subscriber’s email address. Must be a valid email of an existing
subscriber.
Example
import Sequenzy from "sequenzy";
const client = new Sequenzy("YOUR_API_KEY");
const { data, error } = await client.widgets.preferences.generateToken({
email: "user@example.com",
});
if (data) {
// Use the token in your frontend iframe
const widgetUrl = `https://sequenzy.com/embed/preferences?token=${data.token}`;
}
curl -X POST "https://api.sequenzy.com/api/v1/widgets/preferences/token" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'
Using the Token
Once you have the token, embed the widget in your frontend:<iframe
src="https://sequenzy.com/embed/preferences?token={TOKEN}"
width="100%"
height="400"
frameborder="0"
style="border: none; max-width: 500px;"
></iframe>
<script>
// Auto-resize iframe based on content
window.addEventListener("message", function (e) {
if (e.data.type === "sequenzy-preferences-resize") {
var iframe = document.querySelector('iframe[src*="/embed/preferences"]');
if (iframe) iframe.style.height = e.data.height + "px";
}
});
</script>
Responses
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid email format"
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Subscriber not found"
}
}
{
"success": false,
"error": {
"code": "SERVER_ERROR",
"message": "Server configuration error"
}
}
The subscriber must already exist in Sequenzy. If the subscriber doesn’t
exist, create them first using the Create
Subscriber endpoint.
⌘I
Get Preferences Token
curl --request POST \
--url https://api.sequenzy.com/api/v1/widgets/preferences/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>"
}
'import requests
url = "https://api.sequenzy.com/api/v1/widgets/preferences/token"
payload = { "email": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({email: '<string>'})
};
fetch('https://api.sequenzy.com/api/v1/widgets/preferences/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sequenzy.com/api/v1/widgets/preferences/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sequenzy.com/api/v1/widgets/preferences/token"
payload := strings.NewReader("{\n \"email\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sequenzy.com/api/v1/widgets/preferences/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sequenzy.com/api/v1/widgets/preferences/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid email format"
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Subscriber not found"
}
}
{
"success": false,
"error": {
"code": "SERVER_ERROR",
"message": "Server configuration error"
}
}