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 postTenantTemplatePublishResponse = await client.tenants.templates.publish('template_id', {
tenant_id: 'tenant_id',
});
console.log(postTenantTemplatePublishResponse.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
)
post_tenant_template_publish_response = client.tenants.templates.publish(
template_id="template_id",
tenant_id="tenant_id",
)
print(post_tenant_template_publish_response.id)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"),
)
postTenantTemplatePublishResponse, err := client.Tenants.Templates.Publish(
context.TODO(),
"template_id",
courier.TenantTemplatePublishParams{
TenantID: "tenant_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", postTenantTemplatePublishResponse.ID)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.tenants.PostTenantTemplatePublishResponse;
import com.courier.models.tenants.templates.TemplatePublishParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplatePublishParams params = TemplatePublishParams.builder()
.tenantId("tenant_id")
.templateId("template_id")
.build();
PostTenantTemplatePublishResponse postTenantTemplatePublishResponse = client.tenants().templates().publish(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
post_tenant_template_publish_response = courier.tenants.templates.publish("template_id", tenant_id: "tenant_id")
puts(post_tenant_template_publish_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 {
$postTenantTemplatePublishResponse = $client->tenants->templates->publish(
'template_id', tenantID: 'tenant_id', version: 'version'
);
var_dump($postTenantTemplatePublishResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Tenants.Templates;
CourierClient client = new();
TemplatePublishParams parameters = new()
{
TenantID = "tenant_id",
TemplateID = "template_id",
};
var postTenantTemplatePublishResponse = await client.Tenants.Templates.Publish(parameters);
Console.WriteLine(postTenantTemplatePublishResponse);courier tenants:templates publish \
--api-key 'My API Key' \
--tenant-id tenant_id \
--template-id template_idcurl --request POST \
--url https://api.courier.com/tenants/{tenant_id}/templates/{template_id}/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version": "latest"
}
'{
"id": "tenant_abc",
"version": "string",
"published_at": "2024-01-15T10:30:00.000Z"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Courier Create
Publish a Tenant Template
Publishes a specific version of a notification template for a tenant.
The template must already exist in the tenant’s notification map. If no version is specified, defaults to publishing the “latest” version.
POST
/
tenants
/
{tenant_id}
/
templates
/
{template_id}
/
publish
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 postTenantTemplatePublishResponse = await client.tenants.templates.publish('template_id', {
tenant_id: 'tenant_id',
});
console.log(postTenantTemplatePublishResponse.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
)
post_tenant_template_publish_response = client.tenants.templates.publish(
template_id="template_id",
tenant_id="tenant_id",
)
print(post_tenant_template_publish_response.id)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"),
)
postTenantTemplatePublishResponse, err := client.Tenants.Templates.Publish(
context.TODO(),
"template_id",
courier.TenantTemplatePublishParams{
TenantID: "tenant_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", postTenantTemplatePublishResponse.ID)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.models.tenants.PostTenantTemplatePublishResponse;
import com.courier.models.tenants.templates.TemplatePublishParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
TemplatePublishParams params = TemplatePublishParams.builder()
.tenantId("tenant_id")
.templateId("template_id")
.build();
PostTenantTemplatePublishResponse postTenantTemplatePublishResponse = client.tenants().templates().publish(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
post_tenant_template_publish_response = courier.tenants.templates.publish("template_id", tenant_id: "tenant_id")
puts(post_tenant_template_publish_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 {
$postTenantTemplatePublishResponse = $client->tenants->templates->publish(
'template_id', tenantID: 'tenant_id', version: 'version'
);
var_dump($postTenantTemplatePublishResponse);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using TryCourier;
using TryCourier.Models.Tenants.Templates;
CourierClient client = new();
TemplatePublishParams parameters = new()
{
TenantID = "tenant_id",
TemplateID = "template_id",
};
var postTenantTemplatePublishResponse = await client.Tenants.Templates.Publish(parameters);
Console.WriteLine(postTenantTemplatePublishResponse);courier tenants:templates publish \
--api-key 'My API Key' \
--tenant-id tenant_id \
--template-id template_idcurl --request POST \
--url https://api.courier.com/tenants/{tenant_id}/templates/{template_id}/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version": "latest"
}
'{
"id": "tenant_abc",
"version": "string",
"published_at": "2024-01-15T10:30:00.000Z"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"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
Id of the tenant that owns the template.
Id of the template to be published.
Body
application/json
Request body for publishing a tenant template version
The version of the template to publish (e.g., "v1", "v2", "latest"). If not provided, defaults to "latest".
⌘I