const sizeBytes = fileBuffer.byteLength;
const uploadResponse = await fetch(
"https://api.squadvault.xyz/v1/uploads/document-file",
{
method: "POST",
headers: {
"x-api-key": process.env.SQUADVAULT_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
organizationId: "YOUR_ORG_ID",
contentType: "application/pdf",
sizeBytes,
}),
},
);
const { key, fileRef, uploadUrl } = await uploadResponse.json();
await fetch(uploadUrl, {
method: "PUT",
headers: { "Content-Type": "application/pdf" },
body: fileBuffer,
});
const documentResponse = await fetch(
"https://api.squadvault.xyz/v1/documents",
{
method: "POST",
headers: {
"x-api-key": process.env.SQUADVAULT_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
organizationId: "YOUR_ORG_ID",
name: "Playbook Q3",
fileUrl: fileRef,
fileKey: key,
contentType: "application/pdf",
sizeBytes,
tags: ["playbook"],
}),
},
);
const document = await documentResponse.json();