All plans have 30% OFF For this week

Claim Discount

File Endpoint API Reference

The File endpoint in AnswerPal is used for secure uploading, downloading, and management of attachments related to ticket messages. Use these endpoints to upload files, list attachments, delete them, and provide secure download links to end users or customer representatives.

Overview

The File API in AnswerPal is not a generic storage service but is designed to handle attachments for ticket messages. Files can be uploaded by customer representatives or end users, listed per message, deleted, and securely downloaded using a unique access token.

Endpoints

List Attachments

  • Method & URL: GET /ticketMessages/{messageId}/attachments
  • Description: Returns a list of all attachments for the specified ticket message.
  • Response: Returns an array of TicketMessageAttachmentDTO objects (see Data Models below).
  • Example Response:
[
{
"ticketMessageAttachmentID": 123,
"messageID": 456,
"fileName": "invoice.pdf",
"contentType": "application/pdf",
"createdDateTime": "2024-04-22T10:00:00Z",
"isEndUserProvided": false,
"isCustomerRepProvided": true,
"accessToken": "b7e2f3c8-6c7c-4a1d-9b3a-7f3d2a8b9e5d"
}
]

Upload Attachment

  • Method & URL: POST /ticketMessages/{messageId}/attachments
  • Description: Uploads a file as an attachment to the specified ticket message.
  • Request: Content-Type: multipart/form-data Field: file (the file to upload)
  • Response: Returns the created TicketMessageAttachmentDTO object (see Data Models below).
  • Example Request: Use a form with a file input named file.
  • Example Response:
{
"ticketMessageAttachmentID": 124,
"messageID": 456,
"fileName": "screenshot.png",
"contentType": "image/png",
"createdDateTime": "2024-04-22T10:05:00Z",
"isEndUserProvided": true,
"isCustomerRepProvided": false,
"accessToken": "d3f2c7a8-4b3d-4e1d-9b3a-8f7d2c3b1e5d"
}

 

Delete Attachment

  • Method & URL: DELETE /ticketMessages/{messageId}/attachments/{attachmentId}
  • Description: Deletes the specified attachment from the ticket message.
  • Response: 204 No Content on success.

Download Attachment

  • Method & URL: GET /api/File/{accessToken}
  • Description: Downloads the file associated with the given access token. If the file is an image, PDF, or text file, it will be displayed inline in the browser. For other file types, it will be downloaded as an attachment.
  • Response: Binary file data. Content-Disposition and Content-Type set according to the file.
  • Example: To download a file, use the accessToken property from the attachment object in the URL.

Data Models

TicketMessageAttachmentDTO

Elementor Text Editor Text: The TicketMessageAttachmentDTO object is used in all requests and responses for the File API. Below are the properties and their meanings:
Property Type Description
ticketMessageAttachmentID int Unique identifier for the attachment.
messageID int The ID of the message this attachment belongs to.
fileName string The original name of the uploaded file.
contentType string The MIME type of the file (e.g., “application/pdf”, “image/png”).
createdDateTime DateTime The date and time when the attachment was uploaded (ISO 8601 format).
isEndUserProvided bool True if the file was uploaded by an end user; false otherwise.
isCustomerRepProvided bool True if the file was uploaded by a customer representative; false otherwise.
accessToken string Unique token used for secure download of the file (used in /api/File/{accessToken}).

Error Codes

  • 404 Not Found: The requested attachment or file does not exist.
  • 400 Bad Request: Invalid input or missing parameters.
  • 403 Forbidden: You do not have access to this ticket message or attachment.
  • 415 Unsupported Media Type: The uploaded file type is not supported.

Example Scenarios

  • Uploading a file: A customer representative attaches a PDF invoice to a ticket message using a form with file input.
  • Listing attachments: The UI displays all attachments for a message, with download links using the accessToken.
  • Downloading a file: End users click a secure link to download their file, which opens inline for PDFs and images.
  • Deleting an attachment: A customer representative removes an outdated file from a ticket message.

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