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

# Create a ticket



## OpenAPI

````yaml post /v1/tickets
openapi: 3.0.0
info:
  title: Thena Platform
  description: The Thena Platform API description
  version: 1.0.0
  contact: {}
servers:
  - url: https://platform.thena.ai
    description: Platform
  - url: http://localhost:8000
    description: Local
security:
  - ApiKey: []
tags: []
paths:
  /v1/tickets:
    post:
      tags:
        - Tickets
      summary: Create a new ticket
      description: >-
        Create a ticket in the system. Requires title, requestorEmail, and
        teamId. Optional fields include description, assignedAgentId, priority,
        status, and custom fields.
      operationId: create
      parameters: []
      requestBody:
        required: true
        description: Create ticket request body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTicketBody'
            examples:
              minimal:
                summary: Minimal required fields
                description: Basic ticket creation with only required fields
                value:
                  title: Need help with my account!
                  requestorEmail: user@example.com
                  teamId: team_12345
              complete:
                summary: All possible fields
                description: Complete ticket creation with all optional fields
                value:
                  title: Cannot access dashboard
                  requestorEmail: jane.doe@example.com
                  teamId: THETT4QZZD9PPM
                  description: I am unable to access the dashboard after login.
                  accountId: account_abcde
                  assignedAgentId: agent_123
                  assignedAgentEmail: agent@example.com
                  dueDate: '2024-07-01T12:00:00.000Z'
                  submitterEmail: submitter@example.com
                  statusId: status_open
                  statusName: Open
                  priorityId: priority_high
                  priorityName: High
                  sentimentId: sentiment_positive
                  metadata:
                    source: web
                    campaign: summer2024
                  typeId: type_bug
                  isPrivate: false
                  source: web
                  aiGeneratedTitle: Login Issue
                  aiGeneratedSummary: User cannot access dashboard after login.
                  attachmentUrls:
                    - https://example.com/attachment1.png
                    - https://example.com/attachment2.pdf
                  customFieldValues:
                    - customFieldId: cf_001
                      data:
                        - value: Sample text
                      metadata:
                        required: true
                    - customFieldId: cf_002
                      data:
                        - value: Option A
                          id: opt_a
                        - value: Option B
                          id: opt_b
                  performRouting: true
                  formId: FODDKPKKXW88L
                  slackChannelId: C091ZQ1DEBS
      responses:
        '201':
          description: Operation successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TicketWithCommentResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: number
                    example: 400
                  error:
                    type: string
                    example: Bad Request
                  message:
                    type: string
                    example: Default type not set! Please set a default type.
              examples:
                formNotFound:
                  summary: Form not found
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: >-
                      Some forms not found, either they are deleted or not found
                      in your teams, missing forms: FODDKPKKXW88L
                defaultTypeNotSet:
                  summary: Default type not set
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Default type not set! Please set a default type.
                defaultStatusNotSet:
                  summary: Default status not set
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Default status not set! Please set a default status.
                defaultPriorityNotSet:
                  summary: Default priority not set
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Default priority not set! Please set a default priority.
                defaultSentimentNotSet:
                  summary: Default sentiment not set
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Default sentiment not set! Please set a default sentiment.
                agentNotInTeam:
                  summary: Agent not in team
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Assigned agent is not a member of this team!
                formNotForTeam:
                  summary: Form not for team
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Form FODDKPKKXW88L does not belong to team Support
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: number
                    example: 401
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: '16 UNAUTHENTICATED: Invalid API key'
              example:
                statusCode: 401
                error: Unauthorized
                message: '16 UNAUTHENTICATED: Invalid API key'
        '403':
          description: User does not have access to this resource!
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: number
                    example: 404
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: Team not found!
              examples:
                teamNotFound:
                  summary: Team not found
                  value:
                    statusCode: 404
                    error: Not Found
                    message: Team not found!
                accountNotFound:
                  summary: Account not found
                  value:
                    statusCode: 404
                    error: Not Found
                    message: Account not found!
                agentNotFound:
                  summary: Assigned agent not found
                  value:
                    statusCode: 404
                    error: Not Found
                    message: Assigned agent not found!
                sentimentNotFound:
                  summary: Sentiment not found
                  value:
                    statusCode: 404
                    error: Not Found
                    message: Sentiment not found!
                priorityNotFound:
                  summary: Priority not found
                  value:
                    statusCode: 404
                    error: Not Found
                    message: Priority not found!
                statusNotFound:
                  summary: Status not found
                  value:
                    statusCode: 404
                    error: Not Found
                    message: Status not found!
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Validation failed
                  error:
                    type: string
                    example: Validation Error
                  statusCode:
                    type: number
                    example: 422
                  details:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          example: title
                        errors:
                          type: array
                          items:
                            type: string
                          example:
                            - title should not be empty
              examples:
                titleRequired:
                  summary: Title is required
                  value:
                    message: Validation failed
                    error: Validation Error
                    statusCode: 422
                    details:
                      - field: title
                        errors:
                          - title should not be empty
                emailInvalid:
                  summary: Invalid email format
                  value:
                    message: Validation failed
                    error: Validation Error
                    statusCode: 422
                    details:
                      - field: requestorEmail
                        errors:
                          - requestorEmail must be an email
        '429':
          description: Too many requests!
        '500':
          description: Something went wrong!
        '503':
          description: This service/resource is currently unavailable.
components:
  schemas:
    CreateTicketBody:
      type: object
      properties:
        assignedAgentId:
          type: string
          description: The ID of the assigned agent
        accountId:
          type: string
          description: The ID of the account
        assignedAgentEmail:
          type: string
          description: The email of the assigned agent
        description:
          type: string
          description: The description of the ticket
        dueDate:
          format: date-time
          type: string
          description: The due date of the ticket
        submitterEmail:
          type: string
          description: The email of the submitter
        statusId:
          type: string
          description: The ID of the status, status id if provided is used over status name
        statusName:
          type: string
          description: The name of the status to match against
        priorityId:
          type: string
          description: >-
            The ID of the priority, priority id if provided is used over
            priority name
        priorityName:
          type: string
          description: The name of the priority to match against
        sentimentId:
          type: string
          description: The ID of the sentiment
        metadata:
          type: object
          description: The metadata of the ticket
        typeId:
          type: string
          description: The ID of the type
        isPrivate:
          type: boolean
          description: Whether the ticket is private
        source:
          type: string
          description: The source of the ticket
        aiGeneratedTitle:
          type: string
          description: The AI generated title of the ticket
        aiGeneratedSummary:
          type: string
          description: The AI generated summary of the ticket
        attachmentUrls:
          description: The attachment URLs
          type: array
          items:
            type: string
        customFieldValues:
          description: The custom field values
          type: array
          items:
            $ref: '#/components/schemas/ExternalCustomFieldValuesDto'
        isProactive:
          type: boolean
          description: Whether the ticket is proactive
          default: false
        closedAt:
          format: date-time
          type: string
          description: The closed date of the ticket
        closedById:
          type: string
          description: The ID of the user who closed the ticket
        proactiveChannels:
          type: array
          description: The proactive channels associated with the ticket
          items:
            type: string
            enum:
              - email
              - web-chat
              - slack
        title:
          type: string
          description: The title of the ticket
        requestorEmail:
          type: string
          description: The email of the requestor
        performRouting:
          type: boolean
          description: Whether to perform routing
        teamId:
          type: string
          description: The ID of the team
        formId:
          type: string
          description: The ID of the form
        commentContent:
          type: string
          description: The content of the customer comment
        commentContentHtml:
          type: string
          description: The HTML content of the customer comment
        commentContentJson:
          type: string
          description: The JSON content of the customer comment
        commentAttachmentIds:
          description: The attachment IDs for the customer comment
          type: array
          items:
            type: string
        commentMetadata:
          type: object
          description: The metadata for the customer comment
        commentImpersonatedUserName:
          type: string
          description: The impersonated user name for the customer comment
        commentImpersonatedUserEmail:
          type: string
          description: The impersonated user email for the customer comment
        commentImpersonatedUserAvatar:
          type: string
          description: The impersonated user avatar for the customer comment
        deDuplicationKey:
          type: string
          description: >-
            A deduplication key provided by an external application. The
            platform uses this key to prevent the creation of duplicate tickets.
          maxLength: 255
      required:
        - title
        - requestorEmail
        - teamId
    TicketWithCommentResponse:
      type: object
      properties:
        status:
          type: boolean
          default: true
          description: The status of the response
        message:
          type: string
          default: Success
          description: The message of the response
        timestamp:
          format: date-time
          type: string
          default: '2024-01-01T00:00:00.000Z'
          description: The timestamp of the response
        data:
          description: The response for create ticket operation
          allOf:
            - $ref: '#/components/schemas/TicketWithCommentResponseDto'
      required:
        - status
        - message
        - timestamp
        - data
    ExternalCustomFieldValuesDto:
      type: object
      properties: {}
    TicketWithCommentResponseDto:
      type: object
      properties:
        id:
          type: string
          description: The unique identifier of the ticket
        ticketIdentifier:
          type: string
          description: The unique identifier of the ticket
        title:
          type: string
          description: The title of the ticket
        ticketId:
          type: number
          description: The ticket ID of the ticket
        description:
          type: string
          description: The description of the ticket
        source:
          type: string
          description: The source of the ticket
        accountId:
          type: string
          description: The account ID of the ticket
        status:
          type: string
          description: The status of the ticket
        statusId:
          type: string
          description: The status ID of the ticket
        priority:
          type: string
          description: The priority of the ticket
        priorityId:
          type: string
          description: The priority ID of the ticket
        storyPoints:
          type: number
          description: The story points of the ticket
        account:
          type: string
          description: The account of the ticket
        teamId:
          type: string
          description: The team ID of the ticket
        teamName:
          type: string
          description: The name of the team of the ticket
        teamIdentifier:
          type: string
          description: The identifier of the team of the ticket
        subTeamId:
          type: string
          description: The sub team ID of the ticket
        subTeamName:
          type: string
          description: The name of the sub team of the ticket
        subTeamIdentifier:
          type: string
          description: The identifier of the sub team of the ticket
        isPrivate:
          type: boolean
          description: Whether the ticket is private
        typeId:
          type: string
          description: The type ID of the ticket
        type:
          type: string
          description: The name of the type of the ticket
        assignedAgent:
          type: string
          description: The assigned agent of the ticket
        assignedAgentId:
          type: string
          description: The assigned agent ID of the ticket
        assignedAgentEmail:
          type: string
          description: The assigned agent email of the ticket
        assignedAgentAvatar:
          type: string
          description: The assigned agent avatar of the ticket
        requestorEmail:
          type: string
          description: The requestor email of the ticket
        customerContactId:
          type: string
          description: The customer contact ID of the ticket
        customerContactFirstName:
          type: string
          description: The customer contact first name of the ticket
        customerContactLastName:
          type: string
          description: The customer contact last name of the ticket
        customerContactEmail:
          type: string
          description: The customer contact email of the ticket
        submitterEmail:
          type: string
          description: The submitter email of the ticket
        customFieldValues:
          description: The custom field values
          type: array
          items:
            type: string
        deletedAt:
          type: string
          description: The deleted at date of the ticket
        archivedAt:
          type: string
          description: The archived at date of the ticket
        createdAt:
          type: string
          description: The created at date of the ticket
        updatedAt:
          type: string
          description: The updated at date of the ticket
        formId:
          type: string
          description: The form ID of the ticket
        aiGeneratedTitle:
          type: string
          description: The AI generated title of the ticket
        aiGeneratedSummary:
          type: string
          description: The AI generated summary of the ticket
        sentiment:
          type: string
          description: The sentiment of the ticket
        sentimentId:
          type: string
          description: The sentiment ID of the ticket
        teamIcon:
          type: string
          description: The team icon of the ticket
        teamColor:
          type: string
          description: The team color of the ticket
        teamOrganizationId:
          type: string
          description: The team organization ID of the ticket
        teamParentTeamId:
          type: string
          description: The team parent team ID of the ticket
        teamDescription:
          type: string
          description: The team description of the ticket
        teamConfigurationId:
          type: string
          description: The team configuration ID of the ticket
        teamTeamOwnerId:
          type: string
          description: The team team owner ID of the ticket
        teamIsActive:
          type: boolean
          description: The team is active of the ticket
        teamIsPrivate:
          type: boolean
          description: The team is private of the ticket
        teamCreatedAt:
          type: string
          description: The team created at of the ticket
        teamUpdatedAt:
          type: string
          description: The team updated at of the ticket
        teamDeletedAt:
          type: string
          description: The team deleted at of the ticket
        teamArchivedAt:
          type: string
          description: The team archived at of the ticket
        subTeamIcon:
          type: string
          description: The sub team icon of the ticket
        subTeamColor:
          type: string
          description: The sub team color of the ticket
        subTeamOrganizationId:
          type: string
          description: The sub team organization ID of the ticket
        subTeamParentTeamId:
          type: string
          description: The sub team parent team ID of the ticket
        subTeamDescription:
          type: string
          description: The sub team description of the ticket
        subTeamConfigurationId:
          type: string
          description: The sub team configuration ID of the ticket
        subTeamTeamOwnerId:
          type: string
          description: The sub team team owner ID of the ticket
        subTeamIsActive:
          type: boolean
          description: The sub team is active of the ticket
        subTeamIsPrivate:
          type: boolean
          description: The sub team is private of the ticket
        subTeamCreatedAt:
          type: string
          description: The sub team created at of the ticket
        subTeamUpdatedAt:
          type: string
          description: The sub team updated at of the ticket
        subTeamDeletedAt:
          type: string
          description: The sub team deleted at of the ticket
        subTeamArchivedAt:
          type: string
          description: The sub team archived at of the ticket
        lastCustomerComment:
          type: string
          description: The last customer comment timestamp
        lastVendorComment:
          type: string
          description: The last vendor comment timestamp
        closedAt:
          type: string
          description: The closed at date of the ticket
          nullable: true
        closedBy:
          type: string
          description: The display name of the user who closed the ticket
          nullable: true
        closedById:
          type: string
          description: The ID of the user who closed the ticket
          nullable: true
        closedByEmail:
          type: string
          description: The email of the user who closed the ticket
          nullable: true
        lastComment:
          type: string
          description: >-
            The last comment timestamp (max of lastCustomerComment and
            lastVendorComment)
        isEscalated:
          type: boolean
          description: Whether the ticket is escalated
        comment:
          description: The comment creation response
          allOf:
            - $ref: '#/components/schemas/CommentResponseDto'
      required:
        - id
        - ticketIdentifier
        - title
        - ticketId
        - description
        - source
        - accountId
        - status
        - statusId
        - priority
        - priorityId
        - storyPoints
        - account
        - teamId
        - teamName
        - teamIdentifier
        - subTeamId
        - subTeamName
        - subTeamIdentifier
        - isPrivate
        - typeId
        - type
        - assignedAgent
        - assignedAgentId
        - assignedAgentEmail
        - assignedAgentAvatar
        - requestorEmail
        - customerContactId
        - customerContactFirstName
        - customerContactLastName
        - customerContactEmail
        - submitterEmail
        - customFieldValues
        - deletedAt
        - archivedAt
        - createdAt
        - updatedAt
        - formId
        - aiGeneratedTitle
        - aiGeneratedSummary
        - sentiment
        - sentimentId
        - teamIcon
        - teamColor
        - teamOrganizationId
        - teamParentTeamId
        - teamDescription
        - teamConfigurationId
        - teamTeamOwnerId
        - teamIsActive
        - teamIsPrivate
        - teamCreatedAt
        - teamUpdatedAt
        - teamDeletedAt
        - teamArchivedAt
        - subTeamIcon
        - subTeamColor
        - subTeamOrganizationId
        - subTeamParentTeamId
        - subTeamDescription
        - subTeamConfigurationId
        - subTeamTeamOwnerId
        - subTeamIsActive
        - subTeamIsPrivate
        - subTeamCreatedAt
        - subTeamUpdatedAt
        - subTeamDeletedAt
        - subTeamArchivedAt
        - lastCustomerComment
        - lastVendorComment
        - lastComment
        - isEscalated
        - comment
    CommentResponseDto:
      type: object
      properties:
        id:
          type: string
          description: The unique identifier of the comment
        content:
          type: string
          description: The content of the comment
        contentHtml:
          type: string
          description: The HTML content of the comment
        contentJson:
          type: string
          description: The JSON content of the comment
        contentMarkdown:
          type: string
          description: The markdown content of the comment
        isEdited:
          type: boolean
          description: Indicates if the comment is edited
        threadName:
          type: string
          description: The name of the comment thread
        commentVisibility:
          type: string
          description: The visibility of the comment
        commentType:
          type: string
          description: The type of the comment
        isPinned:
          type: boolean
          description: Indicates if the comment is pinned
        sourceEmailId:
          type: string
          description: The source email ID of the comment
        metadata:
          type: object
          description: The metadata of the comment
        parentCommentId:
          type: string
          description: The parent comment ID of the comment
        createdAt:
          type: string
          description: The creation date of the comment
        updatedAt:
          type: string
          description: The update date of the comment
        author:
          type: string
          description: The author of the comment
        authorId:
          type: string
          description: The unique identifier of the author of the comment
        authorUserType:
          type: string
          description: The user type of the author of the comment
        customerContactId:
          type: string
          description: The customer contact ID of the author of the comment
        customerContactEmail:
          type: string
          description: The email of the customer contact of the author of the comment
        customerContactFirstName:
          type: string
          description: The first name of the customer contact of the author of the comment
        customerContactLastName:
          type: string
          description: The last name of the customer contact of the author of the comment
        customerContactAvatarUrl:
          type: string
          description: The avatar url of the customer contact of the author of the comment
        authorAvatarUrl:
          type: string
          description: The avatar url of the author of the comment
        impersonatedUserEmail:
          type: string
          description: The impersonated user email
        impersonatedUserName:
          type: string
          description: The impersonated user name
        impersonatedUserAvatar:
          type: string
          description: The impersonated user avatar
        attachments:
          description: The attachments of the comment
          type: array
          items:
            type: string
        deletedAt:
          type: string
          description: The deletion date of the comment (null if not deleted)
      required:
        - id
        - content
        - contentHtml
        - contentJson
        - contentMarkdown
        - isEdited
        - threadName
        - commentVisibility
        - commentType
        - isPinned
        - sourceEmailId
        - metadata
        - parentCommentId
        - createdAt
        - updatedAt
        - author
        - authorId
        - authorUserType
        - customerContactId
        - customerContactEmail
        - customerContactFirstName
        - customerContactLastName
        - customerContactAvatarUrl
        - authorAvatarUrl
        - impersonatedUserEmail
        - impersonatedUserName
        - impersonatedUserAvatar
        - attachments
        - deletedAt
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: 'Enter your API key '

````