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

# Añadir una etiqueta a un contacto

> Asocia una etiqueta reutilizable existente a un contacto de Instagram por ID y devuelve el conjunto completo de etiquetas actuales del contacto.

Añade `tagId` al contacto identificado por `contactId`. Ambos UUIDs deben
pertenecer a la cuenta de Instagram seleccionada.

Tu clave de API necesita el permiso `contacts:write`. Envía `account_id` como
el único campo del cuerpo de la solicitud.

```bash theme={null}
curl --request PUT \
  --url "https://levios.app/api/v1/contacts/${LEVIOS_CONTACT_ID}/tags/${LEVIOS_TAG_ID}" \
  --header "Authorization: Bearer ${LEVIOS_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data @- <<JSON
{
  "account_id": "${LEVIOS_ACCOUNT_ID}"
}
JSON
```

La respuesta contiene `contact_id` y el array `tags` completo y actual del
contacto. Cada etiqueta contiene `id` y `name`.

Añadir una etiqueta ya asignada no crea un duplicado. La operación es
idempotente. Un contacto puede tener hasta 100 etiquetas asignadas.

<Warning>
  Si la API devuelve `api_contact_tag_response_unavailable` con `committed: true`
  y `retryable: false`, la asignación cambió, pero no se pudo verificar la
  respuesta. No reintentes la operación automáticamente. Lee el contacto para
  comprobar sus etiquetas actuales.
</Warning>


## OpenAPI

````yaml openapi/v1.json PUT /api/v1/contacts/{contactId}/tags/{tagId}
openapi: 3.1.0
info:
  title: levios public API
  version: '1'
servers:
  - url: https://levios.app
security:
  - bearerAuth: []
paths:
  /api/v1/contacts/{contactId}/tags/{tagId}:
    put:
      tags:
        - contact_tag
      summary: Add a tag to a contact
      description: >-
        Adds an existing account tag to a contact and returns the contact's
        current tags.
      operationId: contact_tags.attach
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: tagId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                account_id:
                  type: string
                  format: uuid
              required:
                - account_id
              additionalProperties: false
      responses:
        '200':
          description: Successful response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicContactTagAssignmentResult'
        '400':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_invalid_content_length
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - Invalid Content-Length.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_invalid_json
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The request body is not valid JSON.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_invalid_request_url
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The request URL is invalid.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_invalid_utf8
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The request body is not valid UTF-8.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
        '401':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
            WWW-Authenticate:
              description: API key Bearer challenge.
              schema:
                type: string
                enum:
                  - Bearer
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - api_unauthorized
                      correlation_id:
                        type: string
                      message:
                        type: string
                        enum:
                          - Authentication required.
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '403':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_account_not_granted
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - >-
                                This credential is not authorized for the
                                request.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_forbidden
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - >-
                                This credential is not authorized for the
                                request.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_scope_denied
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - >-
                                This credential is not authorized for the
                                request.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
        '404':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - api_contact_tag_not_found
                      correlation_id:
                        type: string
                      message:
                        type: string
                        enum:
                          - The requested contact tag was not found.
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '409':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - api_contact_tag_limit_reached
                      correlation_id:
                        type: string
                      message:
                        type: string
                        enum:
                          - The contact tag limit has been reached.
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '413':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_body_too_large
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The JSON request body exceeds 1 MiB.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_json_too_deep
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The JSON request body exceeds maximum depth.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
        '415':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - api_unsupported_media_type
                      correlation_id:
                        type: string
                      message:
                        type: string
                        enum:
                          - Content-Type must be application/json.
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '422':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - api_validation_error
                      correlation_id:
                        type: string
                      details:
                        type: object
                        properties:
                          issues:
                            type: array
                            items:
                              type: object
                              properties:
                                code:
                                  type: string
                                  minLength: 1
                                  maxLength: 64
                                path:
                                  type: array
                                  items:
                                    type: integer
                                    minimum: 0
                                  maxItems: 16
                              required:
                                - code
                                - path
                              additionalProperties: false
                            maxItems: 32
                        required:
                          - issues
                        additionalProperties: false
                      message:
                        type: string
                        enum:
                          - The request does not match the declared schema.
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '429':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - rate_limited
                      correlation_id:
                        type: string
                      message:
                        type: string
                        enum:
                          - Rate limit exceeded.
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '500':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_contact_tag_response_unavailable
                          correlation_id:
                            type: string
                          details:
                            type: object
                            properties:
                              committed:
                                type: boolean
                                enum:
                                  - true
                              retryable:
                                type: boolean
                                enum:
                                  - false
                            required:
                              - committed
                              - retryable
                            additionalProperties: false
                          message:
                            type: string
                            enum:
                              - >-
                                The contact tag changed, but its response could
                                not be verified. Do not retry automatically.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_internal_error
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The request could not be completed.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
        '503':
          description: Error response.
          headers:
            X-Correlation-ID:
              description: Correlation identifier for this request.
              schema:
                type: string
                pattern: ^[0-9A-HJKMNP-TV-Z]{26}$
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_account_resolution_unavailable
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The reachable account set could not be read.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - api_contact_tag_write_unavailable
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - The contact tag could not be changed.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - rate_limiter_unavailable
                          correlation_id:
                            type: string
                          message:
                            type: string
                            enum:
                              - Rate limiter unavailable.
                        required:
                          - code
                          - message
                        additionalProperties: false
                    required:
                      - error
                    additionalProperties: false
components:
  schemas:
    PublicContactTagAssignmentResult:
      $ref: 46fda251-8b2f-420d-9334-0b958aeb2462
      $defs:
        PublicContactTagAssignmentResult:
          additionalProperties: false
          properties:
            contact_id:
              description: Stable contact UUID whose exact current tag set is returned.
              format: uuid
              pattern: >-
                ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
              type: string
            tags:
              items:
                additionalProperties: false
                properties:
                  id:
                    description: >-
                      Stable public tag UUID. Internal numeric catalog IDs are
                      never exposed.
                    format: uuid
                    pattern: >-
                      ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
                    type: string
                  name:
                    description: >-
                      Normalized tag name: trimmed, with consecutive whitespace
                      collapsed to one ASCII space.
                    maxLength: 50
                    minLength: 1
                    pattern: ^(?!.*\s{2})(?!\s)(?!.*\s$)(?!.*[\u0000-\u001F\u007F]).+$
                    type: string
                required:
                  - id
                  - name
                type: object
              maxItems: 100
              type: array
          required:
            - contact_id
            - tags
          type: object
      $id: https://levios.app/schemas/public-contact-tag-assignment-result-v1
      $schema: https://json-schema.org/draft/2019-09/schema#
      title: PublicContactTagAssignmentResult
      x-levios-max-serialized-bytes: 65536
      x-levios-schema-version: 1
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Levios API key sent as a Bearer token.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.