Skip to main content
GET
/
preferences
/
sections
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 workspacePreferenceListResponse = await client.workspacePreferences.list();

console.log(workspacePreferenceListResponse.results);
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_list_response = client.workspace_preferences.list()
print(workspace_preference_list_response.results)
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"),
)
workspacePreferenceListResponse, err := client.WorkspacePreferences.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", workspacePreferenceListResponse.Results)
}
package com.courier.example;

import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.workspacepreferences.WorkspacePreferenceListParams;
import com.courier.models.workspacepreferences.WorkspacePreferenceListResponse;

public final class Main {
private Main() {}

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

WorkspacePreferenceListResponse workspacePreferenceListResponse = client.workspacePreferences().list();
}
}
require "courier"

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

workspace_preference_list_response = courier.workspace_preferences.list

puts(workspace_preference_list_response)
<?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 {
$workspacePreferenceListResponse = $client->workspacePreferences->list();

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

CourierClient client = new();

WorkspacePreferenceListParams parameters = new();

var workspacePreferenceListResponse = await client.WorkspacePreferences.List(parameters);

Console.WriteLine(workspacePreferenceListResponse);
courier workspace-preferences list \
--api-key 'My API Key'
curl --request GET \
--url https://api.courier.com/preferences/sections \
--header 'Authorization: Bearer <token>'
{
  "results": [
    {
      "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"
        }
      ]
    }
  ]
}

Authorizations

Authorization
string
header
required

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

Response

200 - application/json

The workspace's preferences, each with its topics.

results
WorkspacePreferenceGetResponse · object[]
required