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: { foo: 'bar' } });
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={
"foo": "bar"
},
)
print(response.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"),
)
response, err := client.Profiles.Replace(
context.TODO(),
"user_id",
courier.ProfileReplaceParams{
Profile: map[string]any{
"foo": "bar",
},
},
)
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("foo", 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: {foo: "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: ['foo' => '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>()
{
{ "foo", 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 '{foo: bar}'curl --request PUT \
--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
Replace a profile
When using PUT, be sure to include all the key-value pairs required by the recipient’s profile.
Any key-value pairs that exist in the profile but fail to be included in the PUT request will be
removed from the profile. Remember, a PUT update is a full replacement of the data. For partial updates,
use the Patch request.
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: { foo: 'bar' } });
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={
"foo": "bar"
},
)
print(response.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"),
)
response, err := client.Profiles.Replace(
context.TODO(),
"user_id",
courier.ProfileReplaceParams{
Profile: map[string]any{
"foo": "bar",
},
},
)
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("foo", 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: {foo: "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: ['foo' => '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>()
{
{ "foo", 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 '{foo: bar}'curl --request PUT \
--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 user profile.
Body
application/json
Response
Available options:
SUCCESS ⌘I