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 response = await client.users.preferences.retrieveTopic('topic_id', { user_id: 'user_id' });
console.log(response.topic);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
response = client.users.preferences.retrieve_topic(
topic_id="topic_id",
user_id="user_id",
)
print(response.topic)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"),
)
response, err := client.Users.Preferences.GetTopic(
context.TODO(),
"topic_id",
courier.UserPreferenceGetTopicParams{
UserID: "user_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Topic)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.users.preferences.PreferenceRetrieveTopicParams;
import com.courier.models.users.preferences.PreferenceRetrieveTopicResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
PreferenceRetrieveTopicParams params = PreferenceRetrieveTopicParams.builder()
.userId("user_id")
.topicId("topic_id")
.build();
PreferenceRetrieveTopicResponse response = client.users().preferences().retrieveTopic(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.users.preferences.retrieve_topic("topic_id", user_id: "user_id")
puts(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 {
$response = $client->users->preferences->retrieveTopic(
'topic_id', userID: 'user_id', tenantID: 'tenant_id'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Users.Preferences;
CourierClient client = new();
PreferenceRetrieveTopicParams parameters = new()
{
UserID = "user_id",
TopicID = "topic_id",
};
var response = await client.Users.Preferences.RetrieveTopic(parameters);
Console.WriteLine(response);courier users:preferences retrieve-topic \
--api-key 'My API Key' \
--user-id user_id \
--topic-id topic_idcurl --request GET \
--url https://api.courier.com/users/{user_id}/preferences/{topic_id} \
--header 'Authorization: Bearer <token>'{
"topic": {
"custom_routing": [
"direct_message"
],
"default_status": "OPTED_IN",
"has_custom_routing": true,
"status": "OPTED_IN",
"topic_id": "pt_01kx4h2jdafq8bk99mj9q2gsa2",
"topic_name": "string"
}
}{
"message": "Example message text",
"type": "invalid_request_error"
}User Preferences
Get user subscription topic
Fetch user preferences for a specific subscription topic.
GET
/
users
/
{user_id}
/
preferences
/
{topic_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 response = await client.users.preferences.retrieveTopic('topic_id', { user_id: 'user_id' });
console.log(response.topic);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
response = client.users.preferences.retrieve_topic(
topic_id="topic_id",
user_id="user_id",
)
print(response.topic)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"),
)
response, err := client.Users.Preferences.GetTopic(
context.TODO(),
"topic_id",
courier.UserPreferenceGetTopicParams{
UserID: "user_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Topic)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.users.preferences.PreferenceRetrieveTopicParams;
import com.courier.models.users.preferences.PreferenceRetrieveTopicResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
PreferenceRetrieveTopicParams params = PreferenceRetrieveTopicParams.builder()
.userId("user_id")
.topicId("topic_id")
.build();
PreferenceRetrieveTopicResponse response = client.users().preferences().retrieveTopic(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.users.preferences.retrieve_topic("topic_id", user_id: "user_id")
puts(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 {
$response = $client->users->preferences->retrieveTopic(
'topic_id', userID: 'user_id', tenantID: 'tenant_id'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Users.Preferences;
CourierClient client = new();
PreferenceRetrieveTopicParams parameters = new()
{
UserID = "user_id",
TopicID = "topic_id",
};
var response = await client.Users.Preferences.RetrieveTopic(parameters);
Console.WriteLine(response);courier users:preferences retrieve-topic \
--api-key 'My API Key' \
--user-id user_id \
--topic-id topic_idcurl --request GET \
--url https://api.courier.com/users/{user_id}/preferences/{topic_id} \
--header 'Authorization: Bearer <token>'{
"topic": {
"custom_routing": [
"direct_message"
],
"default_status": "OPTED_IN",
"has_custom_routing": true,
"status": "OPTED_IN",
"topic_id": "pt_01kx4h2jdafq8bk99mj9q2gsa2",
"topic_name": "string"
}
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
A unique identifier associated with the user whose preferences you wish to retrieve.
A unique identifier associated with a subscription topic.
Query Parameters
Query the preferences of a user for this specific tenant context.
Response
Show child attributes
Show child attributes
Update user preferences in bulk
Previous
Update or Create user preferences for a specific subscription topic
Next
⌘I