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

# Update the AI agent on a ticket

> Put an AI agent on a ticket, or take the one currently on it off by passing `aiAgentId: null`. The AI agent is the autonomous agent working the ticket, not its assignee — to assign the ticket to a person, use `updateTicketAssignee` instead. An agent calls this with null to take itself off a ticket it is handing back to the team.

<span className="badge-write">Key: Write</span><span className="badge-company">Scope: Company</span>


## OpenAPI

````yaml https://api.getprimo.com/openapi.json post /tickets/{ticketId}/ai-agent
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /tickets/{ticketId}/ai-agent:
    post:
      tags:
        - Tickets
      summary: Update the AI agent on a ticket
      description: >-
        Put an AI agent on a ticket, or take the one currently on it off by
        passing `aiAgentId: null`. The AI agent is the autonomous agent working
        the ticket, not its assignee — to assign the ticket to a person, use
        `updateTicketAssignee` instead. An agent calls this with null to take
        itself off a ticket it is handing back to the team.
      operationId: updateTicketAiAgent
      parameters:
        - name: ticketId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTicketAiAgentBody'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TicketOutput_Output'
components:
  schemas:
    UpdateTicketAiAgentBody:
      type: object
      properties:
        aiAgentId:
          description: >-
            Id of the AI agent to put on the ticket. Pass null to take the agent
            currently on it off.
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
      required:
        - aiAgentId
    TicketOutput_Output:
      type: object
      properties:
        id:
          type: string
        reference:
          type: string
        title:
          type: string
        status:
          type: string
          enum:
            - PENDING
            - IN_PROGRESS
            - COMPLETED
            - CANCELLED
            - SCHEDULED
        priority:
          anyOf:
            - type: string
              enum:
                - LOW
                - MEDIUM
                - HIGH
            - type: 'null'
        assignee:
          anyOf:
            - anyOf:
                - type: object
                  properties:
                    type:
                      type: string
                      const: EMAIL
                    email:
                      type: string
                  required:
                    - type
                    - email
                  additionalProperties: false
                - type: object
                  properties:
                    type:
                      type: string
                      const: EMPLOYEE
                    employeeId:
                      type: string
                  required:
                    - type
                    - employeeId
                  additionalProperties: false
                - type: object
                  properties:
                    type:
                      type: string
                      const: EXTERNAL_ADMIN
                    userId:
                      type: string
                  required:
                    - type
                    - userId
                  additionalProperties: false
            - type: 'null'
        requester:
          description: Who the ticket was opened on behalf of (its creator)
          anyOf:
            - type: object
              properties:
                type:
                  type: string
                  const: EMPLOYEE
                employeeId:
                  type: string
              required:
                - type
                - employeeId
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: EXTERNAL_ADMIN
                userId:
                  type: string
              required:
                - type
                - userId
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: EMAIL
                email:
                  type: string
              required:
                - type
                - email
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: PRIMO
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: API
              required:
                - type
              additionalProperties: false
            - description: The autonomous AI agent
              type: object
              properties:
                type:
                  type: string
                  const: AGENT
                agentId:
                  description: Id of the AI agent behind the action
                  anyOf:
                    - type: string
                    - type: 'null'
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  const: SLACK_USER
                name:
                  type: string
              required:
                - type
                - name
              additionalProperties: false
        dueDate:
          anyOf:
            - type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
            - type: 'null'
        createdAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        updatedAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        tagIds:
          description: Ids of the tags attached to this ticket
          type: array
          items:
            type: string
        aiAgentId:
          description: Id of the AI agent handling it; null when no agent is on it
          default: null
          anyOf:
            - type: string
            - type: 'null'
        tasks:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              ticketId:
                type: string
              title:
                type: string
              status:
                type: string
                enum:
                  - PENDING
                  - IN_PROGRESS
                  - COMPLETED
                  - CANCELLED
                  - SCHEDULED
              priority:
                anyOf:
                  - type: string
                    enum:
                      - LOW
                      - MEDIUM
                      - HIGH
                  - type: 'null'
              dueDate:
                anyOf:
                  - type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                  - type: 'null'
              scheduleDate:
                description: >-
                  Wake-up date of a SCHEDULED (dormant) task; null on any other
                  status
                anyOf:
                  - type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                  - type: 'null'
              isManuallyCompletable:
                description: Whether a human (not only the system) may complete this task
                type: boolean
              isAdminManaged:
                description: >-
                  Whether only an admin may assign this task or change its
                  status
                type: boolean
              assignee:
                anyOf:
                  - anyOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            const: EMAIL
                          email:
                            type: string
                        required:
                          - type
                          - email
                        additionalProperties: false
                      - type: object
                        properties:
                          type:
                            type: string
                            const: EMPLOYEE
                          employeeId:
                            type: string
                        required:
                          - type
                          - employeeId
                        additionalProperties: false
                      - type: object
                        properties:
                          type:
                            type: string
                            const: EXTERNAL_ADMIN
                          userId:
                            type: string
                        required:
                          - type
                          - userId
                        additionalProperties: false
                  - type: 'null'
              tagIds:
                description: Ids of the tags attached to this task
                type: array
                items:
                  type: string
              aiAgentId:
                description: Id of the AI agent handling it; null when no agent is on it
                default: null
                anyOf:
                  - type: string
                  - type: 'null'
            required:
              - id
              - ticketId
              - title
              - status
              - priority
              - dueDate
              - scheduleDate
              - isManuallyCompletable
              - isAdminManaged
              - assignee
              - tagIds
              - aiAgentId
            additionalProperties: false
        comments:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              text:
                type: string
              creator:
                anyOf:
                  - type: object
                    properties:
                      type:
                        type: string
                        const: EMPLOYEE
                      employeeId:
                        type: string
                    required:
                      - type
                      - employeeId
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: EXTERNAL_ADMIN
                      userId:
                        type: string
                    required:
                      - type
                      - userId
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: EMAIL
                      email:
                        type: string
                    required:
                      - type
                      - email
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: PRIMO
                    required:
                      - type
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: API
                    required:
                      - type
                    additionalProperties: false
                  - description: The autonomous AI agent
                    type: object
                    properties:
                      type:
                        type: string
                        const: AGENT
                      agentId:
                        description: Id of the AI agent behind the action
                        anyOf:
                          - type: string
                          - type: 'null'
                    required:
                      - type
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        const: SLACK_USER
                      name:
                        type: string
                    required:
                      - type
                      - name
                    additionalProperties: false
              visibility:
                description: >-
                  INTERNAL comments are team-only (admins and assignee), never
                  shown to the requester; PUBLIC comments are visible to the
                  ticket requester
                type: string
                enum:
                  - INTERNAL
                  - PUBLIC
              taskId:
                description: Id of the ticket task this comment concerns, if any
                anyOf:
                  - type: string
                  - type: 'null'
              createdAt:
                type: string
                format: date-time
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
            required:
              - id
              - text
              - creator
              - visibility
              - taskId
              - createdAt
            additionalProperties: false
        relatedObjects:
          type: array
          items:
            type: object
            properties:
              linkId:
                description: Id of the link itself — use it to unlink the related object
                type: string
              relatedType:
                type: string
                enum:
                  - DEVICE
                  - EMPLOYEE
                  - IDENTITY
                  - ORDER
                  - SHIPMENT
                  - COMPANY_SAAS_APPLICATION
              relatedId:
                description: >-
                  Id of the related resource (device, employee, identity, order
                  or shipment)
                type: string
              resolved:
                description: False when the related resource no longer exists
                type: boolean
            required:
              - linkId
              - relatedType
              - relatedId
              - resolved
            additionalProperties: false
      required:
        - id
        - reference
        - title
        - status
        - priority
        - assignee
        - requester
        - dueDate
        - createdAt
        - updatedAt
        - tagIds
        - aiAgentId
        - tasks
        - comments
        - relatedObjects
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````