Skip to main content
POST
/
notifications
JavaScript
import Courier from '@trycourier/courier';

const client = new Courier({
  apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});

const notificationTemplateMutationResponse = await client.notifications.create({
  notification: {
    name: 'Welcome Email',
    tags: ['onboarding', 'welcome'],
    brand: { id: 'brand_abc' },
    subscription: { topic_id: 'marketing' },
    routing: { strategy_id: 'rs_123' },
    content: { version: '2022-01-01', elements: [{ type: 'channel' }] },
  },
  state: 'DRAFT',
});

console.log(notificationTemplateMutationResponse.notification);
{
  "notification": {
    "id": "nt_01abc123"
  },
  "state": "DRAFT"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request body for creating a notification template.

notification
NotificationTemplatePayload · object
required

Full document shape used in POST and PUT request bodies, and returned inside the GET response envelope.

state
enum<string>
default:DRAFT

Template state after creation. Case-insensitive input, normalized to uppercase in the response. Defaults to "DRAFT".

Available options:
DRAFT,
PUBLISHED

Response

Response returned by POST and PUT operations.

notification
object
required
state
enum<string>
required

The template state after the operation. Always uppercase.

Available options:
DRAFT,
PUBLISHED