JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
await client.users.tenants.addMultiple('user_id', { tenants: [{ tenant_id: 'tenant_id' }] });import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
client.users.tenants.add_multiple(
user_id="user_id",
tenants=[{
"tenant_id": "tenant_id"
}],
)package main
import (
"context"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Users.Tenants.AddMultiple(
context.TODO(),
"user_id",
courier.UserTenantAddMultipleParams{
Tenants: []courier.TenantAssociationParam{{
TenantID: "tenant_id",
}},
},
)
if err != nil {
panic(err.Error())
}
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.tenants.TenantAssociation;
import com.courier.models.users.tenants.TenantAddMultipleParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TenantAddMultipleParams params = TenantAddMultipleParams.builder()
.userId("user_id")
.addTenant(TenantAssociation.builder()
.tenantId("tenant_id")
.build())
.build();
client.users().tenants().addMultiple(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
result = courier.users.tenants.add_multiple("user_id", tenants: [{tenant_id: "tenant_id"}])
puts(result)<?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 {
$result = $client->users->tenants->addMultiple(
'user_id',
tenants: [
[
'tenantID' => 'tenant_id',
'profile' => ['foo' => 'bar'],
'type' => 'user',
'userID' => 'user_id',
],
],
);
var_dump($result);
} catch (APIException $e) {
echo $e->getMessage();
}using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using Tenants = TryCourier.Models.Tenants;
using TryCourier.Models.Users.Tenants;
CourierClient client = new();
TenantAddMultipleParams parameters = new()
{
UserID = "user_id",
Tenants =
[
new()
{
TenantID = "tenant_id",
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Type = Tenants::Type.User,
UserID = "user_id",
},
],
};
await client.Users.Tenants.AddMultiple(parameters);courier users:tenants add-multiple \
--api-key 'My API Key' \
--user-id user_id \
--tenant '{tenant_id: tenant_id}'curl --request PUT \
--url https://api.courier.com/users/{user_id}/tenants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tenants": [
{
"tenant_id": "<string>",
"user_id": "<string>",
"type": "user",
"profile": {}
}
]
}
'User Tenants
Add a User to Multiple Tenants
This endpoint is used to add a user to multiple tenants in one call. A custom profile can also be supplied for each tenant. This profile will be merged with the user’s main profile when sending to the user with that tenant.
PUT
/
users
/
{user_id}
/
tenants
JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
await client.users.tenants.addMultiple('user_id', { tenants: [{ tenant_id: 'tenant_id' }] });import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
client.users.tenants.add_multiple(
user_id="user_id",
tenants=[{
"tenant_id": "tenant_id"
}],
)package main
import (
"context"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Users.Tenants.AddMultiple(
context.TODO(),
"user_id",
courier.UserTenantAddMultipleParams{
Tenants: []courier.TenantAssociationParam{{
TenantID: "tenant_id",
}},
},
)
if err != nil {
panic(err.Error())
}
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.tenants.TenantAssociation;
import com.courier.models.users.tenants.TenantAddMultipleParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TenantAddMultipleParams params = TenantAddMultipleParams.builder()
.userId("user_id")
.addTenant(TenantAssociation.builder()
.tenantId("tenant_id")
.build())
.build();
client.users().tenants().addMultiple(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
result = courier.users.tenants.add_multiple("user_id", tenants: [{tenant_id: "tenant_id"}])
puts(result)<?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 {
$result = $client->users->tenants->addMultiple(
'user_id',
tenants: [
[
'tenantID' => 'tenant_id',
'profile' => ['foo' => 'bar'],
'type' => 'user',
'userID' => 'user_id',
],
],
);
var_dump($result);
} catch (APIException $e) {
echo $e->getMessage();
}using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using Tenants = TryCourier.Models.Tenants;
using TryCourier.Models.Users.Tenants;
CourierClient client = new();
TenantAddMultipleParams parameters = new()
{
UserID = "user_id",
Tenants =
[
new()
{
TenantID = "tenant_id",
Profile = new Dictionary<string, JsonElement>()
{
{ "foo", JsonSerializer.SerializeToElement("bar") }
},
Type = Tenants::Type.User,
UserID = "user_id",
},
],
};
await client.Users.Tenants.AddMultiple(parameters);courier users:tenants add-multiple \
--api-key 'My API Key' \
--user-id user_id \
--tenant '{tenant_id: tenant_id}'curl --request PUT \
--url https://api.courier.com/users/{user_id}/tenants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tenants": [
{
"tenant_id": "<string>",
"user_id": "<string>",
"type": "user",
"profile": {}
}
]
}
'Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The user's ID. This can be any uniquely identifiable string.
Body
application/json
Show child attributes
Show child attributes
Response
204 - undefined
⌘I