User Profiles
Create a Profile
Merges the supplied values into a user’s profile, creating it if absent and leaving any key you omit untouched. Prefer this for everyday writes.
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: { email: 'jdoe@example.com', phone_number: '+15558675309' },
});
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={
"email": "jdoe@example.com",
"phone_number": "+15558675309",
},
)
print(profile.status)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/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{
"email": "jdoe@example.com",
"phone_number": "+15558675309",
},
},
)
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("email", JsonValue.from("bar"))
.putAdditionalProperty("phone_number", 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: {email: "bar", phone_number: "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: ['email' => 'bar', 'phone_number' => 'bar'],
idempotencyKey: 'order-ORD-456-user-123',
xIdempotencyExpiration: '1785312000',
);
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>()
{
{ "email", JsonSerializer.SerializeToElement("bar") },
{ "phone_number", 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 '{email: bar, phone_number: bar}'curl --request POST \
--url https://api.courier.com/profiles/{user_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"profile": {
"email": "jdoe@example.com",
"phone_number": "+15558675309"
}
}
'{
"status": "SUCCESS"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Headers
A unique key that makes this request idempotent. If Courier receives another request with the same Idempotency-Key, it returns the stored response from the first request without performing the operation again (including the original status code and any error). Use it to safely retry POST requests after network failures without risking duplicate sends. The key is scoped to this endpoint.
Path Parameters
⌘I
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: { email: 'jdoe@example.com', phone_number: '+15558675309' },
});
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={
"email": "jdoe@example.com",
"phone_number": "+15558675309",
},
)
print(profile.status)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/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{
"email": "jdoe@example.com",
"phone_number": "+15558675309",
},
},
)
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("email", JsonValue.from("bar"))
.putAdditionalProperty("phone_number", 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: {email: "bar", phone_number: "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: ['email' => 'bar', 'phone_number' => 'bar'],
idempotencyKey: 'order-ORD-456-user-123',
xIdempotencyExpiration: '1785312000',
);
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>()
{
{ "email", JsonSerializer.SerializeToElement("bar") },
{ "phone_number", 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 '{email: bar, phone_number: bar}'curl --request POST \
--url https://api.courier.com/profiles/{user_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"profile": {
"email": "jdoe@example.com",
"phone_number": "+15558675309"
}
}
'{
"status": "SUCCESS"
}{
"message": "Example message text",
"type": "invalid_request_error"
}