curl --request POST \
--url https://api.paubox.com/v1/marketing/subscriptions \
--header 'Content-Type: application/json' \
--header 'authorization: <api-key>' \
--data '
{
"subscription": {
"subscription_list_id": "123e4567-e89b-12d3-a456-426614174000",
"subscriber_id": 4821
}
}
'import requests
url = "https://api.paubox.com/v1/marketing/subscriptions"
payload = { "subscription": {
"subscription_list_id": "123e4567-e89b-12d3-a456-426614174000",
"subscriber_id": 4821
} }
headers = {
"authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscription: {
subscription_list_id: '123e4567-e89b-12d3-a456-426614174000',
subscriber_id: 4821
}
})
};
fetch('https://api.paubox.com/v1/marketing/subscriptions', 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.paubox.com/v1/marketing/subscriptions",
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([
'subscription' => [
'subscription_list_id' => '123e4567-e89b-12d3-a456-426614174000',
'subscriber_id' => 4821
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <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.paubox.com/v1/marketing/subscriptions"
payload := strings.NewReader("{\n \"subscription\": {\n \"subscription_list_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"subscriber_id\": 4821\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<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.paubox.com/v1/marketing/subscriptions")
.header("authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription\": {\n \"subscription_list_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"subscriber_id\": 4821\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paubox.com/v1/marketing/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription\": {\n \"subscription_list_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"subscriber_id\": 4821\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"uuid": "<string>",
"subscription_list_id": "<string>",
"dynamic_list_id": 123,
"subscriber_id": 123,
"unsubscribed_at": "2023-11-07T05:31:56Z",
"delete_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"errors": [
"<string>"
]
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}Create a subscription with the Marketing API
Subscribes an existing subscriber to an existing subscription list.
Creating a subscription fires any drip campaign configured with a subscription_created trigger on that list.
A subscriber may only be subscribed to a given list once; a duplicate request fails validation.
Note on subscriber_id: this field takes the subscriber’s internal numeric ID, not the UUID returned by the subscriber endpoints. To add a subscriber to a list by UUID, use POST /subscribers with a subscription_list_id, or POST /subscriptions/subscribe to re-subscribe an existing subscription.
Example curl command:
curl -X POST \
https://api.paubox.com/v1/marketing/subscriptions \
-H 'authorization: Token token=YOUR_API_KEY' \
-H 'content-type: application/json' \
-d '{
"subscription": {
"subscription_list_id": "123e4567-e89b-12d3-a456-426614174000",
"subscriber_id": 4821
}
}'
curl --request POST \
--url https://api.paubox.com/v1/marketing/subscriptions \
--header 'Content-Type: application/json' \
--header 'authorization: <api-key>' \
--data '
{
"subscription": {
"subscription_list_id": "123e4567-e89b-12d3-a456-426614174000",
"subscriber_id": 4821
}
}
'import requests
url = "https://api.paubox.com/v1/marketing/subscriptions"
payload = { "subscription": {
"subscription_list_id": "123e4567-e89b-12d3-a456-426614174000",
"subscriber_id": 4821
} }
headers = {
"authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscription: {
subscription_list_id: '123e4567-e89b-12d3-a456-426614174000',
subscriber_id: 4821
}
})
};
fetch('https://api.paubox.com/v1/marketing/subscriptions', 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.paubox.com/v1/marketing/subscriptions",
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([
'subscription' => [
'subscription_list_id' => '123e4567-e89b-12d3-a456-426614174000',
'subscriber_id' => 4821
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <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.paubox.com/v1/marketing/subscriptions"
payload := strings.NewReader("{\n \"subscription\": {\n \"subscription_list_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"subscriber_id\": 4821\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<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.paubox.com/v1/marketing/subscriptions")
.header("authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription\": {\n \"subscription_list_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"subscriber_id\": 4821\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paubox.com/v1/marketing/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription\": {\n \"subscription_list_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"subscriber_id\": 4821\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"uuid": "<string>",
"subscription_list_id": "<string>",
"dynamic_list_id": 123,
"subscriber_id": 123,
"unsubscribed_at": "2023-11-07T05:31:56Z",
"delete_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"errors": [
"<string>"
]
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}Authorizations
Token-based authentication. Use format: "Token token=<API_KEY>" where <API_KEY> is your API key
Body
Show child attributes
Show child attributes
Response
Subscription created. If validation fails the response is still 200 but the body contains an errors array instead of data.