Skip to main content
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>"
}
'
{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
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

email
string
required
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}`;
}

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..."
}
The subscriber must already exist in Sequenzy. If the subscriber doesn’t exist, create them first using the Create Subscriber endpoint.