Update a draft
Updates the supplied fields on a draft. account_id and inbox_id are
server-owned and ignored if present in the body, so a draft can never be moved
between accounts or inboxes.
A draft that is being sent or has already been sent is immutable and returns 422 — modifying it would race with delivery or rewrite the record of what was actually sent.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const EmailDraft = await client.emailInboxes.drafts.update('inbox_id', 'draft_id', {
from_email: 'from_email',
});
console.log(EmailDraft.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_draft = client.email_inboxes.drafts.update(
inbox_id="inbox_id",
draft_id="draft_id",
from_email="from_email",
)
print(email_draft.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"),
)
draft, err := client.EmailInboxes.Drafts.Update(
context.TODO(),
"inbox_id",
"draft_id",
telnyx.EmailInboxeDraftUpdateParams{
FromEmail: telnyx.String("from_email"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", draft.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.emailInboxes.drafts.DraftUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
DraftUpdateParams params = DraftUpdateParams.builder()
.fromEmail("from_email")
.build();
var response = client.emailInboxes().drafts().update("inbox_id", "draft_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_draft = telnyx.email_inboxes.drafts.update("inbox_id", "draft_id", from_email: "from_email")
puts(email_draft)<?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_draft = $client->emailInboxes->drafts->update(
'inbox_id',
'draft_id',
from_email: 'from_email',
);
var_dump($email_draft);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts update \
--api-key 'My API Key' \
--inbox-id inbox_id \
--draft-id draft_id \
--from-email from_emailcurl --request PUT \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subject": "Quarterly update (revised)",
"text_body": "Updated 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
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.
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?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const EmailDraft = await client.emailInboxes.drafts.update('inbox_id', 'draft_id', {
from_email: 'from_email',
});
console.log(EmailDraft.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_draft = client.email_inboxes.drafts.update(
inbox_id="inbox_id",
draft_id="draft_id",
from_email="from_email",
)
print(email_draft.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"),
)
draft, err := client.EmailInboxes.Drafts.Update(
context.TODO(),
"inbox_id",
"draft_id",
telnyx.EmailInboxeDraftUpdateParams{
FromEmail: telnyx.String("from_email"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", draft.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.emailInboxes.drafts.DraftUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
DraftUpdateParams params = DraftUpdateParams.builder()
.fromEmail("from_email")
.build();
var response = client.emailInboxes().drafts().update("inbox_id", "draft_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_draft = telnyx.email_inboxes.drafts.update("inbox_id", "draft_id", from_email: "from_email")
puts(email_draft)<?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_draft = $client->emailInboxes->drafts->update(
'inbox_id',
'draft_id',
from_email: 'from_email',
);
var_dump($email_draft);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts update \
--api-key 'My API Key' \
--inbox-id inbox_id \
--draft-id draft_id \
--from-email from_emailcurl --request PUT \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts/{draft_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subject": "Quarterly update (revised)",
"text_body": "Updated 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."
}
]
}