# Attachments

Ticket and comment attachments. Any user can upload attachment while creating a ticket or leaving a comment.

# Attachment Object

Name Type Comment
id string Unique attachment identifier.
user_id integer The ID of the user who uploaded the attachment.
name string The human readable file name.
file_name string The file name used internally.
mime_type string MIME type of the attachment file.
size integer Size of the attachment file in bytes.
created_at datetime Attachment creation timestamp.
updated_at datetime Attachment update timestamp.

# Upload an Attachment

Upload any kind of files. Max file size is 30MB.

POST
/attachments

# Parameters

Parameter Type Required Validation
file file yes A valid file.

# Request

curl --location --request POST 'https://yoursubdomain.support-hub.io/api/attachments' \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form 'file=testfile.zip'

# Example Response

{
    "data": {
        "id": "8ed42a7f-b191-4161-be3a-65bd255e8c62",
        "user_id": 1,
        "name": "test_file.zip",
        "file_name": "attachments/1/nOQKrZc3rMif54CD9xWr8mKsTeb9xYaqdFxPP762.zip",
        "mime_type": "text/plain",
        "size": 44642,
        "created_at": "2019-09-20 09:53:07",
        "updated_at": "2019-09-20 09:53:07"
    }
}

# View an Attachment

GET
/attachments/{id}

# Request

curl --location --request GET 'https://yoursubdomain.support-hub.io/api/attachments/8ed42a7f-b191-4161-be3a-65bd255e8c62' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'

# Example Response

{
    "data": {
        "id": "8ed42a7f-b191-4161-be3a-65bd255e8c62",
        "user_id": 1,
        "name": "test_file.zip",
        "file_name": "attachments/1/nOQKrZc3rMif54CD9xWr8mKsTeb9xYaqdFxPP762.zip",
        "mime_type": "text/plain",
        "size": 44642,
        "created_at": "2019-09-20 09:53:07",
        "updated_at": "2019-09-20 09:53:07"
    }
}

# Download Attachment

Returns the content of the attachment and initiate the download if accessed from the browser.

GET
/attachments/{id}/download

# Request

curl --location --request GET 'https://yoursubdomain.support-hub.io/api/attachments/8ed42a7f-b191-4161-be3a-65bd255e8c62/download' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'

# Example Response

// binary

# Delete an Attachment

DELETE
/attachments/{id}

# Request

curl --location --request DELETE 'https://yoursubdomain.support-hub.io/api/attachments/8ed42a7f-b191-4161-be3a-65bd255e8c62' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'

# Example Response

Status: 200 OK

{
  "success": true
}