Download a file of a support ticket
/v1/tickets/{ticketRef}/files/{fileId} Downloads a file sent with one of the ticket's messages, as it is: its type in Content-Type, its size in Content-Length and its name in Content-Disposition (always as an attachment).
Scopes
The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).
-
support:read - View tickets. Read this account's support tickets.
Path parameters
| Field | Type and description |
|---|---|
ticketRef Required | string The ticket's id: its reference, like |
fileId Required | string The file's id (in the message's |
Example request
curl "https://api.rabbitflare.com/v1/tickets/RF-7KQ2MX/files/5e6f7a8b-9c0d-4e1f-a2b3-c4d5e6f7a8b9" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-OJ import { writeFile } from "node:fs/promises";
const res = await fetch("https://api.rabbitflare.com/v1/tickets/RF-7KQ2MX/files/5e6f7a8b-9c0d-4e1f-a2b3-c4d5e6f7a8b9", {
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
await writeFile("download", Buffer.from(await res.arrayBuffer())); import { writeFile } from "node:fs/promises";
import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const res = await rf.tickets.files.download({
ticketRef: "RF-7KQ2MX",
fileId: "5e6f7a8b-9c0d-4e1f-a2b3-c4d5e6f7a8b9",
});
await writeFile("download", Buffer.from(await res.arrayBuffer())); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/tickets/RF-7KQ2MX/files/5e6f7a8b-9c0d-4e1f-a2b3-c4d5e6f7a8b9');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
file_put_contents('download', $body); import os
import requests
response = requests.get(
"https://api.rabbitflare.com/v1/tickets/RF-7KQ2MX/files/5e6f7a8b-9c0d-4e1f-a2b3-c4d5e6f7a8b9",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
timeout=120,
)
response.raise_for_status()
with open("download", "wb") as f:
f.write(response.content) Response
200 OK The answer is the file itself, as application/octet-stream, without the data envelope.
Example response
The file itself, as application/octet-stream, without the data envelope.
Errors
The errors this request can answer besides those every request can (a missing token, a missing scope, the rate limits). Each answer is an Error object (see Errors).
| Status and code | When, and what to do |
|---|---|
404 not_ | The resource doesn't exist, or isn't this account's. Check the id. Ids of other accounts' resources answer the same way. |
502 bad_ | Something on our side didn't answer properly. Try again in a moment. |