Pular para o conteúdo

Files

Este conteúdo não está disponível em sua língua ainda.

Files represent attachments uploaded to tickets. Each file object includes metadata (name, MIME type, size) and a short-lived signed URL you can use to download the file directly.

Signed URLs expire after 300 seconds. Fetch a fresh URL by calling Retrieve a file again before it expires.

{
"object": "file",
"id": 142,
"ticket_id": "T-1042",
"filename": "a3f9c1b2.jpg",
"original_name": "cracked-screen-photo.jpg",
"mime_type": "image/jpeg",
"size_bytes": 284310,
"uploaded_by": "tech@example.com",
"portal_visible": true,
"download_url": "/api/attachments/T-1042/a3f9c1b2.jpg?sig=...",
"download_url_ttl_sec": 300,
"created_at": "2025-11-10T14:22:00.000Z"
}
FieldTypeDescription
idintegerFile ID
ticket_idstringTicket the file belongs to
filenamestringStored filename (opaque; use original_name for display)
original_namestring | nullOriginal filename as uploaded
mime_typestring | nullMIME type (e.g. image/jpeg, application/pdf)
size_bytesinteger | nullFile size in bytes
uploaded_bystring | nullEmail or identifier of the uploader
portal_visiblebooleanWhether the file is visible in the customer portal
download_urlstring | nullSigned URL valid for download_url_ttl_sec seconds
download_url_ttl_secinteger | nullSigned URL lifetime in seconds (300)
created_atstringISO-8601 upload timestamp

GET /api/v1/files

Returns attachment metadata sorted by newest first. Use ticket_id to scope results to a single ticket, without it the endpoint returns all attachments across all tickets.

Scope required: files.read

ParameterTypeDescription
ticket_idstringFilter to a specific ticket (strongly recommended)
limitintegerPage size, 1–100 (default: 25)
cursorstringOpaque cursor from a previous response’s next_cursor
Terminal window
curl "https://app.benchkey.com/api/v1/files?ticket_id=T-1042&limit=20" \
-H "Authorization: Bearer bk_live_01J8X4_kvWz9nP3mRqTs7uYeBfGhDjLa"
const res = await fetch(
"https://app.benchkey.com/api/v1/files?ticket_id=T-1042&limit=20",
{ headers: { Authorization: "Bearer bk_live_01J8X4_kvWz9nP3mRqTs7uYeBfGhDjLa" } }
);
const { data, has_more, next_cursor } = await res.json();
{
"object": "list",
"data": [
{
"object": "file",
"id": 142,
"ticket_id": "T-1042",
"filename": "a3f9c1b2.jpg",
"original_name": "cracked-screen-photo.jpg",
"mime_type": "image/jpeg",
"size_bytes": 284310,
"uploaded_by": "tech@example.com",
"portal_visible": true,
"download_url": "/api/attachments/T-1042/a3f9c1b2.jpg?sig=...",
"download_url_ttl_sec": 300,
"created_at": "2025-11-10T14:22:00.000Z"
}
],
"has_more": false,
"next_cursor": null
}

Hidden and soft-deleted tickets are excluded from all results. See Pagination for how to page through results.


GET /api/v1/files/:id

Returns a single file object with a fresh signed download URL.

Scope required: files.read

Terminal window
curl "https://app.benchkey.com/api/v1/files/142" \
-H "Authorization: Bearer bk_live_01J8X4_kvWz9nP3mRqTs7uYeBfGhDjLa"
const res = await fetch(
"https://app.benchkey.com/api/v1/files/142",
{ headers: { Authorization: "Bearer bk_live_01J8X4_kvWz9nP3mRqTs7uYeBfGhDjLa" } }
);
const file = await res.json();
// file.download_url is valid for 300 seconds

Returns the file object. Returns 404 if the file does not exist or its ticket is hidden or deleted.


The download_url in every file object is a relative signed URL that resolves against https://app.benchkey.com. Append it to the base URL and make an unauthenticated GET request, no API key is needed once you have the signed URL.

Terminal window
curl "https://app.benchkey.com/api/attachments/T-1042/a3f9c1b2.jpg?sig=..." \
-o cracked-screen-photo.jpg
const fileObj = await fetch("https://app.benchkey.com/api/v1/files/142", {
headers: { Authorization: "Bearer bk_live_01J8X4_kvWz9nP3mRqTs7uYeBfGhDjLa" },
}).then(r => r.json());
// Download using the signed URL (no API key needed)
const blob = await fetch(`https://app.benchkey.com${fileObj.download_url}`).then(r => r.blob());

Signed URLs expire after 300 seconds. If your workflow takes longer, retrieve the file object again to get a fresh URL.


HTTP statusCodeMeaning
400invalid_id:id is not a valid positive integer, or is not a safe integer
400invalid_queryticket_id query parameter is malformed
400invalid_cursorcursor is malformed
404not_foundFile not found, or its ticket is hidden or deleted
403insufficient_scopeAPI key lacks files.read

See Errors for the full error envelope format.

Status do sistema