const API_KEY = "key_...";
const formData = new FormData();
// File must be a File or Blob object.
// In Node.js you can use `fs.openAsBlob` to get a Blob from a file path, or use the `new buffer.Blob()` constructor if you have a Buffer
// In the browser, you can get a File from an <input type="file" /> element or use the `new Blob()` constructor if you have an ArrayBuffer
formData.append("file", document.querySelector('input[type="file"]').files[0]);
// JSON payload
formData.append("metadata", JSON.stringify({
invoice_id: "INV-123",
amount: 61.69,
currency: "GBP",
}), { contentType: "application/json" });
const response = await fetch("https://api.veqaro.com/invoices", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.API_KEY}`,
},
body: formData,
});
const data = await response.json();
console.log(data);