API Reference Get Unsubscribe Link
Get Unsubscribe Link
Look up what an unsubscribe link from a Syntext email covers.
Session token
Returns what an unsubscribe link applies to and the person's current categories, so an unsubscribe page can show them before anything changes. Nothing is changed by this call.
Note
Public — no credential needed. The signed token in the email's link is the credential, and it names the person. Rate limited to 30 requests a minute per IP address, shared with Unsubscribe.
Unsubscribe tokens don't expire, so a link in an old email keeps working.
Query Parameters
NameDescription
tokenThe token from the unsubscribe link in the email.
Response — 200 OK
NameDescription
emailThe address, masked to its first character and domain — enough to recognise, not to harvest.
scopeWhat the link was for: one category (
product_tips, account_nudges, reports, news or account), or all. An account reminder's link is for account.categoriesOne boolean per category — the four product email categories and
account (account reminders) — true when the person still gets it.unsubscribedAlltrue when the person has already unsubscribed from all — product email and account reminders.Error Responses
400 Bad Request
invalid_token — the token is missing, altered, or belongs to an account that no longer exists.
json
{
"error": {
"code": "invalid_token",
"message": "This unsubscribe link is not valid.",
"details": { "traceId": "6f1c2a9e-3b7d-4c11-9a0e-2d5f8b4c7e10" }
}
}
429 Too Many Requests
rate_limited — more than 30 requests in a minute from one IP address. Try again in a minute.
503 Service Unavailable
not_configured — unsubscribe links aren't available right now.
Was this page helpful? Yes No
Previous
Next
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl "https://api.syntext.dev/v1/email/unsubscribe?token=$UNSUBSCRIBE_TOKEN"
// A browser has no environment variables: set these to your values.
const UNSUBSCRIBE_TOKEN = '<UNSUBSCRIBE_TOKEN>';
const response = await fetch(`https://api.syntext.dev/v1/email/unsubscribe?token=${UNSUBSCRIBE_TOKEN}`, {
method: 'GET',
});
const data = await response.json();
console.log(response.status, data);
import os
import requests
url = f"https://api.syntext.dev/v1/email/unsubscribe?token={os.environ['UNSUBSCRIBE_TOKEN']}"
response = requests.get(url)
print(response.status_code)
print(response.json())
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("GET", "https://api.syntext.dev/v1/email/unsubscribe?token="+os.Getenv("UNSUBSCRIBE_TOKEN"), nil)
if err != nil {
panic(err)
}
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.Status)
fmt.Println(string(body))
}
require "net/http"
require "uri"
uri = URI("https://api.syntext.dev/v1/email/unsubscribe?token=#{ENV.fetch("UNSUBSCRIBE_TOKEN")}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Get.new(uri)
response = http.request(request)
puts response.code
puts response.body
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.syntext.dev/v1/email/unsubscribe?token=' . getenv('UNSUBSCRIBE_TOKEN'),
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
echo $status, PHP_EOL, $response, PHP_EOL;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.syntext.dev/v1/email/unsubscribe?token=" + System.getenv("UNSUBSCRIBE_TOKEN")))
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.syntext.dev/v1/email/unsubscribe?token=" + Environment.GetEnvironmentVariable("UNSUBSCRIBE_TOKEN"));
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Responseapplication/json
200OK
{
"data": {
"email": "a***@example.com",
"scope": "reports",
"categories": {
"product_tips": true,
"account_nudges": true,
"reports": true,
"news": true,
"account": true
},
"unsubscribedAll": false
}
}