Update a draft (alias)
Identical to PUT; both apply a partial update to the supplied fields.
PATCH
/
email_inboxes
/
{inbox_id}
/
drafts
/
{draft_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.emailInboxes.drafts.patch('inbox_id', 'draft_id', {
from_email: 'from_email',
});
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_inboxes.drafts.patch(
inbox_id="inbox_id",
draft_id="draft_id",
from_email="from_email",
)
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.EmailInboxes.Drafts.Patch(
context.TODO(),
"inbox_id",
"draft_id",
telnyx.EmailInboxeDraftPatchParams{
FromEmail: telnyx.String("from_email"),
},
)
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.emailInboxes.drafts.DraftPatchParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
DraftPatchParams params = DraftPatchParams.builder()
.fromEmail("from_email")
.build();
var response = client.emailInboxes().drafts().patch("inbox_id", "draft_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.email_inboxes.drafts.patch("inbox_id", "draft_id", from_email: "from_email")
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->emailInboxes->drafts->patch(
'inbox_id',
'draft_id',
from_email: 'from_email',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts patch \
--api-key 'My API Key' \
--inbox-id inbox_id \
--draft-id draft_id \
--from-email from_emailcurl --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 '
{
"subject": "Quarterly update (revised)",
"text_body": "Updated body."
}
'{
"data": {
"record_type": "email_draft",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"inbox_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "draft",
"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",
"attachments": [],
"labels": [
"string"
],
"tags": [
"string"
],
"reply_to_message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"sent_message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"sent_at": "2024-01-23T18:10:02.574Z",
"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"
}
}
]
}{
"errors": [
{
"code": "10016",
"title": "Service Unavailable",
"detail": "Drafts are temporarily unavailable. Please try again later."
}
]
}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 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
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.emailInboxes.drafts.patch('inbox_id', 'draft_id', {
from_email: 'from_email',
});
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_inboxes.drafts.patch(
inbox_id="inbox_id",
draft_id="draft_id",
from_email="from_email",
)
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.EmailInboxes.Drafts.Patch(
context.TODO(),
"inbox_id",
"draft_id",
telnyx.EmailInboxeDraftPatchParams{
FromEmail: telnyx.String("from_email"),
},
)
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.emailInboxes.drafts.DraftPatchParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
DraftPatchParams params = DraftPatchParams.builder()
.fromEmail("from_email")
.build();
var response = client.emailInboxes().drafts().patch("inbox_id", "draft_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.email_inboxes.drafts.patch("inbox_id", "draft_id", from_email: "from_email")
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->emailInboxes->drafts->patch(
'inbox_id',
'draft_id',
from_email: 'from_email',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts patch \
--api-key 'My API Key' \
--inbox-id inbox_id \
--draft-id draft_id \
--from-email from_emailcurl --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 '
{
"subject": "Quarterly update (revised)",
"text_body": "Updated body."
}
'{
"data": {
"record_type": "email_draft",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"inbox_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "draft",
"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",
"attachments": [],
"labels": [
"string"
],
"tags": [
"string"
],
"reply_to_message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"sent_message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"sent_at": "2024-01-23T18:10:02.574Z",
"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"
}
}
]
}{
"errors": [
{
"code": "10016",
"title": "Service Unavailable",
"detail": "Drafts are temporarily unavailable. Please try again later."
}
]
}