All plans have 30% OFF For this week

Claim Discount

Tickets Endpoint

The Tickets endpoint in AnswerPal provides full access to the lifecycle of customer support tickets, including creation, updates, and retrieval. Each ticket aggregates all related messages, attachments, and actions. This page documents the Tickets API endpoints and the associated TicketMessages (messages) sub-resource, including complete data models, detailed endpoint documentation, and usage examples.

Tickets Endpoint Overview

The Tickets API allows you to list, search, create, update, and delete support tickets. Each ticket contains all communication related to a customer issue, including messages, attachments, status, and topic classification. Tickets are linked to end-users and can be managed programmatically or through the AnswerPal dashboard.

Tickets Data Model

The Ticket object is used for both requests (creating/updating a ticket) and responses (retrieving ticket data). Below are the main properties:

  • ticketID (number): Unique identifier for the ticket.
  • dateCreated (string): Date and time when the ticket was created (ISO 8601 format).
  • status (string): Current ticket status (e.g., “Open”, “Closed”, “Escalated”).
  • subject (string): Subject or summary of the ticket.
  • channelID (number): Identifier for the communication channel (email, chat, etc.).
  • channelType (string): Type of channel (“Email”, “Chat”, “Phone”, “WhatsApp”).
  • endUserID (number): Identifier of the end-user.
  • isClosed (boolean): Whether the ticket is closed.
  • isSpam (boolean): Whether the ticket is marked as spam.
  • lastMessageDate (string): Date/time of the latest message.
  • topics (string[]): List of topic names associated with the ticket.
  • aiFeedbackComments (string[]): List of AI feedback comments from escalated messages.
  • [other properties may be present based on your configuration]

TicketMessage Data Model

TicketMessage objects have the following properties:

  • messageID (number): Unique identifier for the message.
  • ticketID (number): ID of the parent ticket.
  • dateCreated (string): Date/time the message was created.
  • senderType (string): Who sent the message (“EndUser” or “CustomerRep”).
  • customerRepID (number, optional): ID of the representative (if applicable).
  • customerRepName (string, optional): Name of the representative.
  • message (string, optional): Plaintext content of the message.
  • subject (string, optional): Subject (for emails).
  • fromAddress / toAddress (string, optional): Email addresses.
  • fromName (string, optional): Name of sender.
  • isOpened (boolean, optional): Whether the message has been opened.
  • messageDate (string, optional): Date/time of the message (can differ from creation date).
  • uid (string, optional): Unique identifier for the end-user (if available).
  • status (string, optional): Status of the message.
  • channelID (number, optional): Channel identifier.
  • preview (string, optional): Short preview/summary of the message.
  • pageScreenshot (string, optional): Screenshot (for web/chat context).
  • pageURL (string, optional): URL where the message originated.
  • htmlBody / textBody (string, optional): HTML and/or plain text body.
  • hasAttachment (boolean, optional): Whether attachments are present.
  • isEscalated (boolean, optional): Whether message was escalated.
  • aI_FeedbackComment (string, optional): Feedback from escalation.
  • topics (array): List of topics assigned to this message.
  • customFieldsData (object, optional): Custom fields as key-value pairs.
  • actions (array, optional): List of actions performed or available on this message.
  • [other properties may be present depending on configuration]

Tickets Endpoints (Detailed)

GET /tickets

Purpose: List all tickets with support for filtering, sorting, and pagination.

Query Parameters:

  • pageNumber (number, optional): Page number (default: 1).
  • pageSize (number, optional): Number of items per page (default: 20).
  • sortBy (string, optional): Field to sort by.
  • sortOrder (‘asc’|’desc’, optional): Sort order.
  • Filtering: status, channelType, channelIDs, UID, isClosed, isSpam, search, etc.

Response:

{

"items": [

{

"ticketID": 123,

"dateCreated": "2024-04-01T10:00:00Z",

"status": "Open",

"subject": "Login not working",

"channelID": 2,

"endUserID": 45,

"isClosed": false,

"topics": ["Login Issues", "Authentication"],

"aiFeedbackComments": []

}

],

"totalCount": 1,

"totalPages": 1

}

GET /tickets/{id}

Purpose: Retrieve a specific ticket by its ID.

Path Parameters:

  • id (number, required): Ticket ID.

Response: Returns a Ticket object (see Data Model).

POST /tickets

Purpose: Create a new ticket.

Request Body:

{

"subject": "Login not working",

"channelID": 2,

"endUserID": 45,

"status": "Open",

"customFieldsData": { "priority": "urgent" }

}

Response: Returns the created Ticket object.

PUT /tickets/{id}

Purpose: Update an existing ticket.

Path Parameters:

  • id (number, required): Ticket ID.

Request Body: Ticket fields to update.

Response: 204 No Content on success.

DELETE /tickets/{id}

Purpose: Delete a ticket by ID.

Response: 204 No Content on success.

PUT /tickets/bulk

Purpose: Bulk update tickets (e.g., close, assign, escalate).

Request Body:

{

"ticketIDs": [123, 124],

"action": "close",

"customerRepID": 5

}

Response: 204 No Content on success.

GET /tickets/{ticketID}/history-summary

Purpose: Retrieve the historical summary for a ticket.

Response: A string summary of the ticket’s history.

TicketMessages Endpoints (Detailed)

GET /ticketMessages?ticketId={ticketId}

Purpose: Returns a paginated list of messages for a given ticket.

Query Parameters:

  • ticketId (number, required): The ID of the parent ticket.
  • pageNumber, pageSize, sortBy, sortOrder: (see above)

Response: See Data Model.

GET /ticketMessages/{id}

Purpose: Returns all details for a single ticket message.

Path Parameters:

  • id (number, required): The unique message ID.

Response: See Data Model.

POST /ticketMessages/create-new

Purpose: Creates a new message, either in an existing ticket or by creating a new ticket.

Request Body: See Data Model.

Response: Returns the full message details.

PUT /ticketMessages/{id}

Purpose: Update certain fields of a ticket message (e.g., AI reply, custom fields).

Request Body: See Data Model.

Response: 204 No Content.

POST /ticketMessages/{id}/correct-topics

Purpose: Assigns a new list of topics to a ticket message.

Request Body:

{

"topicIds": [1, 2, 3]

}
  • topicIds: Array of topic IDs to assign to the message.

Response: 204 No Content.

POST /ticketMessages/{id}/send

Purpose: Sends the already prepared AI reply (or a manually modified one) for a message.

Request Body:

{

"modifiedAnswer": "Thank you for your patience. Please reset your password."

}
  • modifiedAnswer: (optional) Human-modified response.

Response:

{ "message": "Message sent successfully." }

POST /ticketMessages/{id}/escalate-by-id

Purpose: Escalates the message for human review or higher support level.

Request Body:

{

"feedbackComment": "User is very upset and needs urgent help.",

"email": "manager@example.com"

}
  • feedbackComment: (optional) Human feedback.
  • email: (optional) Email to notify.

Response:

{ "message": "Ticket escalated" }

POST /ticketMessages/{id}/detect-topics

Purpose: Triggers AI topic detection for the message.

Query Parameters:

  • modelName (string, optional): Specify model override.
  • executeActions (boolean, optional): Whether to execute actions after detection.

Response: 204 No Content.

GET /ticketMessages/{id}/promptDocuments

Purpose: Retrieves prompt documents (contextual data) for the message.

Query Parameters:

  • onlyPromptDocuments (boolean, optional): If true, only prompt docs are returned.
  • hookName (string, optional): Filter by event/hook.

Response:

{

"promptDocuments": [

{ "documentID": 1, "title": "FAQ", "content": "..." }

]

}

 

POST /ticketMessages/{id}/attachments

Purpose: Uploads a file to the message.

Request Body:

  • Multipart/form-data with field file.

Response:

{

"ticketMessageAttachmentID": 10,

"fileName": "error_screenshot.png",

"contentType": "image/png"

}

GET /ticketMessages/{id}/attachments

Purpose: Returns a list of attachments for the message.

Response:

[

{

"ticketMessageAttachmentID": 10,

"fileName": "error_screenshot.png",

"contentType": "image/png"

}

]

DELETE /ticketMessages/{id}/attachments/{attachmentId}

Purpose: Deletes a specific attachment from the message.

Response: 204 No Content.

GET /ticketMessages/{ticketToken}/like-dislike?like=true|false

Purpose: Lets the end user like or dislike a message via a unique ticket token.

Query Parameters:

  • like (boolean, required): true for like, false for dislike.

Response:

{

"agentAvailable": false,

"customerRepName": "John"

}

DELETE /ticketMessages/{id}

Purpose: Deletes a ticket message by ID.

Response: 204 No Content.

Example Requests & Responses

Request:

GET /tickets?status=Open&pageNumber=1&pageSize=10

Response:

{

"items": [

{

"ticketID": 123,

"dateCreated": "2024-04-01T10:00:00Z",

"status": "Open",

"subject": "Login not working",

"channelID": 2,

"endUserID": 45,

"isClosed": false,

"topics": ["Login Issues", "Authentication"],

"aiFeedbackComments": []

}

],

"totalCount": 1,

"totalPages": 1

}

Request:

GET /ticketMessages?ticketId=123&pageNumber=1&pageSize=20

Response:

{

"items": [

{

"messageID": 567,

"ticketID": 123,

"dateCreated": "2024-04-01T10:01:00Z",

"senderType": "EndUser",

"message": "I can't log in to my account.",

"topics": [

{ "ticketMessageTopicID": 1, "topicName": "Login Issues" }

]

}

],

"totalCount": 1,

"totalPages": 1

}

Table of Contents

AnswerPal: AI-powered customer service solutions to elevate your support and communication effortlessly.

Contact

For all support, sales, and partnership inquiries, email us at info@answerpal.eu