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.profiles.replace('user_id', {
profile: {
email: 'jdoe@example.com',
phone_number: '+15558675309',
locale: 'en-US',
},
});
console.log(response.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
)
response = client.profiles.replace(
user_id="user_id",
profile={
"email": "jdoe@example.com",
"phone_number": "+15558675309",
"locale": "en-US",
},
)
print(response.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"),
)
response, err := client.Profiles.Replace(
context.TODO(),
"user_id",
courier.ProfileReplaceParams{
Profile: map[string]any{
"email": "jdoe@example.com",
"phone_number": "+15558675309",
"locale": "en-US",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.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.ProfileReplaceParams;
import com.courier.models.profiles.ProfileReplaceResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
ProfileReplaceParams params = ProfileReplaceParams.builder()
.userId("user_id")
.profile(ProfileReplaceParams.Profile.builder()
.putAdditionalProperty("email", JsonValue.from("bar"))
.putAdditionalProperty("phone_number", JsonValue.from("bar"))
.putAdditionalProperty("locale", JsonValue.from("bar"))
.build())
.build();
ProfileReplaceResponse response = client.profiles().replace(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.profiles.replace("user_id", profile: {email: "bar", phone_number: "bar", locale: "bar"})
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->profiles->replace(
'user_id',
profile: ['email' => 'bar', 'phone_number' => 'bar', 'locale' => 'bar'],
);
var_dump($response);
} 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();
ProfileReplaceParams parameters = new()
{
UserID = "user_id",
Profile = new Dictionary<string, JsonElement>()
{
{ "email", JsonSerializer.SerializeToElement("bar") },
{ "phone_number", JsonSerializer.SerializeToElement("bar") },
{ "locale", JsonSerializer.SerializeToElement("bar") },
},
};
var response = await client.Profiles.Replace(parameters);
Console.WriteLine(response);courier profiles replace \
--api-key 'My API Key' \
--user-id user_id \
--profile '{email: bar, phone_number: bar, locale: bar}'curl --request PUT \
--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",
"locale": "en-US"
}
}
'{
"status": "SUCCESS"
}{
"message": "Example message text",
"type": "invalid_request_error"
}User Profiles
Replace a Profile
Overwrites a user profile in full, removing any key absent from the request body. Use the patch endpoint when changing a single field.
PUT
/
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 response = await client.profiles.replace('user_id', {
profile: {
email: 'jdoe@example.com',
phone_number: '+15558675309',
locale: 'en-US',
},
});
console.log(response.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
)
response = client.profiles.replace(
user_id="user_id",
profile={
"email": "jdoe@example.com",
"phone_number": "+15558675309",
"locale": "en-US",
},
)
print(response.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"),
)
response, err := client.Profiles.Replace(
context.TODO(),
"user_id",
courier.ProfileReplaceParams{
Profile: map[string]any{
"email": "jdoe@example.com",
"phone_number": "+15558675309",
"locale": "en-US",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.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.ProfileReplaceParams;
import com.courier.models.profiles.ProfileReplaceResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
ProfileReplaceParams params = ProfileReplaceParams.builder()
.userId("user_id")
.profile(ProfileReplaceParams.Profile.builder()
.putAdditionalProperty("email", JsonValue.from("bar"))
.putAdditionalProperty("phone_number", JsonValue.from("bar"))
.putAdditionalProperty("locale", JsonValue.from("bar"))
.build())
.build();
ProfileReplaceResponse response = client.profiles().replace(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.profiles.replace("user_id", profile: {email: "bar", phone_number: "bar", locale: "bar"})
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->profiles->replace(
'user_id',
profile: ['email' => 'bar', 'phone_number' => 'bar', 'locale' => 'bar'],
);
var_dump($response);
} 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();
ProfileReplaceParams parameters = new()
{
UserID = "user_id",
Profile = new Dictionary<string, JsonElement>()
{
{ "email", JsonSerializer.SerializeToElement("bar") },
{ "phone_number", JsonSerializer.SerializeToElement("bar") },
{ "locale", JsonSerializer.SerializeToElement("bar") },
},
};
var response = await client.Profiles.Replace(parameters);
Console.WriteLine(response);courier profiles replace \
--api-key 'My API Key' \
--user-id user_id \
--profile '{email: bar, phone_number: bar, locale: bar}'curl --request PUT \
--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",
"locale": "en-US"
}
}
'{
"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 user profile.
Body
application/json
Response
Available options:
SUCCESS โI