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 preference = await client.users.preferences.retrieve('user_id');
console.log(preference.items);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
preference = client.users.preferences.retrieve(
user_id="user_id",
)
print(preference.items)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"),
)
preference, err := client.Users.Preferences.Get(
context.TODO(),
"user_id",
courier.UserPreferenceGetParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", preference.Items)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.users.preferences.PreferenceRetrieveParams;
import com.courier.models.users.preferences.PreferenceRetrieveResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
PreferenceRetrieveResponse preference = client.users().preferences().retrieve("user_id");
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
preference = courier.users.preferences.retrieve("user_id")
puts(preference)<?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 {
$preference = $client->users->preferences->retrieve(
'user_id', tenantID: 'tenant_id'
);
var_dump($preference);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Users.Preferences;
CourierClient client = new();
PreferenceRetrieveParams parameters = new() { UserID = "user_id" };
var preference = await client.Users.Preferences.Retrieve(parameters);
Console.WriteLine(preference);courier users:preferences retrieve \
--api-key 'My API Key' \
--user-id user_idcurl --request GET \
--url https://api.courier.com/users/{user_id}/preferences \
--header 'Authorization: Bearer <token>'{
"paging": {
"cursor": "MTpFWUNFRkRRN0c1WERTRTU2",
"more": true
},
"items": [
{
"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's preferences
Fetch all user preferences.
GET
/
users
/
{user_id}
/
preferences
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 preference = await client.users.preferences.retrieve('user_id');
console.log(preference.items);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
preference = client.users.preferences.retrieve(
user_id="user_id",
)
print(preference.items)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"),
)
preference, err := client.Users.Preferences.Get(
context.TODO(),
"user_id",
courier.UserPreferenceGetParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", preference.Items)
}
package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.users.preferences.PreferenceRetrieveParams;
import com.courier.models.users.preferences.PreferenceRetrieveResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
PreferenceRetrieveResponse preference = client.users().preferences().retrieve("user_id");
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
preference = courier.users.preferences.retrieve("user_id")
puts(preference)<?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 {
$preference = $client->users->preferences->retrieve(
'user_id', tenantID: 'tenant_id'
);
var_dump($preference);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Users.Preferences;
CourierClient client = new();
PreferenceRetrieveParams parameters = new() { UserID = "user_id" };
var preference = await client.Users.Preferences.Retrieve(parameters);
Console.WriteLine(preference);courier users:preferences retrieve \
--api-key 'My API Key' \
--user-id user_idcurl --request GET \
--url https://api.courier.com/users/{user_id}/preferences \
--header 'Authorization: Bearer <token>'{
"paging": {
"cursor": "MTpFWUNFRkRRN0c1WERTRTU2",
"more": true
},
"items": [
{
"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.
Query Parameters
Query the preferences of a user for this specific tenant context.
⌘I