Skip to main content
POST
/
routing-strategies
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 routingStrategyMutationResponse = await client.routingStrategies.create({
  name: 'Email via SendGrid',
  routing: { method: 'single', channels: ['email'] },
  channels: { email: { providers: ['sendgrid', 'ses'] } },
  description: 'Routes email through sendgrid with SES failover',
  providers: { sendgrid: { override: {} } },
  tags: ['production', 'email'],
});

console.log(routingStrategyMutationResponse.id);
{
  "id": "rs_01abc123"
}

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 routing strategy.

name
string
required

Human-readable name for the routing strategy.

routing
MessageRouting · object
required

Routing tree defining channel selection method and order.

description
string | null

Optional description of the routing strategy.

tags
string[] | null

Optional tags for categorization.

channels
MessageChannels · object

Per-channel delivery configuration. Defaults to empty if omitted.

providers
MessageProviders · object

Per-provider delivery configuration. Defaults to empty if omitted.

Response

Created

Response returned by create and replace operations.

id
string
required

The routing strategy ID (rs_ prefix).