> ## Documentation Index
> Fetch the complete documentation index at: https://www.courier.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Workspace Preference

> Returns one workspace preference by id, including its subscription topics, routing options, and custom routing flag.



## OpenAPI

````yaml /openapi-specs/openapi.documented.yml get /preferences/sections/{section_id}
openapi: 3.0.1
info:
  title: Courier
  description: The Courier REST API for sending and managing notifications across channels.
  version: 0.0.1
servers:
  - url: https://api.courier.com
    description: Production
security: []
paths:
  /preferences/sections/{section_id}:
    get:
      tags:
        - Workspace Preferences
      summary: Get Workspace Preference
      description: >-
        Returns one workspace preference by id, including its subscription
        topics, routing options, and custom routing flag.
      operationId: workspacePreferences_retrieve
      parameters:
        - name: section_id
          in: path
          description: Id of the workspace preference.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspacePreferenceGetResponse'
              examples:
                Example:
                  value:
                    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
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
              examples:
                WorkspacePreferenceNotFound:
                  value:
                    type: invalid_request_error
                    message: Workspace preference not found
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            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.retrieve('section_id');


            console.log(workspacePreferenceGetResponse.id);
        - lang: Python
          source: >-
            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.retrieve(
                "section_id",
            )

            print(workspace_preference_get_response.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/trycourier/courier-go\"\n\t\"github.com/trycourier/courier-go/option\"\n)\n\nfunc main() {\n\tclient := courier.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tworkspacePreferenceGetResponse, err := client.WorkspacePreferences.Get(context.TODO(), \"section_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", workspacePreferenceGetResponse.ID)\n}\n"
        - lang: Java
          source: >-
            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.WorkspacePreferenceRetrieveParams;


            public final class Main {
                private Main() {}

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

                    WorkspacePreferenceGetResponse workspacePreferenceGetResponse = client.workspacePreferences().retrieve("section_id");
                }
            }
        - lang: Ruby
          source: >-
            require "courier"


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


            workspace_preference_get_response =
            courier.workspace_preferences.retrieve("section_id")


            puts(workspace_preference_get_response)
        - lang: PHP
          source: >-
            <?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 {
              $workspacePreferenceGetResponse = $client->workspacePreferences->retrieve(
                'section_id'
              );

              var_dump($workspacePreferenceGetResponse);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: >-
            using System;

            using TryCourier;

            using TryCourier.Models.WorkspacePreferences;


            CourierClient client = new();


            WorkspacePreferenceRetrieveParams parameters = new()

            {
                SectionID = "section_id"
            };


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


            Console.WriteLine(workspacePreferenceGetResponse);
        - lang: CLI
          source: |-
            courier workspace-preferences retrieve \
              --api-key 'My API Key' \
              --section-id section_id
components:
  schemas:
    WorkspacePreferenceGetResponse:
      title: WorkspacePreferenceGetResponse
      type: object
      description: A workspace preference in your workspace, including its topics.
      properties:
        id:
          type: string
          description: The workspace preference id.
        name:
          type: string
          description: Human-readable name.
        description:
          type: string
          nullable: true
          description: >-
            Optional description shown under the section on the hosted
            preferences page.
        routing_options:
          type: array
          items:
            $ref: '#/components/schemas/ChannelClassification'
          description: Default channels for the workspace preference. May be empty.
        has_custom_routing:
          type: boolean
          description: >-
            Whether the workspace preference defines custom routing for its
            topics.
        created:
          type: string
          description: ISO-8601 timestamp of when the workspace preference was created.
        creator:
          type: string
          nullable: true
          description: Id of the creator.
        updated:
          type: string
          nullable: true
          description: ISO-8601 timestamp of the last update.
        updater:
          type: string
          nullable: true
          description: Id of the last updater.
        topics:
          type: array
          items:
            $ref: '#/components/schemas/WorkspacePreferenceTopicGetResponse'
          description: The topics contained in this workspace preference.
      required:
        - id
        - name
        - routing_options
        - has_custom_routing
        - created
        - topics
    NotFound:
      title: NotFound
      type: object
      properties:
        type:
          type: string
          enum:
            - invalid_request_error
      required:
        - type
      allOf:
        - $ref: '#/components/schemas/BaseError'
    ChannelClassification:
      title: ChannelClassification
      type: string
      enum:
        - direct_message
        - email
        - push
        - sms
        - webhook
        - inbox
    WorkspacePreferenceTopicGetResponse:
      title: WorkspacePreferenceTopicGetResponse
      type: object
      description: A subscription preference topic in your workspace.
      properties:
        id:
          type: string
          description: The preference topic id.
        name:
          type: string
          description: Human-readable name.
        description:
          type: string
          nullable: true
          description: >-
            Optional description shown under the topic on the hosted preferences
            page.
        default_status:
          $ref: '#/components/schemas/SubscriptionTopicStatus'
          description: >-
            The default subscription status applied when a recipient has not set
            their own.
        routing_options:
          type: array
          items:
            $ref: '#/components/schemas/ChannelClassification'
          description: Default channels delivered for this topic. May be empty.
        allowed_preferences:
          type: array
          items:
            $ref: '#/components/schemas/AllowedPreference'
          description: Preference controls a recipient may customize. May be empty.
        include_unsubscribe_header:
          type: boolean
          description: >-
            Whether a list-unsubscribe header is included on emails for this
            topic.
        topic_data:
          type: object
          additionalProperties: true
          description: Arbitrary metadata associated with the topic.
        created:
          type: string
          description: ISO-8601 timestamp of when the topic was created.
        creator:
          type: string
          nullable: true
          description: Id of the creator.
        updated:
          type: string
          description: ISO-8601 timestamp of the last update.
        updater:
          type: string
          nullable: true
          description: Id of the last updater.
      required:
        - id
        - name
        - default_status
        - routing_options
        - allowed_preferences
        - include_unsubscribe_header
        - topic_data
        - created
        - updated
    BaseError:
      title: BaseError
      type: object
      properties:
        message:
          type: string
          description: A message describing the error that occurred.
      required:
        - message
    SubscriptionTopicStatus:
      title: SubscriptionTopicStatus
      type: string
      enum:
        - OPTED_OUT
        - OPTED_IN
        - REQUIRED
    AllowedPreference:
      title: AllowedPreference
      type: string
      description: A preference control a recipient may customize for a topic.
      enum:
        - snooze
        - channel_preferences
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````