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 profile = await client.profiles.create('user_id', { profile: { foo: 'bar' } });
console.log(profile.status);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
profile = client.profiles.create(
user_id="user_id",
profile={
"foo": "bar"
},
)
print(profile.status)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"),
)
profile, err := client.Profiles.New(
context.TODO(),
"user_id",
courier.ProfileNewParams{
Profile: map[string]any{
"foo": "bar",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", profile.Status)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.core.JsonValue;
import com.courier.models.profiles.ProfileCreateParams;
import com.courier.models.profiles.ProfileCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
ProfileCreateParams params = ProfileCreateParams.builder()
.userId("user_id")
.profile(ProfileCreateParams.Profile.builder()
.putAdditionalProperty("foo", JsonValue.from("bar"))
.build())
.build();
ProfileCreateResponse profile = client.profiles().create(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
profile = courier.profiles.create("user_id", profile: {foo: "bar"})
puts(profile)<?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 {
$profile = $client->profiles->create('user_id', profile: ['foo' => 'bar']);
var_dump($profile);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models.Profiles;
CourierClient client = new();
ProfileCreateParams parameters = new()
{
UserID = "user_id",
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
};
var profile = await client.Profiles.Create(parameters);
Console.WriteLine(profile);courier profiles create \
--api-key 'My API Key' \
--user-id user_id \
--profile '{foo: bar}'curl --request POST \
--url https://api.courier.com/profiles/{user_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"profile": {}
}'{
"status": "SUCCESS"
}{
"message": "Example message text",
"type": "invalid_request_error"
}User Profiles
Create a profile
Merge the supplied values with an existing profile or create a new profile if one doesn’t already exist.
POST
/
profiles
/
{user_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 profile = await client.profiles.create('user_id', { profile: { foo: 'bar' } });
console.log(profile.status);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
profile = client.profiles.create(
user_id="user_id",
profile={
"foo": "bar"
},
)
print(profile.status)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"),
)
profile, err := client.Profiles.New(
context.TODO(),
"user_id",
courier.ProfileNewParams{
Profile: map[string]any{
"foo": "bar",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", profile.Status)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.core.JsonValue;
import com.courier.models.profiles.ProfileCreateParams;
import com.courier.models.profiles.ProfileCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
ProfileCreateParams params = ProfileCreateParams.builder()
.userId("user_id")
.profile(ProfileCreateParams.Profile.builder()
.putAdditionalProperty("foo", JsonValue.from("bar"))
.build())
.build();
ProfileCreateResponse profile = client.profiles().create(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
profile = courier.profiles.create("user_id", profile: {foo: "bar"})
puts(profile)<?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 {
$profile = $client->profiles->create('user_id', profile: ['foo' => 'bar']);
var_dump($profile);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using TryCourier.Models.Profiles;
CourierClient client = new();
ProfileCreateParams parameters = new()
{
UserID = "user_id",
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
};
var profile = await client.Profiles.Create(parameters);
Console.WriteLine(profile);courier profiles create \
--api-key 'My API Key' \
--user-id user_id \
--profile '{foo: bar}'curl --request POST \
--url https://api.courier.com/profiles/{user_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"profile": {}
}'{
"status": "SUCCESS"
}{
"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 representing the user associated with the requested profile.
Body
application/json
Response
Available options:
SUCCESS ⌘I