Create a subscriber
curl --request POST \
--url https://api.railmail.app/api/v1/subscribers \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"topicKeys": [
"APIT-1",
"APIT-2"
],
"consent": {
"source": "checkout-form",
"sourceUrl": "https://shop.example.com/checkout",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"consentText": "I agree to receive product updates",
"formVersion": "v3"
},
"customFields": {
"plan": "pro"
}
}
'import requests
url = "https://api.railmail.app/api/v1/subscribers"
payload = {
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"topicKeys": ["APIT-1", "APIT-2"],
"consent": {
"source": "checkout-form",
"sourceUrl": "https://shop.example.com/checkout",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"consentText": "I agree to receive product updates",
"formVersion": "v3"
},
"customFields": { "plan": "pro" }
}
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({
email: 'jane@example.com',
firstName: 'Jane',
lastName: 'Doe',
topicKeys: ['APIT-1', 'APIT-2'],
consent: {
source: 'checkout-form',
sourceUrl: 'https://shop.example.com/checkout',
ipAddress: '203.0.113.10',
userAgent: 'Mozilla/5.0',
consentText: 'I agree to receive product updates',
formVersion: 'v3'
},
customFields: {plan: 'pro'}
})
};
fetch('https://api.railmail.app/api/v1/subscribers', 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",
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' => 'jane@example.com',
'firstName' => 'Jane',
'lastName' => 'Doe',
'topicKeys' => [
'APIT-1',
'APIT-2'
],
'consent' => [
'source' => 'checkout-form',
'sourceUrl' => 'https://shop.example.com/checkout',
'ipAddress' => '203.0.113.10',
'userAgent' => 'Mozilla/5.0',
'consentText' => 'I agree to receive product updates',
'formVersion' => 'v3'
],
'customFields' => [
'plan' => 'pro'
]
]),
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"
payload := strings.NewReader("{\n \"email\": \"jane@example.com\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"topicKeys\": [\n \"APIT-1\",\n \"APIT-2\"\n ],\n \"consent\": {\n \"source\": \"checkout-form\",\n \"sourceUrl\": \"https://shop.example.com/checkout\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"consentText\": \"I agree to receive product updates\",\n \"formVersion\": \"v3\"\n },\n \"customFields\": {\n \"plan\": \"pro\"\n }\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")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"jane@example.com\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"topicKeys\": [\n \"APIT-1\",\n \"APIT-2\"\n ],\n \"consent\": {\n \"source\": \"checkout-form\",\n \"sourceUrl\": \"https://shop.example.com/checkout\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"consentText\": \"I agree to receive product updates\",\n \"formVersion\": \"v3\"\n },\n \"customFields\": {\n \"plan\": \"pro\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.railmail.app/api/v1/subscribers")
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 \"email\": \"jane@example.com\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"topicKeys\": [\n \"APIT-1\",\n \"APIT-2\"\n ],\n \"consent\": {\n \"source\": \"checkout-form\",\n \"sourceUrl\": \"https://shop.example.com/checkout\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"consentText\": \"I agree to receive product updates\",\n \"formVersion\": \"v3\"\n },\n \"customFields\": {\n \"plan\": \"pro\"\n }\n}"
response = http.request(request)
puts response.read_body{
"subscriberKey": "SUB-1A2B",
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"phone": null,
"status": "ACTIVE",
"source": "API",
"createdAt": "2026-06-24T10:15:00Z",
"updatedAt": "2026-06-24T10:15:00Z"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}Subscribers
Create a subscriber
Creates a subscriber in the key’s project and subscribes them to the given topics in a single call. If a topic uses double opt-in, the resulting consent is PENDING_CONFIRMATION. Requires scope: subscribers:write. Tenancy: scoped to the API key’s project.
POST
/
api
/
v1
/
subscribers
Create a subscriber
curl --request POST \
--url https://api.railmail.app/api/v1/subscribers \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"topicKeys": [
"APIT-1",
"APIT-2"
],
"consent": {
"source": "checkout-form",
"sourceUrl": "https://shop.example.com/checkout",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"consentText": "I agree to receive product updates",
"formVersion": "v3"
},
"customFields": {
"plan": "pro"
}
}
'import requests
url = "https://api.railmail.app/api/v1/subscribers"
payload = {
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"topicKeys": ["APIT-1", "APIT-2"],
"consent": {
"source": "checkout-form",
"sourceUrl": "https://shop.example.com/checkout",
"ipAddress": "203.0.113.10",
"userAgent": "Mozilla/5.0",
"consentText": "I agree to receive product updates",
"formVersion": "v3"
},
"customFields": { "plan": "pro" }
}
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({
email: 'jane@example.com',
firstName: 'Jane',
lastName: 'Doe',
topicKeys: ['APIT-1', 'APIT-2'],
consent: {
source: 'checkout-form',
sourceUrl: 'https://shop.example.com/checkout',
ipAddress: '203.0.113.10',
userAgent: 'Mozilla/5.0',
consentText: 'I agree to receive product updates',
formVersion: 'v3'
},
customFields: {plan: 'pro'}
})
};
fetch('https://api.railmail.app/api/v1/subscribers', 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",
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' => 'jane@example.com',
'firstName' => 'Jane',
'lastName' => 'Doe',
'topicKeys' => [
'APIT-1',
'APIT-2'
],
'consent' => [
'source' => 'checkout-form',
'sourceUrl' => 'https://shop.example.com/checkout',
'ipAddress' => '203.0.113.10',
'userAgent' => 'Mozilla/5.0',
'consentText' => 'I agree to receive product updates',
'formVersion' => 'v3'
],
'customFields' => [
'plan' => 'pro'
]
]),
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"
payload := strings.NewReader("{\n \"email\": \"jane@example.com\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"topicKeys\": [\n \"APIT-1\",\n \"APIT-2\"\n ],\n \"consent\": {\n \"source\": \"checkout-form\",\n \"sourceUrl\": \"https://shop.example.com/checkout\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"consentText\": \"I agree to receive product updates\",\n \"formVersion\": \"v3\"\n },\n \"customFields\": {\n \"plan\": \"pro\"\n }\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")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"jane@example.com\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"topicKeys\": [\n \"APIT-1\",\n \"APIT-2\"\n ],\n \"consent\": {\n \"source\": \"checkout-form\",\n \"sourceUrl\": \"https://shop.example.com/checkout\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"consentText\": \"I agree to receive product updates\",\n \"formVersion\": \"v3\"\n },\n \"customFields\": {\n \"plan\": \"pro\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.railmail.app/api/v1/subscribers")
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 \"email\": \"jane@example.com\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"topicKeys\": [\n \"APIT-1\",\n \"APIT-2\"\n ],\n \"consent\": {\n \"source\": \"checkout-form\",\n \"sourceUrl\": \"https://shop.example.com/checkout\",\n \"ipAddress\": \"203.0.113.10\",\n \"userAgent\": \"Mozilla/5.0\",\n \"consentText\": \"I agree to receive product updates\",\n \"formVersion\": \"v3\"\n },\n \"customFields\": {\n \"plan\": \"pro\"\n }\n}"
response = http.request(request)
puts response.read_body{
"subscriberKey": "SUB-1A2B",
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"phone": null,
"status": "ACTIVE",
"source": "API",
"createdAt": "2026-06-24T10:15:00Z",
"updatedAt": "2026-06-24T10:15:00Z"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"errors": {}
}Authorizations
Project-scoped API key, format rm_(live|test)_... . May also be sent as Authorization: Bearer rm_....
Body
application/json
Minimum array length:
1Show child attributes
Show child attributes
Maximum string length:
50Maximum string length:
50Maximum string length:
20Show child attributes
Show child attributes