Update a draft (alias)
Identical to PUT; both apply a partial update to the supplied fields.
PATCH
/
email_inboxes
/
{inbox_id}
/
drafts
/
{draft_id}
Update a draft (alias)
curl --request PATCH \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from_email": "<string>",
"from_name": "<string>",
"to": [
"<string>"
],
"cc": [
"<string>"
],
"bcc": [
"<string>"
],
"reply_to": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"text": "<string>",
"html": "<string>",
"headers": {},
"attachments": [
{}
],
"labels": [
"<string>"
],
"tags": [
"<string>"
],
"metadata": {}
}
'import requests
url = "https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}"
payload = {
"from_email": "<string>",
"from_name": "<string>",
"to": ["<string>"],
"cc": ["<string>"],
"bcc": ["<string>"],
"reply_to": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"text": "<string>",
"html": "<string>",
"headers": {},
"attachments": [{}],
"labels": ["<string>"],
"tags": ["<string>"],
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from_email: '<string>',
from_name: '<string>',
to: ['<string>'],
cc: ['<string>'],
bcc: ['<string>'],
reply_to: '<string>',
subject: '<string>',
text_body: '<string>',
html_body: '<string>',
text: '<string>',
html: '<string>',
headers: {},
attachments: [{}],
labels: ['<string>'],
tags: ['<string>'],
metadata: {}
})
};
fetch('https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'from_email' => '<string>',
'from_name' => '<string>',
'to' => [
'<string>'
],
'cc' => [
'<string>'
],
'bcc' => [
'<string>'
],
'reply_to' => '<string>',
'subject' => '<string>',
'text_body' => '<string>',
'html_body' => '<string>',
'text' => '<string>',
'html' => '<string>',
'headers' => [
],
'attachments' => [
[
]
],
'labels' => [
'<string>'
],
'tags' => [
'<string>'
],
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}"
payload := strings.NewReader("{\n \"from_email\": \"<string>\",\n \"from_name\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"reply_to\": \"<string>\",\n \"subject\": \"<string>\",\n \"text_body\": \"<string>\",\n \"html_body\": \"<string>\",\n \"text\": \"<string>\",\n \"html\": \"<string>\",\n \"headers\": {},\n \"attachments\": [\n {}\n ],\n \"labels\": [\n \"<string>\"\n ],\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from_email\": \"<string>\",\n \"from_name\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"reply_to\": \"<string>\",\n \"subject\": \"<string>\",\n \"text_body\": \"<string>\",\n \"html_body\": \"<string>\",\n \"text\": \"<string>\",\n \"html\": \"<string>\",\n \"headers\": {},\n \"attachments\": [\n {}\n ],\n \"labels\": [\n \"<string>\"\n ],\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_email\": \"<string>\",\n \"from_name\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"reply_to\": \"<string>\",\n \"subject\": \"<string>\",\n \"text_body\": \"<string>\",\n \"html_body\": \"<string>\",\n \"text\": \"<string>\",\n \"html\": \"<string>\",\n \"headers\": {},\n \"attachments\": [\n {}\n ],\n \"labels\": [\n \"<string>\"\n ],\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"data": {
"record_type": "email_draft",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"inbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": "<string>",
"from_name": "<string>",
"to": [
{
"email": "<string>",
"name": "<string>"
}
],
"cc": [
{
"email": "<string>",
"name": "<string>"
}
],
"bcc": [
{
"email": "<string>",
"name": "<string>"
}
],
"reply_to": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"headers": {},
"attachments": [
{}
],
"labels": [
"<string>"
],
"tags": [
"<string>"
],
"metadata": {},
"reply_to_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"thread_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sent_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sent_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"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"
}
}
]
}{
"errors": [
{
"code": "10016",
"title": "Service Unavailable",
"detail": "Drafts are temporarily unavailable. Please try again later."
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Email inbox UUID.
Email draft UUID.
Body
application/json
All fields are optional — a draft may be saved incomplete. account_id,
inbox_id, status, sent_at, sent_message_id, reply_to_message_id and
thread_id are server-owned and ignored if supplied.
Maximum string length:
255Alias for text_body, matching the send endpoint.
Alias for html_body, matching the send endpoint.
Show child attributes
Show child attributes
Response
The updated draft.
An unsent, mutable draft message belonging to an inbox.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Update a draft (alias)
curl --request PATCH \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from_email": "<string>",
"from_name": "<string>",
"to": [
"<string>"
],
"cc": [
"<string>"
],
"bcc": [
"<string>"
],
"reply_to": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"text": "<string>",
"html": "<string>",
"headers": {},
"attachments": [
{}
],
"labels": [
"<string>"
],
"tags": [
"<string>"
],
"metadata": {}
}
'import requests
url = "https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}"
payload = {
"from_email": "<string>",
"from_name": "<string>",
"to": ["<string>"],
"cc": ["<string>"],
"bcc": ["<string>"],
"reply_to": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"text": "<string>",
"html": "<string>",
"headers": {},
"attachments": [{}],
"labels": ["<string>"],
"tags": ["<string>"],
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from_email: '<string>',
from_name: '<string>',
to: ['<string>'],
cc: ['<string>'],
bcc: ['<string>'],
reply_to: '<string>',
subject: '<string>',
text_body: '<string>',
html_body: '<string>',
text: '<string>',
html: '<string>',
headers: {},
attachments: [{}],
labels: ['<string>'],
tags: ['<string>'],
metadata: {}
})
};
fetch('https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'from_email' => '<string>',
'from_name' => '<string>',
'to' => [
'<string>'
],
'cc' => [
'<string>'
],
'bcc' => [
'<string>'
],
'reply_to' => '<string>',
'subject' => '<string>',
'text_body' => '<string>',
'html_body' => '<string>',
'text' => '<string>',
'html' => '<string>',
'headers' => [
],
'attachments' => [
[
]
],
'labels' => [
'<string>'
],
'tags' => [
'<string>'
],
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}"
payload := strings.NewReader("{\n \"from_email\": \"<string>\",\n \"from_name\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"reply_to\": \"<string>\",\n \"subject\": \"<string>\",\n \"text_body\": \"<string>\",\n \"html_body\": \"<string>\",\n \"text\": \"<string>\",\n \"html\": \"<string>\",\n \"headers\": {},\n \"attachments\": [\n {}\n ],\n \"labels\": [\n \"<string>\"\n ],\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from_email\": \"<string>\",\n \"from_name\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"reply_to\": \"<string>\",\n \"subject\": \"<string>\",\n \"text_body\": \"<string>\",\n \"html_body\": \"<string>\",\n \"text\": \"<string>\",\n \"html\": \"<string>\",\n \"headers\": {},\n \"attachments\": [\n {}\n ],\n \"labels\": [\n \"<string>\"\n ],\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_email\": \"<string>\",\n \"from_name\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"cc\": [\n \"<string>\"\n ],\n \"bcc\": [\n \"<string>\"\n ],\n \"reply_to\": \"<string>\",\n \"subject\": \"<string>\",\n \"text_body\": \"<string>\",\n \"html_body\": \"<string>\",\n \"text\": \"<string>\",\n \"html\": \"<string>\",\n \"headers\": {},\n \"attachments\": [\n {}\n ],\n \"labels\": [\n \"<string>\"\n ],\n \"tags\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"data": {
"record_type": "email_draft",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"inbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": "<string>",
"from_name": "<string>",
"to": [
{
"email": "<string>",
"name": "<string>"
}
],
"cc": [
{
"email": "<string>",
"name": "<string>"
}
],
"bcc": [
{
"email": "<string>",
"name": "<string>"
}
],
"reply_to": "<string>",
"subject": "<string>",
"text_body": "<string>",
"html_body": "<string>",
"headers": {},
"attachments": [
{}
],
"labels": [
"<string>"
],
"tags": [
"<string>"
],
"metadata": {},
"reply_to_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"thread_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sent_message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sent_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"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"
}
}
]
}{
"errors": [
{
"code": "10016",
"title": "Service Unavailable",
"detail": "Drafts are temporarily unavailable. Please try again later."
}
]
}