curl --request POST \
--url https://api.kit.com/v4/broadcasts \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"email_template_id": 2,
"email_address": null,
"content": "<p>Let me introduce myself</p>",
"description": "Intro email",
"public": true,
"published_at": "2023-02-17T11:43:55+00:00",
"send_at": null,
"thumbnail_alt": null,
"thumbnail_url": null,
"preview_text": "Pleased to meet you!",
"subject": "Hello!",
"subscriber_filter": [
{
"all": [
{
"type": "segment",
"ids": [
2
]
}
],
"any": null,
"none": null
}
]
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/broadcasts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email_template_id\": 2,\n \"email_address\": null,\n \"content\": \"<p>Let me introduce myself</p>\",\n \"description\": \"Intro email\",\n \"public\": true,\n \"published_at\": \"2023-02-17T11:43:55+00:00\",\n \"send_at\": null,\n \"thumbnail_alt\": null,\n \"thumbnail_url\": null,\n \"preview_text\": \"Pleased to meet you!\",\n \"subject\": \"Hello!\",\n \"subscriber_filter\": [\n {\n \"all\": [\n {\n \"type\": \"segment\",\n \"ids\": [\n 2\n ]\n }\n ],\n \"any\": null,\n \"none\": null\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email_template_id: 2,
email_address: null,
content: '<p>Let me introduce myself</p>',
description: 'Intro email',
public: true,
published_at: '2023-02-17T11:43:55+00:00',
send_at: null,
thumbnail_alt: null,
thumbnail_url: null,
preview_text: 'Pleased to meet you!',
subject: 'Hello!',
subscriber_filter: [{all: [{type: 'segment', ids: [2]}], any: null, none: null}]
})
};
fetch('https://api.kit.com/v4/broadcasts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/broadcasts"
payload := strings.NewReader("{\n \"email_template_id\": 2,\n \"email_address\": null,\n \"content\": \"<p>Let me introduce myself</p>\",\n \"description\": \"Intro email\",\n \"public\": true,\n \"published_at\": \"2023-02-17T11:43:55+00:00\",\n \"send_at\": null,\n \"thumbnail_alt\": null,\n \"thumbnail_url\": null,\n \"preview_text\": \"Pleased to meet you!\",\n \"subject\": \"Hello!\",\n \"subscriber_filter\": [\n {\n \"all\": [\n {\n \"type\": \"segment\",\n \"ids\": [\n 2\n ]\n }\n ],\n \"any\": null,\n \"none\": null\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/broadcasts",
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_template_id' => 2,
'email_address' => null,
'content' => '<p>Let me introduce myself</p>',
'description' => 'Intro email',
'public' => true,
'published_at' => '2023-02-17T11:43:55+00:00',
'send_at' => null,
'thumbnail_alt' => null,
'thumbnail_url' => null,
'preview_text' => 'Pleased to meet you!',
'subject' => 'Hello!',
'subscriber_filter' => [
[
'all' => [
[
'type' => 'segment',
'ids' => [
2
]
]
],
'any' => null,
'none' => null
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/broadcasts"
payload = {
"email_template_id": 2,
"email_address": None,
"content": "<p>Let me introduce myself</p>",
"description": "Intro email",
"public": True,
"published_at": "2023-02-17T11:43:55+00:00",
"send_at": None,
"thumbnail_alt": None,
"thumbnail_url": None,
"preview_text": "Pleased to meet you!",
"subject": "Hello!",
"subscriber_filter": [
{
"all": [
{
"type": "segment",
"ids": [2]
}
],
"any": None,
"none": None
}
]
}
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"broadcast": {
"id": 7,
"publication_id": 7,
"created_at": "2023-02-17T11:43:55Z",
"subject": "Hello!",
"preview_text": "Pleased to meet you!",
"description": "Intro email",
"content": "<p>Let me introduce myself</p>",
"public": true,
"published_at": "2023-02-17T11:43:55Z",
"send_at": null,
"thumbnail_alt": null,
"thumbnail_url": null,
"public_url": null,
"email_address": "greetings@kit.dev",
"email_template": {
"id": 2,
"name": "Classic"
},
"subscriber_filter": [
{
"all": [
{
"type": "segment",
"ids": [
2
]
}
]
}
],
"status": "draft",
"ab_test": null
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"You do not have sufficient permissions to access this resource. Please contact support."
]
}{
"errors": [
"Email template not found",
"Only a single filter group is supported. Use one of `all`, `any`, or `none`."
]
}Create a broadcast
Draft or schedule to send a broadcast to all or a subset of your subscribers.
To save a draft, set send_at to null.
To publish to the web, set public to true.
To schedule the broadcast for sending, provide a send_at timestamp. Scheduled broadcasts should contain a subject and your content, at a minimum.
We currently support targeting your subscribers based on segment or tag ids.
curl --request POST \
--url https://api.kit.com/v4/broadcasts \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '
{
"email_template_id": 2,
"email_address": null,
"content": "<p>Let me introduce myself</p>",
"description": "Intro email",
"public": true,
"published_at": "2023-02-17T11:43:55+00:00",
"send_at": null,
"thumbnail_alt": null,
"thumbnail_url": null,
"preview_text": "Pleased to meet you!",
"subject": "Hello!",
"subscriber_filter": [
{
"all": [
{
"type": "segment",
"ids": [
2
]
}
],
"any": null,
"none": null
}
]
}
'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/broadcasts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"email_template_id\": 2,\n \"email_address\": null,\n \"content\": \"<p>Let me introduce myself</p>\",\n \"description\": \"Intro email\",\n \"public\": true,\n \"published_at\": \"2023-02-17T11:43:55+00:00\",\n \"send_at\": null,\n \"thumbnail_alt\": null,\n \"thumbnail_url\": null,\n \"preview_text\": \"Pleased to meet you!\",\n \"subject\": \"Hello!\",\n \"subscriber_filter\": [\n {\n \"all\": [\n {\n \"type\": \"segment\",\n \"ids\": [\n 2\n ]\n }\n ],\n \"any\": null,\n \"none\": null\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email_template_id: 2,
email_address: null,
content: '<p>Let me introduce myself</p>',
description: 'Intro email',
public: true,
published_at: '2023-02-17T11:43:55+00:00',
send_at: null,
thumbnail_alt: null,
thumbnail_url: null,
preview_text: 'Pleased to meet you!',
subject: 'Hello!',
subscriber_filter: [{all: [{type: 'segment', ids: [2]}], any: null, none: null}]
})
};
fetch('https://api.kit.com/v4/broadcasts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/broadcasts"
payload := strings.NewReader("{\n \"email_template_id\": 2,\n \"email_address\": null,\n \"content\": \"<p>Let me introduce myself</p>\",\n \"description\": \"Intro email\",\n \"public\": true,\n \"published_at\": \"2023-02-17T11:43:55+00:00\",\n \"send_at\": null,\n \"thumbnail_alt\": null,\n \"thumbnail_url\": null,\n \"preview_text\": \"Pleased to meet you!\",\n \"subject\": \"Hello!\",\n \"subscriber_filter\": [\n {\n \"all\": [\n {\n \"type\": \"segment\",\n \"ids\": [\n 2\n ]\n }\n ],\n \"any\": null,\n \"none\": null\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/broadcasts",
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_template_id' => 2,
'email_address' => null,
'content' => '<p>Let me introduce myself</p>',
'description' => 'Intro email',
'public' => true,
'published_at' => '2023-02-17T11:43:55+00:00',
'send_at' => null,
'thumbnail_alt' => null,
'thumbnail_url' => null,
'preview_text' => 'Pleased to meet you!',
'subject' => 'Hello!',
'subscriber_filter' => [
[
'all' => [
[
'type' => 'segment',
'ids' => [
2
]
]
],
'any' => null,
'none' => null
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/broadcasts"
payload = {
"email_template_id": 2,
"email_address": None,
"content": "<p>Let me introduce myself</p>",
"description": "Intro email",
"public": True,
"published_at": "2023-02-17T11:43:55+00:00",
"send_at": None,
"thumbnail_alt": None,
"thumbnail_url": None,
"preview_text": "Pleased to meet you!",
"subject": "Hello!",
"subscriber_filter": [
{
"all": [
{
"type": "segment",
"ids": [2]
}
],
"any": None,
"none": None
}
]
}
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"broadcast": {
"id": 7,
"publication_id": 7,
"created_at": "2023-02-17T11:43:55Z",
"subject": "Hello!",
"preview_text": "Pleased to meet you!",
"description": "Intro email",
"content": "<p>Let me introduce myself</p>",
"public": true,
"published_at": "2023-02-17T11:43:55Z",
"send_at": null,
"thumbnail_alt": null,
"thumbnail_url": null,
"public_url": null,
"email_address": "greetings@kit.dev",
"email_template": {
"id": 2,
"name": "Classic"
},
"subscriber_filter": [
{
"all": [
{
"type": "segment",
"ids": [
2
]
}
]
}
],
"status": "draft",
"ab_test": null
}
}{
"errors": [
"The access token is invalid"
]
}{
"errors": [
"You do not have sufficient permissions to access this resource. Please contact support."
]
}{
"errors": [
"Email template not found",
"Only a single filter group is supported. Use one of `all`, `any`, or `none`."
]
}Authorizations
Body
The HTML content of the email. On a Classic template this is the body, and the template adds the design around it when the broadcast is sent. On a Starting point template the design lives in the body, so this is the complete email: keep the wrappers, images, inline styles and Liquid tags, including {{ unsubscribe_url }} and {{ address }}. Without an unsubscribe link the broadcast can't be sent.
A read returns the string that was written, so GET, PUT, GET round-trips, apart from Kit's own "Built with Kit" badge, which a Starting point write takes out of the body and re-applies when the email renders. A broadcast built in Kit's editor reads back as Kit's rendered HTML instead, and writing that back replaces its individually-editable blocks with one HTML block. Sending content in the same request as a Starting point email_template_id shapes that content into the template's design. Omit content and name a Starting point template in email_template_id to create the broadcast with that template's own design.
Filters your subscribers. At this time, we only support using only one filter group type via the API (e.g. all, any, or none but no combinations). If nothing is provided, will default to all of your subscribers. Each entry matches subscribers in any of its ids. To require several tags or segments under all, send one entry for each, for example [{ "all": [{ "type": "tag", "ids": [1] }, { "type": "tag", "ids": [2] }] }].
Show child attributes
Show child attributes
Was this page helpful?