Skip to main content
PUT
/
preferences
/
sections
/
{section_id}
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 workspacePreferenceGetResponse = await client.workspacePreferences.replace('section_id', {
  name: 'name',
});

console.log(workspacePreferenceGetResponse.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
)
workspace_preference_get_response = client.workspace_preferences.replace(
section_id="section_id",
name="name",
)
print(workspace_preference_get_response.id)
package main

import (
"context"
"fmt"

"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)

func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
workspacePreferenceGetResponse, err := client.WorkspacePreferences.Replace(
context.TODO(),
"section_id",
courier.WorkspacePreferenceReplaceParams{
WorkspacePreferenceReplaceRequest: courier.WorkspacePreferenceReplaceRequestParam{
Name: "name",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", workspacePreferenceGetResponse.ID)
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.workspacepreferences.WorkspacePreferenceGetResponse;
import com.courier.models.workspacepreferences.WorkspacePreferenceReplaceParams;
import com.courier.models.workspacepreferences.WorkspacePreferenceReplaceRequest;

public final class Main {
private Main() {}

public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();

WorkspacePreferenceReplaceParams params = WorkspacePreferenceReplaceParams.builder()
.sectionId("section_id")
.workspacePreferenceReplaceRequest(WorkspacePreferenceReplaceRequest.builder()
.name("name")
.build())
.build();
WorkspacePreferenceGetResponse workspacePreferenceGetResponse = client.workspacePreferences().replace(params);
}
}
require "courier"

courier = Courier::Client.new(api_key: "My API Key")

workspace_preference_get_response = courier.workspace_preferences.replace("section_id", name: "name")

puts(workspace_preference_get_response)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Courier\Client;
use Courier\ChannelClassification;
use Courier\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');

try {
$workspacePreferenceGetResponse = $client->workspacePreferences->replace(
'section_id',
name: 'name',
description: 'description',
hasCustomRouting: true,
routingOptions: [ChannelClassification::DIRECT_MESSAGE],
);

var_dump($workspacePreferenceGetResponse);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using TryCourier;
using TryCourier.Models.WorkspacePreferences;

CourierClient client = new();

WorkspacePreferenceReplaceParams parameters = new()
{
SectionID = "section_id",
Name = "name",
};

var workspacePreferenceGetResponse = await client.WorkspacePreferences.Replace(parameters);

Console.WriteLine(workspacePreferenceGetResponse);
courier workspace-preferences replace \
--api-key 'My API Key' \
--section-id section_id \
--name name
curl --request PUT \
--url https://api.courier.com/preferences/sections/{section_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"routing_options": [],
"has_custom_routing": true
}
'
{
  "id": "ps_01kx4h2jdafq8bk9b6w3knrezh",
  "name": "Account Notifications",
  "routing_options": [
    "direct_message"
  ],
  "has_custom_routing": true,
  "created": "2024-01-15T10:30:00.000Z",
  "creator": "user_123",
  "updated": "2024-01-15T10:30:00.000Z",
  "updater": "user_123",
  "topics": [
    {
      "id": "pt_01kx4h2jdafq8bk99mj9q2gsa2",
      "name": "Product Updates",
      "default_status": "OPTED_OUT",
      "routing_options": [
        "direct_message"
      ],
      "allowed_preferences": [
        "snooze"
      ],
      "include_unsubscribe_header": true,
      "topic_data": {},
      "created": "2024-01-15T10:30:00.000Z",
      "creator": "user_123",
      "updated": "2024-01-15T10:30:00.000Z",
      "updater": "user_123"
    }
  ]
}
{
"message": "Example message text",
"type": "invalid_request_error"
}
{
"message": "Example message text",
"type": "invalid_request_error"
}

Authorizations

Authorization
string
header
required

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

Path Parameters

section_id
string
required

Id of the workspace preference.

Body

application/json

Request body for replacing a workspace preference. Full document replacement; missing optional fields are cleared.

name
string
required

Human-readable name for the workspace preference.

description
string | null

Optional description shown under the section on the hosted preferences page. Omit to clear.

routing_options
enum<string>[] | null

Default channels for the workspace preference. Omit to clear.

Available options:
direct_message,
email,
push,
sms,
webhook,
inbox
has_custom_routing
boolean | null

Whether the workspace preference defines custom routing for its topics.

Response

A workspace preference in your workspace, including its topics.

id
string
required

The workspace preference id.

name
string
required

Human-readable name.

routing_options
enum<string>[]
required

Default channels for the workspace preference. May be empty.

Available options:
direct_message,
email,
push,
sms,
webhook,
inbox
has_custom_routing
boolean
required

Whether the workspace preference defines custom routing for its topics.

created
string
required

ISO-8601 timestamp of when the workspace preference was created.

topics
WorkspacePreferenceTopicGetResponse · object[]
required

The topics contained in this workspace preference.

description
string | null

Optional description shown under the section on the hosted preferences page.

creator
string | null

Id of the creator.

updated
string | null

ISO-8601 timestamp of the last update.

updater
string | null

Id of the last updater.