> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.




## OpenAPI

````yaml /openapi/generated/email/inboxes.yml post /email_inboxes/{inbox_id}/threads/{thread_id}/labels
openapi: 3.1.0
info:
  contact:
    email: support@telnyx.com
  description: API for managing email inboxes, drafts, messages, filters, and threads.
  title: Telnyx Email Inboxes API
  version: 2.0.0
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /email_inboxes/{inbox_id}/threads/{thread_id}/labels:
    post:
      tags:
        - Email Inboxes
      summary: Add labels to an inbox thread
      description: |
        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.
      operationId: AddEmailInboxThreadLabels
      parameters:
        - $ref: '#/components/parameters/InboxIdPathParam'
        - $ref: '#/components/parameters/ThreadIdPathParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LabelMutationRequest'
            example:
              labels:
                - needs_review
      responses:
        '200':
          $ref: '#/components/responses/InboundThreadLabelResponse'
        '401':
          $ref: '#/components/responses/email_UnauthorizedResponse'
        '404':
          $ref: '#/components/responses/email_NotFoundResponse'
        '422':
          $ref: '#/components/responses/ValidationErrorResponse'
        '503':
          $ref: '#/components/responses/LabelServiceUnavailableResponse'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            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);
        - lang: Python
          source: |-
            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)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tlabel, err := client.EmailInboxes.Threads.Labels.New(\n\t\tcontext.TODO(),\n\t\t\"inbox_id\",\n\t\t\"thread_id\",\n\t\ttelnyx.EmailInboxeThreadLabelNewParams{\n\t\t\tLabels: \"labels\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", label.Data)\n}\n"
        - lang: Java
          source: >-
            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);
                }
            }
        - lang: Ruby
          source: >-
            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)
        - lang: PHP
          source: >-
            <?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();
            }
        - lang: CLI
          source: |-
            telnyx email-inboxes:threads:labels create \
              --api-key 'My API Key' \
              --inbox-id inbox_id \
              --thread-id thread_id \
              --labels labels
components:
  parameters:
    InboxIdPathParam:
      name: inbox_id
      in: path
      required: true
      description: Email inbox UUID.
      schema:
        type: string
        format: uuid
    ThreadIdPathParam:
      name: thread_id
      in: path
      required: true
      description: Thread UUID.
      schema:
        type: string
        format: uuid
  schemas:
    LabelMutationRequest:
      type: object
      description: >-
        Labels to add or remove. Both operations are idempotent set operations,
        so a retried request converges instead of failing.
      properties:
        labels:
          type: array
          description: >-
            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.
          items:
            type: string
            minLength: 1
            maxLength: 255
          minItems: 1
          maxItems: 50
      required:
        - labels
    email_ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorObject'
        suppressed:
          type: array
          description: >-
            Present when every recipient is suppressed, so the request is
            rejected and no message is created.
          items:
            $ref: '#/components/schemas/SuppressedRecipient'
      required:
        - errors
    ErrorObject:
      type: object
      properties:
        code:
          type: string
          description: >-
            Telnyx error code. Edge idempotency errors use 10027 or 10036.
            Fallback 404/500 responses from the framework may use string status
            codes ('404', '500') instead.
          enum:
            - '10001'
            - '10006'
            - '10007'
            - '10015'
            - '10016'
            - '10019'
            - recipient_suppressed
            - reputation_suspended
            - '404'
            - '500'
            - '10027'
            - '10036'
        title:
          type: string
        detail:
          description: >-
            Human-readable error detail. Changeset responses may return a
            structured object.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
        source:
          type:
            - object
            - 'null'
          additionalProperties: true
        meta:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Additional metadata. Present on 401 errors with a documentation URL.
      required:
        - code
        - title
        - detail
    SuppressedRecipient:
      type: object
      properties:
        to:
          type: string
          format: email
          description: Suppressed recipient email address.
        reason:
          type: string
          description: Suppression reason returned by the recipient suppression service.
        scope:
          type: string
          description: Scope at which the suppression applies.
        override_allowed:
          type: boolean
          description: Whether an authorized send may override this suppression.
      required:
        - to
        - reason
        - scope
        - override_allowed
  responses:
    InboundThreadLabelResponse:
      description: The thread identity and its current label set.
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  record_type:
                    type: string
                    enum:
                      - email_thread
                  inbox_id:
                    type: string
                    format: uuid
                  labels:
                    type: array
                    items:
                      type: string
                      maxLength: 255
                    maxItems: 50
                required:
                  - id
                  - record_type
                  - labels
            required:
              - data
          example:
            data:
              id: 33333333-3333-3333-3333-333333333333
              record_type: email_thread
              inbox_id: 11111111-1111-1111-1111-111111111111
              labels:
                - needs_review
    email_UnauthorizedResponse:
      description: Not authorized (10006).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/email_ErrorResponse'
          example:
            errors:
              - code: '10006'
                title: Not authorized
                detail: Invalid API key
                meta:
                  url: https://developers.telnyx.com/docs/overview/errors/10006
    email_NotFoundResponse:
      description: Resource not found (10001).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/email_ErrorResponse'
          example:
            errors:
              - code: '10001'
                title: Not Found
                detail: The requested resource was not found
    ValidationErrorResponse:
      description: Validation Failed (10015) or changeset validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/email_ErrorResponse'
          example:
            errors:
              - code: '10015'
                title: Validation Failed
                detail: subject can't be blank
                source:
                  pointer: /data/attributes/subject
    LabelServiceUnavailableResponse:
      description: Inbound label storage is temporarily unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/email_ErrorResponse'
          example:
            errors:
              - code: '10016'
                title: Service Unavailable
                detail: >-
                  Inbox labels are temporarily unavailable. Please try again
                  later.
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````