Create a draft
Creates an unsent draft in the inbox. Every field is optional — a draft is a work-in-progress and may be saved incomplete. Send-time requirements (sender, subject, at least one recipient) are enforced when the draft is sent, not when it is created.
Drafts are unbillable and emit no Email Detail Records until they are 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.create('inbox_id');
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.create(
inbox_id="inbox_id",
)
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.New(
context.TODO(),
"inbox_id",
telnyx.EmailInboxeDraftNewParams{
},
)
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.DraftCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
DraftCreateParams params = DraftCreateParams.builder()
.build();
var response = client.emailInboxes().drafts().create("inbox_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_draft = telnyx.email_inboxes.drafts.create("inbox_id")
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->create(
'inbox_id',
);
var_dump($email_draft);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts create \
--api-key 'My API Key' \
--inbox-id inbox_idcurl --request POST \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": [
{
"email": "recipient@example.com",
"name": "Recipient"
}
],
"subject": "Quarterly update",
"text_body": "Here is the update.",
"labels": [
"important"
]
}
'{
"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.
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 created 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.create('inbox_id');
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.create(
inbox_id="inbox_id",
)
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.New(
context.TODO(),
"inbox_id",
telnyx.EmailInboxeDraftNewParams{
},
)
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.DraftCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
DraftCreateParams params = DraftCreateParams.builder()
.build();
var response = client.emailInboxes().drafts().create("inbox_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_draft = telnyx.email_inboxes.drafts.create("inbox_id")
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->create(
'inbox_id',
);
var_dump($email_draft);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts create \
--api-key 'My API Key' \
--inbox-id inbox_idcurl --request POST \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": [
{
"email": "recipient@example.com",
"name": "Recipient"
}
],
"subject": "Quarterly update",
"text_body": "Here is the update.",
"labels": [
"important"
]
}
'{
"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."
}
]
}