Update an email template
Updates one or more fields of the specified email template and returns the updated template.
PATCH
/
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 EmailTemplate = await client.emailTemplates.update('id', {
name: 'name',
});
console.log(EmailTemplate.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
)
email_template = client.email_templates.update(
id="id",
name="name",
)
print(email_template.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"),
)
emailTemplate, err := client.EmailTemplates.Update(
context.TODO(),
"id",
telnyx.EmailTemplateUpdateParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", emailTemplate.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.EmailTemplateUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
EmailTemplateUpdateParams params = EmailTemplateUpdateParams.builder()
.name("name")
.build();
var response = client.emailTemplates().update("id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_template = telnyx.email_templates.update("id", name: "name")
puts(email_template)<?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 {
$email_template = $client->emailTemplates->update(
'id',
name: 'name',
);
var_dump($email_template);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-templates update \
--api-key 'My API Key' \
--id id \
--name namecurl --request PATCH \
--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 EmailTemplate = await client.emailTemplates.update('id', {
name: 'name',
});
console.log(EmailTemplate.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
)
email_template = client.email_templates.update(
id="id",
name="name",
)
print(email_template.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"),
)
emailTemplate, err := client.EmailTemplates.Update(
context.TODO(),
"id",
telnyx.EmailTemplateUpdateParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", emailTemplate.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.EmailTemplateUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
EmailTemplateUpdateParams params = EmailTemplateUpdateParams.builder()
.name("name")
.build();
var response = client.emailTemplates().update("id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_template = telnyx.email_templates.update("id", name: "name")
puts(email_template)<?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 {
$email_template = $client->emailTemplates->update(
'id',
name: 'name',
);
var_dump($email_template);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-templates update \
--api-key 'My API Key' \
--id id \
--name namecurl --request PATCH \
--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"
}
}
]
}