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

# Auto-derive contact trait tags via LLM

> Reads the contact's 30-day event mix + deterministic signals and asks the LLM to synthesise an open-ended kebab-case tag set (`high-LTV`, `churn-risk`, `engaged-7d`, …). The output REPLACES (not appends to) the persisted `contact_scores.derived_trait_tags` array. Pre-launch: synthesiser-only on-demand surface; segmentation-engine sync ships in a follow-up wave.



## OpenAPI

````yaml /openapi.yaml post /api/v1/cdp/traits/auto-derive
openapi: 3.1.0
info:
  title: Devotel CPaaS API
  description: Orbit by Devotel — Communications Platform as a Service API
  version: 1.0.0
  contact:
    name: Devotel
    url: https://devotel.io
    email: support@devotel.io
  license:
    name: Proprietary
servers:
  - url: https://api.orbit.devotel.io
    description: Production
security:
  - Bearer: []
  - ApiKey: []
tags:
  - name: Messages
    description: >-
      Send and manage messages across all channels (SMS, WhatsApp, RCS, Email,
      Viber, etc.)
  - name: Fax
    description: >-
      List and track fax (MMS/T.38) transmissions on Telnyx-backed fax numbers
      (sending flows through the Messaging API)
  - name: Agents
    description: AI agent creation, configuration, and execution
  - name: Voice
    description: Voice calls, IVR, conferencing, and SIP trunking
  - name: OnCall
    description: On-call rotations and escalation policy planning for incident alerting
  - name: Webhooks
    description: Webhook endpoint management and delivery logs
  - name: Numbers
    description: Phone number search, provisioning, and configuration
  - name: Brand Identity
    description: >-
      Unified cross-channel brand trust posture (10DLC, toll-free, WhatsApp,
      RCS, branded calling, number KYC)
  - name: Contacts
    description: Contact management, segmentation, and lifecycle tracking
  - name: Campaigns
    description: Marketing campaign orchestration and analytics
  - name: Flows
    description: Automation flow builder and execution engine
  - name: Templates
    description: Message template management and approval workflows
  - name: Settings
    description: Organization, channel, and user preference settings
  - name: Verify
    description: OTP generation and verification across channels
  - name: Push
    description: Push notification delivery via FCM and APNs
  - name: Integrations
    description: Third-party service connections and OAuth management
  - name: CDP
    description: >-
      Customer Data Platform — activation surface (CRM object sync, streaming
      destinations, ad-audience activation)
  - name: Files
    description: >-
      Server-to-server media upload, listing, retrieval, and deletion
      (signed-URL backed)
  - name: Commerce
    description: >-
      Omnichannel conversational-commerce — persistent cart + checkout state
      machine, channel-agnostic hosted pay-by-link, native WhatsApp checkout,
      and AP2-style agent payment mandates.
  - name: Sync
    description: >-
      Real-time shared-state primitive (Twilio Sync parity) — Documents, Maps,
      Lists, and ephemeral Streams, with change events relayed over the
      /api/v1/ws/sync WebSocket gateway
paths:
  /api/v1/cdp/traits/auto-derive:
    post:
      tags:
        - CDP
      summary: Auto-derive contact trait tags via LLM
      description: >-
        Reads the contact's 30-day event mix + deterministic signals and asks
        the LLM to synthesise an open-ended kebab-case tag set (`high-LTV`,
        `churn-risk`, `engaged-7d`, …). The output REPLACES (not appends to) the
        persisted `contact_scores.derived_trait_tags` array. Pre-launch:
        synthesiser-only on-demand surface; segmentation-engine sync ships in a
        follow-up wave.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contact_id
              additionalProperties: false
              properties:
                contact_id:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: >-
                    Contact identifier. The handler reads the contact's 30-day
                    event mix + deterministic signals from the tenant schema
                    before invoking the LLM.
                max_tags:
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 6
                  description: >-
                    Soft cap on the tags the LLM proposes. Server-side clamping
                    prevents a chatty model from blowing the contact-detail
                    panel layout.
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - meta
                properties:
                  data:
                    type: object
                    required:
                      - contact_id
                      - derived_traits
                      - features
                    properties:
                      contact_id:
                        type: string
                      derived_traits:
                        type: array
                        items:
                          type: object
                          required:
                            - tag
                            - rationale
                          properties:
                            tag:
                              type: string
                              pattern: ^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$
                              description: >-
                                Kebab-case label (≤ 32 chars). Safe to use as a
                                URL fragment, CSS class suffix, and
                                segment-predicate hint.
                            rationale:
                              type: string
                              description: >-
                                One-line LLM rationale explaining why this
                                contact earned the tag — surfaced as a tooltip
                                on the contact-detail panel chip.
                        description: >-
                          LLM-derived tag set. REPLACES (not appends to) the
                          persisted `contact_scores.derived_trait_tags` array on
                          each refresh.
                      derived_trait_tags_computed_at:
                        type:
                          - 'null'
                          - string
                        format: date-time
                        description: >-
                          ISO-8601 timestamp the persistence layer wrote. NULL
                          when persistence failed (transient DB blip / tenant
                          migration not yet applied) — the synthesiser result is
                          still returned so the operator's LLM spend isn't
                          wasted.
                      features:
                        type: object
                        required:
                          - recent_event_count_30d
                          - top_event_counts_30d
                        properties:
                          recent_event_count_30d:
                            type: integer
                            minimum: 0
                            description: >-
                              Total CDP track-events ingested for this contact
                              in the last 30 days. Drives the synthesiser's
                              confidence.
                          top_event_counts_30d:
                            type: object
                            additionalProperties:
                              type: integer
                              minimum: 0
                            description: >-
                              Map of event name → count over the last 30 days,
                              capped at the top N most frequent.
                          deterministic_segment_label:
                            type:
                              - 'null'
                              - string
                            description: >-
                              Lifecycle label from the deterministic scorer
                              (`lead`, `customer`, `dormant`, …) — surfaced to
                              the LLM as a coherence hint.
                      llm_output_preview:
                        type: string
                        description: >-
                          First 500 chars of the LLM's raw output. Operators use
                          this to debug a parse failure without re-spending
                          tokens.
                  meta:
                    type: object
                    properties:
                      request_id:
                        type: string
                      timestamp:
                        type: string
                        format: date-time
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                  - meta
                properties:
                  error:
                    type: object
                    required:
                      - code
                      - message
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      status:
                        type: number
                      details: {}
                  meta:
                    type: object
                    properties:
                      request_id:
                        type: string
                      timestamp:
                        type: string
                        format: date-time
        '422':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                  - meta
                properties:
                  error:
                    type: object
                    required:
                      - code
                      - message
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      status:
                        type: number
                      details: {}
                  meta:
                    type: object
                    properties:
                      request_id:
                        type: string
                      timestamp:
                        type: string
                        format: date-time
        '502':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                  - meta
                properties:
                  error:
                    type: object
                    required:
                      - code
                      - message
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      status:
                        type: number
                      details: {}
                  meta:
                    type: object
                    properties:
                      request_id:
                        type: string
                      timestamp:
                        type: string
                        format: date-time
        '503':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                  - meta
                properties:
                  error:
                    type: object
                    required:
                      - code
                      - message
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      status:
                        type: number
                      details: {}
                  meta:
                    type: object
                    properties:
                      request_id:
                        type: string
                      timestamp:
                        type: string
                        format: date-time
components:
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Dashboard JWT token from Clerk
    ApiKey:
      type: apiKey
      name: X-API-Key
      in: header
      description: Server-to-server API key (dv_live_sk_*)

````