import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const brand = await client.brands.create({
name: 'My Brand',
settings: { colors: { primary: '#9D3789', secondary: '#FFFFFF' } },
});
console.log(brand.id);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
brand = client.brands.create(
name="My Brand",
settings={
"colors": {
"primary": "#9D3789",
"secondary": "#FFFFFF",
}
},
)
print(brand.id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
brand, err := client.Brands.New(context.TODO(), courier.BrandNewParams{
Name: "My Brand",
Settings: courier.BrandSettingsParam{
Colors: courier.BrandColorsParam{
Primary: courier.String("#9D3789"),
Secondary: courier.String("#FFFFFF"),
},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", brand.ID)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.brands.Brand;
import com.courier.models.brands.BrandCreateParams;
import com.courier.models.brands.BrandSettings;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BrandCreateParams params = BrandCreateParams.builder()
.name("My Brand")
.settings(BrandSettings.builder().build())
.build();
Brand brand = client.brands().create(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
brand = courier.brands.create(name: "My Brand", settings: {})
puts(brand)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$brand = $client->brands->create(
name: 'My Brand',
settings: [
'colors' => ['primary' => '#9D3789', 'secondary' => '#FFFFFF'],
'email' => [
'footer' => ['content' => 'content', 'inheritDefault' => true],
'head' => ['inheritDefault' => true, 'content' => 'content'],
'header' => [
'logo' => ['href' => 'href', 'image' => 'image'],
'barColor' => 'barColor',
'inheritDefault' => true,
],
'templateOverride' => [
'enabled' => true,
'backgroundColor' => 'backgroundColor',
'blocksBackgroundColor' => 'blocksBackgroundColor',
'footer' => 'footer',
'head' => 'head',
'header' => 'header',
'width' => 'width',
'mjml' => [
'enabled' => true,
'backgroundColor' => 'backgroundColor',
'blocksBackgroundColor' => 'blocksBackgroundColor',
'footer' => 'footer',
'head' => 'head',
'header' => 'header',
'width' => 'width',
],
'footerBackgroundColor' => 'footerBackgroundColor',
'footerFullWidth' => true,
],
],
'inapp' => [
'colors' => ['primary' => 'primary', 'secondary' => 'secondary'],
'icons' => ['bell' => 'bell', 'message' => 'message'],
'widgetBackground' => [
'bottomColor' => 'bottomColor', 'topColor' => 'topColor'
],
'borderRadius' => 'borderRadius',
'disableMessageIcon' => true,
'fontFamily' => 'fontFamily',
'placement' => 'top',
],
],
id: 'id',
snippets: ['items' => [['name' => 'name', 'value' => 'value']]],
idempotencyKey: 'order-ORD-456-user-123',
xIdempotencyExpiration: '1785312000',
);
var_dump($brand);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Brands;
CourierClient client = new();
BrandCreateParams parameters = new()
{
Name = "My Brand",
Settings = new()
{
Colors = new()
{
Primary = "#9D3789",
Secondary = "#FFFFFF",
},
Email = new()
{
Footer = new()
{
Content = "content",
InheritDefault = true,
},
Head = new()
{
InheritDefault = true,
Content = "content",
},
Header = new()
{
Logo = new()
{
Href = "href",
Image = "image",
},
BarColor = "barColor",
InheritDefault = true,
},
TemplateOverride = new()
{
Enabled = true,
BackgroundColor = "backgroundColor",
BlocksBackgroundColor = "blocksBackgroundColor",
Footer = "footer",
Head = "head",
Header = "header",
Width = "width",
Mjml = new()
{
Enabled = true,
BackgroundColor = "backgroundColor",
BlocksBackgroundColor = "blocksBackgroundColor",
Footer = "footer",
Head = "head",
Header = "header",
Width = "width",
},
FooterBackgroundColor = "footerBackgroundColor",
FooterFullWidth = true,
},
},
Inapp = new()
{
Colors = new()
{
Primary = "primary",
Secondary = "secondary",
},
Icons = new()
{
Bell = "bell",
Message = "message",
},
WidgetBackground = new()
{
BottomColor = "bottomColor",
TopColor = "topColor",
},
BorderRadius = "borderRadius",
DisableMessageIcon = true,
FontFamily = "fontFamily",
Placement = Placement.Top,
},
},
};
var brand = await client.Brands.Create(parameters);
Console.WriteLine(brand);courier brands create \
--api-key 'My API Key' \
--name 'My Brand' \
--settings '{}'curl --request POST \
--url https://api.courier.com/brands \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My Brand",
"settings": {
"colors": {
"primary": "#9D3789",
"secondary": "#FFFFFF"
}
}
}
'{
"id": "bnd_01kx4mrd0pfzw8wt7pn7p2fzag",
"name": "Default Brand",
"published": 1,
"created": 1,
"updated": 1,
"settings": {
"colors": {
"primary": "string",
"secondary": "string"
},
"email": {
"templateOverride": {
"backgroundColor": "string",
"blocksBackgroundColor": "string",
"enabled": true,
"footer": "string",
"head": "string",
"header": "string",
"width": "string",
"mjml": {
"backgroundColor": "string",
"blocksBackgroundColor": "string",
"enabled": true,
"footer": "string",
"head": "string",
"header": "string",
"width": "string"
},
"footerBackgroundColor": "string",
"footerFullWidth": true
},
"head": {
"inheritDefault": true,
"content": "string"
},
"footer": {
"content": "string",
"inheritDefault": true
},
"header": {
"inheritDefault": true,
"barColor": "string",
"logo": {
"href": "https://example.com",
"image": "string"
}
}
},
"inapp": {
"borderRadius": "string",
"disableMessageIcon": true,
"fontFamily": "string",
"placement": "top",
"widgetBackground": {
"topColor": "string",
"bottomColor": "string"
},
"colors": {
"primary": "string",
"secondary": "string"
},
"icons": {
"bell": "string",
"message": "Example message text"
}
}
},
"snippets": {
"items": [
{
"name": "Default Brand",
"value": "string"
}
]
},
"version": "string"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "authorization_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Create a new brand
Creates a brand from a name and settings, including primary and secondary colors. Brands supply the logo, colors, and styling that templates render with.
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const brand = await client.brands.create({
name: 'My Brand',
settings: { colors: { primary: '#9D3789', secondary: '#FFFFFF' } },
});
console.log(brand.id);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
brand = client.brands.create(
name="My Brand",
settings={
"colors": {
"primary": "#9D3789",
"secondary": "#FFFFFF",
}
},
)
print(brand.id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
brand, err := client.Brands.New(context.TODO(), courier.BrandNewParams{
Name: "My Brand",
Settings: courier.BrandSettingsParam{
Colors: courier.BrandColorsParam{
Primary: courier.String("#9D3789"),
Secondary: courier.String("#FFFFFF"),
},
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", brand.ID)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.brands.Brand;
import com.courier.models.brands.BrandCreateParams;
import com.courier.models.brands.BrandSettings;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
BrandCreateParams params = BrandCreateParams.builder()
.name("My Brand")
.settings(BrandSettings.builder().build())
.build();
Brand brand = client.brands().create(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
brand = courier.brands.create(name: "My Brand", settings: {})
puts(brand)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$brand = $client->brands->create(
name: 'My Brand',
settings: [
'colors' => ['primary' => '#9D3789', 'secondary' => '#FFFFFF'],
'email' => [
'footer' => ['content' => 'content', 'inheritDefault' => true],
'head' => ['inheritDefault' => true, 'content' => 'content'],
'header' => [
'logo' => ['href' => 'href', 'image' => 'image'],
'barColor' => 'barColor',
'inheritDefault' => true,
],
'templateOverride' => [
'enabled' => true,
'backgroundColor' => 'backgroundColor',
'blocksBackgroundColor' => 'blocksBackgroundColor',
'footer' => 'footer',
'head' => 'head',
'header' => 'header',
'width' => 'width',
'mjml' => [
'enabled' => true,
'backgroundColor' => 'backgroundColor',
'blocksBackgroundColor' => 'blocksBackgroundColor',
'footer' => 'footer',
'head' => 'head',
'header' => 'header',
'width' => 'width',
],
'footerBackgroundColor' => 'footerBackgroundColor',
'footerFullWidth' => true,
],
],
'inapp' => [
'colors' => ['primary' => 'primary', 'secondary' => 'secondary'],
'icons' => ['bell' => 'bell', 'message' => 'message'],
'widgetBackground' => [
'bottomColor' => 'bottomColor', 'topColor' => 'topColor'
],
'borderRadius' => 'borderRadius',
'disableMessageIcon' => true,
'fontFamily' => 'fontFamily',
'placement' => 'top',
],
],
id: 'id',
snippets: ['items' => [['name' => 'name', 'value' => 'value']]],
idempotencyKey: 'order-ORD-456-user-123',
xIdempotencyExpiration: '1785312000',
);
var_dump($brand);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Brands;
CourierClient client = new();
BrandCreateParams parameters = new()
{
Name = "My Brand",
Settings = new()
{
Colors = new()
{
Primary = "#9D3789",
Secondary = "#FFFFFF",
},
Email = new()
{
Footer = new()
{
Content = "content",
InheritDefault = true,
},
Head = new()
{
InheritDefault = true,
Content = "content",
},
Header = new()
{
Logo = new()
{
Href = "href",
Image = "image",
},
BarColor = "barColor",
InheritDefault = true,
},
TemplateOverride = new()
{
Enabled = true,
BackgroundColor = "backgroundColor",
BlocksBackgroundColor = "blocksBackgroundColor",
Footer = "footer",
Head = "head",
Header = "header",
Width = "width",
Mjml = new()
{
Enabled = true,
BackgroundColor = "backgroundColor",
BlocksBackgroundColor = "blocksBackgroundColor",
Footer = "footer",
Head = "head",
Header = "header",
Width = "width",
},
FooterBackgroundColor = "footerBackgroundColor",
FooterFullWidth = true,
},
},
Inapp = new()
{
Colors = new()
{
Primary = "primary",
Secondary = "secondary",
},
Icons = new()
{
Bell = "bell",
Message = "message",
},
WidgetBackground = new()
{
BottomColor = "bottomColor",
TopColor = "topColor",
},
BorderRadius = "borderRadius",
DisableMessageIcon = true,
FontFamily = "fontFamily",
Placement = Placement.Top,
},
},
};
var brand = await client.Brands.Create(parameters);
Console.WriteLine(brand);courier brands create \
--api-key 'My API Key' \
--name 'My Brand' \
--settings '{}'curl --request POST \
--url https://api.courier.com/brands \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My Brand",
"settings": {
"colors": {
"primary": "#9D3789",
"secondary": "#FFFFFF"
}
}
}
'{
"id": "bnd_01kx4mrd0pfzw8wt7pn7p2fzag",
"name": "Default Brand",
"published": 1,
"created": 1,
"updated": 1,
"settings": {
"colors": {
"primary": "string",
"secondary": "string"
},
"email": {
"templateOverride": {
"backgroundColor": "string",
"blocksBackgroundColor": "string",
"enabled": true,
"footer": "string",
"head": "string",
"header": "string",
"width": "string",
"mjml": {
"backgroundColor": "string",
"blocksBackgroundColor": "string",
"enabled": true,
"footer": "string",
"head": "string",
"header": "string",
"width": "string"
},
"footerBackgroundColor": "string",
"footerFullWidth": true
},
"head": {
"inheritDefault": true,
"content": "string"
},
"footer": {
"content": "string",
"inheritDefault": true
},
"header": {
"inheritDefault": true,
"barColor": "string",
"logo": {
"href": "https://example.com",
"image": "string"
}
}
},
"inapp": {
"borderRadius": "string",
"disableMessageIcon": true,
"fontFamily": "string",
"placement": "top",
"widgetBackground": {
"topColor": "string",
"bottomColor": "string"
},
"colors": {
"primary": "string",
"secondary": "string"
},
"icons": {
"bell": "string",
"message": "Example message text"
}
}
},
"snippets": {
"items": [
{
"name": "Default Brand",
"value": "string"
}
]
},
"version": "string"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "authorization_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
A unique key that makes this request idempotent. If Courier receives another request with the same Idempotency-Key, it returns the stored response from the first request without performing the operation again (including the original status code and any error). Use it to safely retry POST requests after network failures without risking duplicate sends. The key is scoped to this endpoint.
How long the idempotency key remains valid, as a Unix epoch timestamp in seconds or an ISO 8601 date string. Only applies when Idempotency-Key is provided. If omitted, the key is retained for 25 hours; the maximum is 1 year.