Replace an email template
Replaces template fields. Behaves identically to PATCH; provided for compatibility with Phoenix resource routes.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.emailTemplates.replace('id', {
name: 'name',
});
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.email_templates.replace(
id="id",
name="name",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.EmailTemplates.Replace(
context.TODO(),
"id",
telnyx.EmailTemplateReplaceParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.emailTemplates.EmailTemplateReplaceParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
EmailTemplateReplaceParams params = EmailTemplateReplaceParams.builder()
.name("name")
.build();
var response = client.emailTemplates().replace("id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.email_templates.replace("id", name: "name")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->emailTemplates->replace(
'id',
name: 'name',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-templates replace \
--api-key 'My API Key' \
--id id \
--name namecurl --request PUT \
--url https://api.telnyx.com/v2/email_templates/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subject": "Welcome aboard, {{first_name}}!"
}
'{
"data": {
"record_type": "email_template",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"subject": "string",
"html_body": "string",
"text_body": "string",
"variables": [
"string"
],
"variables_mode": "automatic",
"strict_variables": false,
"autoescape": false,
"variable_schema": null,
"created_at": "2024-01-23T18:10:02.574Z",
"updated_at": "2024-01-23T18:10:02.574Z"
}
}{
"errors": [
{
"code": "10006",
"title": "Not authorized",
"detail": "Invalid API key",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10006"
}
}
]
}{
"errors": [
{
"code": "10001",
"title": "Not Found",
"detail": "The requested resource was not found"
}
]
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "subject can't be blank",
"source": {
"pointer": "/data/attributes/subject"
}
}
]
}Authorizations
Telnyx API key supplied as Authorization: Bearer <token>. In production, auth may be validated by the API gateway and forwarded via Telnyx auth headers.
Path Parameters
Email template UUID.
Body
255^[A-Za-z0-9 _-]+$Liquid template subject.
255Liquid template HTML body.
Liquid template text body.
Persisted variable names. In automatic mode a non-null array is rejected; in explicit mode this is the exact manual array and each item is limited to 255 Unicode code points.
255Controls how variables is maintained. Setting automatic re-extracts immediately from the effective subject, HTML body, and text body and rejects a simultaneous non-null array. Setting explicit requires the exact non-null array, including valid []. With the mode omitted, a non-null array selects explicit mode, null selects automatic mode, and omitting both fields preserves the current mode. Source-content changes re-extract only in automatic mode.
automatic, explicit Per-template strict variable-validation setting.
Per-template HTML autoescaping setting.
Structured variable requirements. Required variables cannot define defaults; invalid combinations return 422. Set to null to clear the schema.
Show child attributes
Show child attributes
Response
Template updated.
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.emailTemplates.replace('id', {
name: 'name',
});
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.email_templates.replace(
id="id",
name="name",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.EmailTemplates.Replace(
context.TODO(),
"id",
telnyx.EmailTemplateReplaceParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.emailTemplates.EmailTemplateReplaceParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
EmailTemplateReplaceParams params = EmailTemplateReplaceParams.builder()
.name("name")
.build();
var response = client.emailTemplates().replace("id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.email_templates.replace("id", name: "name")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->emailTemplates->replace(
'id',
name: 'name',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-templates replace \
--api-key 'My API Key' \
--id id \
--name namecurl --request PUT \
--url https://api.telnyx.com/v2/email_templates/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subject": "Welcome aboard, {{first_name}}!"
}
'{
"data": {
"record_type": "email_template",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"subject": "string",
"html_body": "string",
"text_body": "string",
"variables": [
"string"
],
"variables_mode": "automatic",
"strict_variables": false,
"autoescape": false,
"variable_schema": null,
"created_at": "2024-01-23T18:10:02.574Z",
"updated_at": "2024-01-23T18:10:02.574Z"
}
}{
"errors": [
{
"code": "10006",
"title": "Not authorized",
"detail": "Invalid API key",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10006"
}
}
]
}{
"errors": [
{
"code": "10001",
"title": "Not Found",
"detail": "The requested resource was not found"
}
]
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "subject can't be blank",
"source": {
"pointer": "/data/attributes/subject"
}
}
]
}