List drafts in an inbox
Lists drafts newest first using stable cursor pagination. All access is scoped to the authenticated account and the given inbox.
GET
/
email_inboxes
/
{inbox_id}
/
drafts
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const response of client.emailInboxes.drafts.list()) {
console.log(response);
}import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
page = client.email_inboxes.drafts.list(
"inbox_id",
)
print(page.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"),
)
drafts, err := client.EmailInboxes.Drafts.List(
context.TODO(),
"inbox_id",
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", drafts.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
var page = client.emailInboxes().drafts().list("inbox_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
page = telnyx.email_inboxes.drafts.list("inbox_id")
puts(page)<?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 {
$page = $client->emailInboxes->drafts->list(
'inbox_id',
);
var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts list \
--api-key 'My API Key' \
--inbox-id inbox_idcurl --request GET \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts \
--header 'Authorization: Bearer <token>'{
"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"
}
],
"meta": {
"page_size": 50,
"page_cursor": "<string>"
}
}{
"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": "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.
Query Parameters
Restrict results to drafts in this state.
Available options:
draft, sending, sent Number of results to return. Defaults to 25; maximum is 100.
Required range:
1 <= x <= 100Opaque cursor returned by the previous page.
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
});
// Automatically fetches more pages as needed.
for await (const response of client.emailInboxes.drafts.list()) {
console.log(response);
}import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
page = client.email_inboxes.drafts.list(
"inbox_id",
)
print(page.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"),
)
drafts, err := client.EmailInboxes.Drafts.List(
context.TODO(),
"inbox_id",
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", drafts.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
var page = client.emailInboxes().drafts().list("inbox_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
page = telnyx.email_inboxes.drafts.list("inbox_id")
puts(page)<?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 {
$page = $client->emailInboxes->drafts->list(
'inbox_id',
);
var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:drafts list \
--api-key 'My API Key' \
--inbox-id inbox_idcurl --request GET \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/drafts \
--header 'Authorization: Bearer <token>'{
"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"
}
],
"meta": {
"page_size": 50,
"page_cursor": "<string>"
}
}{
"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": "10016",
"title": "Service Unavailable",
"detail": "Drafts are temporarily unavailable. Please try again later."
}
]
}