0

Upload Vendor Bill Attachment

by
Published Oct 17, 2025

Use this endpoint to attach a PDF invoice file to an existing vendor bill entity. Submit the file via multipart/form-data with the file in the request body. **Token scopes**: `treasury-vendorbill:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Upload Vendor Bill Attachment
4
 * Use this endpoint to attach a PDF invoice file to an existing vendor bill entity. Submit the file via multipart/form-data with the file in the request body.
5
 **Token scopes**: `treasury-vendorbill:write`
6
 */
7
export async function main(auth: RT.Deel, vendor_bill_id: string, body: Body) {
8
	const url = new URL(
9
		`https://api.letsdeel.com/rest/v2/accounts-payable/vendor-bills/${vendor_bill_id}/attachments`
10
	)
11

12
	const formData = new FormData()
13
	for (const [k, v] of Object.entries(body)) {
14
		if (v !== undefined && v !== '') {
15
			formData.append(k, String(v))
16
		}
17
	}
18
	const response = await fetch(url, {
19
		method: 'POST',
20
		headers: {
21
			Authorization: 'Bearer ' + auth.apiKey
22
		},
23
		body: formData
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31

32
/* eslint-disable */
33
/**
34
 * This file was automatically generated by json-schema-to-typescript.
35
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
36
 * and run json-schema-to-typescript to regenerate this file.
37
 */
38

39
export interface Body {
40
	data: {
41
		/**
42
		 * PDF file to upload (max 8MB)
43
		 */
44
		file?: string
45
		[k: string]: unknown
46
	}
47
	[k: string]: unknown
48
}
49