Add labels to an inbox thread
Adds one or more mutable labels to a thread, letting an agent mark a
whole conversation (for example needs_review) without labelling each
message individually.
Thread labels are independent of message labels: labelling a thread does not label its messages, and labelling a message does not label its thread. Idempotent and case-sensitive.
POST
/
email_inboxes
/
{inbox_id}
/
threads
/
{thread_id}
/
labels
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.threads.labels.create('inbox_id', 'thread_id', {
labels: [],
});
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.threads.labels.create(
inbox_id="inbox_id",
thread_id="thread_id",
labels=[],
)
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"),
)
label, err := client.EmailInboxes.Threads.Labels.New(
context.TODO(),
"inbox_id",
"thread_id",
telnyx.EmailInboxeThreadLabelNewParams{
Labels: "labels",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", label.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.threads.labels.LabelCreateParams;
import java.util.List;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
LabelCreateParams params = LabelCreateParams.builder()
.labels(List.of())
.build();
var response = client.emailInboxes().threads().labels().create("inbox_id", "thread_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.email_inboxes.threads.labels.create("inbox_id", "thread_id", labels: [])
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->threads->labels->create(
'inbox_id',
'thread_id',
labels: [],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:threads:labels create \
--api-key 'My API Key' \
--inbox-id inbox_id \
--thread-id thread_id \
--labels labelscurl --request POST \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/threads/{thread_id}/labels \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"labels": [
"needs_review"
]
}
'{
"data": {
"id": "33333333-3333-3333-3333-333333333333",
"record_type": "email_thread",
"inbox_id": "11111111-1111-1111-1111-111111111111",
"labels": [
"needs_review"
]
}
}{
"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": "Inbox labels are temporarily unavailable. Please try again later."
}
]
}Authorizations
Path Parameters
Body
application/json
Labels to add or remove. Both operations are idempotent set operations, so a retried request converges instead of failing.
One or more labels. Each label is a freeform, case-sensitive string of at most 255 characters; a message or thread may carry at most 50 labels. The telnyx: prefix is a reserved system namespace and is rejected on customer writes.
Required array length:
1 - 50 elementsRequired string length:
1 - 255Was this page helpful?
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.threads.labels.create('inbox_id', 'thread_id', {
labels: [],
});
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.threads.labels.create(
inbox_id="inbox_id",
thread_id="thread_id",
labels=[],
)
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"),
)
label, err := client.EmailInboxes.Threads.Labels.New(
context.TODO(),
"inbox_id",
"thread_id",
telnyx.EmailInboxeThreadLabelNewParams{
Labels: "labels",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", label.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.threads.labels.LabelCreateParams;
import java.util.List;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
LabelCreateParams params = LabelCreateParams.builder()
.labels(List.of())
.build();
var response = client.emailInboxes().threads().labels().create("inbox_id", "thread_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.email_inboxes.threads.labels.create("inbox_id", "thread_id", labels: [])
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->threads->labels->create(
'inbox_id',
'thread_id',
labels: [],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-inboxes:threads:labels create \
--api-key 'My API Key' \
--inbox-id inbox_id \
--thread-id thread_id \
--labels labelscurl --request POST \
--url https://api.telnyx.com/v2/email_inboxes/{inbox_id}/threads/{thread_id}/labels \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"labels": [
"needs_review"
]
}
'{
"data": {
"id": "33333333-3333-3333-3333-333333333333",
"record_type": "email_thread",
"inbox_id": "11111111-1111-1111-1111-111111111111",
"labels": [
"needs_review"
]
}
}{
"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": "Inbox labels are temporarily unavailable. Please try again later."
}
]
}