0

Create Vendor Bill

by
Published Oct 17, 2025

Create vendor bills from external invoice provider data **Token scopes**: `treasury-vendorbill:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create Vendor Bill
4
 * Create vendor bills from external invoice provider data
5
 **Token scopes**: `treasury-vendorbill:write`
6
 */
7
export async function main(auth: RT.Deel, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/accounts-payable/vendor-bills`)
9

10
	const response = await fetch(url, {
11
		method: 'POST',
12
		headers: {
13
			'Content-Type': 'application/json',
14
			Authorization: 'Bearer ' + auth.apiKey
15
		},
16
		body: JSON.stringify(body)
17
	})
18
	if (!response.ok) {
19
		const text = await response.text()
20
		throw new Error(`${response.status} ${text}`)
21
	}
22
	return await response.json()
23
}
24

25
/* eslint-disable */
26
/**
27
 * This file was automatically generated by json-schema-to-typescript.
28
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
29
 * and run json-schema-to-typescript to regenerate this file.
30
 */
31

32
export interface Body {
33
	data: {
34
		/**
35
		 * Invoice/bill date
36
		 */
37
		date: string
38
		/**
39
		 * Total amount including VAT
40
		 */
41
		amount: number
42
		/**
43
		 * ISO 4217 currency code
44
		 */
45
		currency: string
46
		/**
47
		 * Due date for payment
48
		 */
49
		due_date: string
50
		/**
51
		 * Subtotal amount excluding VAT
52
		 */
53
		subtotal: number
54
		/**
55
		 * Vendor bill reference
56
		 */
57
		reference: string
58
		/**
59
		 * Unique identifier for the Vendor
60
		 */
61
		vendor_id: string
62
		/**
63
		 * Line items for the vendor bill
64
		 *
65
		 * @minItems 1
66
		 */
67
		line_items: {
68
			/**
69
			 * Total amount for this line item
70
			 */
71
			amount: number
72
			/**
73
			 * Quantity of items
74
			 */
75
			quantity: number
76
			/**
77
			 * VAT rate percentage
78
			 */
79
			vat_rate: number
80
			/**
81
			 * Price per unit
82
			 */
83
			unit_price: number
84
			/**
85
			 * VAT amount for this line item
86
			 */
87
			vat_amount?: number
88
			/**
89
			 * Description of the line item
90
			 */
91
			description: string
92
			/**
93
			 * Unique Identifier for the Financial department
94
			 */
95
			department_id?: string
96
			/**
97
			 * Unique Identifier for the Expense account
98
			 */
99
			expense_account_id?: string
100
			[k: string]: unknown
101
		}[]
102
		/**
103
		 * General description of the vendor bill
104
		 */
105
		description: string
106
		/**
107
		 * External system identifier (e.g., Brightflag ID)
108
		 */
109
		external_id: string
110
		/**
111
		 * Type of document
112
		 */
113
		document_type: 'INVOICE' | 'RECEIPT' | 'BILL'
114
		/**
115
		 * Unique identifier for the Deel legal entity/subsidiary
116
		 */
117
		subsidiary_id: string
118
		[k: string]: unknown
119
	}
120
	[k: string]: unknown
121
}
122