Nadaj zgodę na temat
curl --request POST \
--url https://api.railmail.app/api/v1/subscribers/{email}/consents \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"topicKey": "APIT-1",
"source": "preference-center",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"sourceUrl": "https://shop.example.com/prefs",
"consentText": "I agree to receive the newsletter",
"formVersion": "v3"
}
'import requests
url = "https://api.railmail.app/api/v1/subscribers/{email}/consents"
payload = {
"topicKey": "APIT-1",
"source": "preference-center",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"sourceUrl": "https://shop.example.com/prefs",
"consentText": "I agree to receive the newsletter",
"formVersion": "v3"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
topicKey: 'APIT-1',
source: 'preference-center',
ipAddress: '203.0.113.10',
userAgent: 'Mozilla/5.0',
sourceUrl: 'https://shop.example.com/prefs',
consentText: 'I agree to receive the newsletter',
formVersion: 'v3'
})
};
fetch('https://api.railmail.app/api/v1/subscribers/{email}/consents', 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.railmail.app/api/v1/subscribers/{email}/consents",
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([
'topicKey' => 'APIT-1',
'source' => 'preference-center',
'ipAddress' => '203.0.113.10',
'userAgent' => 'Mozilla/5.0',
'sourceUrl' => 'https://shop.example.com/prefs',
'consentText' => 'I agree to receive the newsletter',
'formVersion' => 'v3'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.railmail.app/api/v1/subscribers/{email}/consents"
payload := strings.NewReader("{\n \"topicKey\": \"APIT-1\",\n \"source\": \"preference-center\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"sourceUrl\": \"https://shop.example.com/prefs\",\n \"consentText\": \"I agree to receive the newsletter\",\n \"formVersion\": \"v3\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.railmail.app/api/v1/subscribers/{email}/consents")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"topicKey\": \"APIT-1\",\n \"source\": \"preference-center\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"sourceUrl\": \"https://shop.example.com/prefs\",\n \"consentText\": \"I agree to receive the newsletter\",\n \"formVersion\": \"v3\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.railmail.app/api/v1/subscribers/{email}/consents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"topicKey\": \"APIT-1\",\n \"source\": \"preference-center\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"sourceUrl\": \"https://shop.example.com/prefs\",\n \"consentText\": \"I agree to receive the newsletter\",\n \"formVersion\": \"v3\"\n}"
response = http.request(request)
puts response.read_body{
"topicKey": "APIT-1",
"status": "PENDING_CONFIRMATION",
"requiresConfirmation": true,
"grantedAt": "2026-06-24T10:20:00Z",
"confirmedAt": null,
"tokenExpiresAt": "2026-06-26T10:20:00Z"
}Zgody
Nadaj zgodę na temat
Zapisuje istniejącego subskrybenta do tematu. Jeśli temat korzysta z double opt-in, zgoda jest tworzona jako PENDING_CONFIRMATION (requiresConfirmation: true), a subskrybent musi ją potwierdzić przez e-mail, zanim zostanie zapisany. Wymagany zakres: consents:manage. Dzierżawa: ograniczone do projektu klucza API.
POST
/
api
/
v1
/
subscribers
/
{email}
/
consents
Nadaj zgodę na temat
curl --request POST \
--url https://api.railmail.app/api/v1/subscribers/{email}/consents \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"topicKey": "APIT-1",
"source": "preference-center",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"sourceUrl": "https://shop.example.com/prefs",
"consentText": "I agree to receive the newsletter",
"formVersion": "v3"
}
'import requests
url = "https://api.railmail.app/api/v1/subscribers/{email}/consents"
payload = {
"topicKey": "APIT-1",
"source": "preference-center",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"sourceUrl": "https://shop.example.com/prefs",
"consentText": "I agree to receive the newsletter",
"formVersion": "v3"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
topicKey: 'APIT-1',
source: 'preference-center',
ipAddress: '203.0.113.10',
userAgent: 'Mozilla/5.0',
sourceUrl: 'https://shop.example.com/prefs',
consentText: 'I agree to receive the newsletter',
formVersion: 'v3'
})
};
fetch('https://api.railmail.app/api/v1/subscribers/{email}/consents', 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.railmail.app/api/v1/subscribers/{email}/consents",
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([
'topicKey' => 'APIT-1',
'source' => 'preference-center',
'ipAddress' => '203.0.113.10',
'userAgent' => 'Mozilla/5.0',
'sourceUrl' => 'https://shop.example.com/prefs',
'consentText' => 'I agree to receive the newsletter',
'formVersion' => 'v3'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.railmail.app/api/v1/subscribers/{email}/consents"
payload := strings.NewReader("{\n \"topicKey\": \"APIT-1\",\n \"source\": \"preference-center\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"sourceUrl\": \"https://shop.example.com/prefs\",\n \"consentText\": \"I agree to receive the newsletter\",\n \"formVersion\": \"v3\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.railmail.app/api/v1/subscribers/{email}/consents")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"topicKey\": \"APIT-1\",\n \"source\": \"preference-center\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"sourceUrl\": \"https://shop.example.com/prefs\",\n \"consentText\": \"I agree to receive the newsletter\",\n \"formVersion\": \"v3\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.railmail.app/api/v1/subscribers/{email}/consents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"topicKey\": \"APIT-1\",\n \"source\": \"preference-center\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"sourceUrl\": \"https://shop.example.com/prefs\",\n \"consentText\": \"I agree to receive the newsletter\",\n \"formVersion\": \"v3\"\n}"
response = http.request(request)
puts response.read_body{
"topicKey": "APIT-1",
"status": "PENDING_CONFIRMATION",
"requiresConfirmation": true,
"grantedAt": "2026-06-24T10:20:00Z",
"confirmedAt": null,
"tokenExpiresAt": "2026-06-26T10:20:00Z"
}Autoryzacje
Project-scoped API key, format rm_(live|test)_... . May also be sent as Authorization: Bearer rm_....
Parametry ścieżki
URL-encoded subscriber email.
Treść
application/json
Odpowiedź
Zgoda nadana (lub oczekująca potwierdzenia dla tematów z double opt-in)
When requiresConfirmation is true, the topic uses double opt-in and the subscriber must confirm via email before they are subscribed.