Add attachments
/partners/invoices/{uuid}/attachmentsAttaches files to an invoice from public URLs or inline base64 content.
COUNT downloads each URL (or decodes the inline content), virus-scans it and stores its own copy, so a link only has to work at the moment you call. Each file is capped at 5 MB, the same as the multipart upload. All files are added together: if one fails, none are saved. Adding a file clears the invoice's cached PDF, which is rebuilt with the attachment on next view.
Path parameters
uuiduuidrequiredThe invoice, estimate or credit memo UUID.
Request body
attachmentsarrayrequiredFiles to attach. Up to 10 entries; every file is downloaded or decoded and virus-scanned before anything is saved, so one bad file fails the whole request.
urlstringA public http(s) URL. COUNT downloads the file and stores its own copy, so the link only has to work at the moment you call. Send either `url` or `contentBase64`, not both.
fileNamestringRequired with `contentBase64`. The file name, including its extension.
contentBase64stringThe file's bytes, base64-encoded (a `data:...;base64,` prefix is accepted). At most 10 MB once decoded, or the route's own cap where that is lower.
contentTypestringOptional MIME type, e.g. `application/pdf`. Worked out from `fileName` when omitted.
titlestringOptional display title. Defaults to the file name.
Responses
201Attachments added.400A malformed entry (both or neither of `url` and `contentBase64`, a non-http(s) URL, invalid base64), more than 10 files, a file over 5 MB, a type that cannot be attached, or a URL that could not be downloaded. The message names the entry, e.g. `attachments[1]`.422A file was blocked by the virus scan. Nothing was saved.429More than 40 attachment adds a minute for this client and workspace. Retry after the Retry-After header. Troubleshoot404Invoice not found.401Missing or invalid HMAC signature, expired timestamp, or invalid Bearer token. Troubleshoot403The credential does not have access to this workspace or resource. Troubleshoot429Rate limit exceeded (100 requests per minute per user of each app, or 10,000 per minute per app). Retry after the Retry-After header. Troubleshoothttps://api.getcount.com/partners/invoices/{uuid}/attachmentsimport crypto from 'node:crypto';
const BASE_URL = 'https://api.getcount.com';
const CLIENT_ID = process.env.COUNT_CLIENT_ID;
const CLIENT_SECRET = process.env.COUNT_CLIENT_SECRET;
const ACCESS_TOKEN = process.env.COUNT_ACCESS_TOKEN;
const method = 'POST';
const signingPath = '/invoices/3fa85f64-5717-4562-b3fc-2c963f66afa6/attachments';
const timestamp = Math.floor(Date.now() / 1000).toString();
const body = {
"attachments": [
{
"url": "https://files.example-partner.com/invoices/INV-20481.pdf",
"title": "Supplier invoice"
},
{
"fileName": "receipt.png",
"contentType": "image/png",
"contentBase64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
}
]
};
const bodyString = JSON.stringify(body);
const bodyHash = crypto.createHash('sha256').update(bodyString).digest('hex');
const baseString = `${method}:${signingPath}:${timestamp}:${bodyHash}`;
const signature = crypto.createHmac('sha256', CLIENT_SECRET).update(baseString).digest('hex');
const response = await fetch(`${BASE_URL}/partners/invoices/3fa85f64-5717-4562-b3fc-2c963f66afa6/attachments`, {
method,
headers: {
'x-client-id': CLIENT_ID,
'x-timestamp': timestamp,
'x-signature': signature,
'Content-Type': 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
body: bodyString,
});
console.log(await response.json());{
"status": "success",
"message": "Success on adding attachments to invoice",
"data": {
"attachments": [
{
"id": "d7e8f9a0-b1c2-4d3e-8f4a-5b6c7d8e9f01",
"title": "Signed contract",
"documentUrl": "https://countstorage.blob.core.windows.net/invoice-attachments/1042/Signed%20contract.pdf?sv=2024-11-04&se=2026-03-02T12%3A15%3A00Z&sr=b&sp=r&sig=REDACTED",
"isTeamDefault": false,
"edited": false,
"isDeleted": false,
"createdAt": "2026-03-01T09:00:00.000Z",
"updatedAt": "2026-03-02T11:15:00.000Z"
}
]
}
}