Replace an email template
Replaces template fields. Behaves identically to PATCH; provided for compatibility with Phoenix resource routes.
PUT
/
email_templates
/
{id}
JavaScript
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"
],
"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
application/json
Pattern:
^[A-Za-z0-9 _-]+$Liquid template subject.
Liquid template HTML body.
Liquid template text body.
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?
JavaScript
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"
],
"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"
}
}
]
}