0

Create a single deduction loan

by
Published Oct 17, 2025

Create a single deduction loan **Token scopes**: `benefits:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a single deduction loan
4
 * Create a single deduction loan
5
 **Token scopes**: `benefits:write`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	id: string,
10
	contract_id: string,
11
	plan_id: string,
12
	body: Body
13
) {
14
	const url = new URL(
15
		`https://api.letsdeel.com/rest/v2/benefits/legal-entities/${id}/contracts/${contract_id}/plans/${plan_id}/deductions`
16
	)
17

18
	const response = await fetch(url, {
19
		method: 'POST',
20
		headers: {
21
			'Content-Type': 'application/json',
22
			Authorization: 'Bearer ' + auth.apiKey
23
		},
24
		body: JSON.stringify(body)
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.json()
31
}
32

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

40
/**
41
 * Schema for the 401K Guideline Plan request body.
42
 */
43
export interface Body {
44
	/**
45
	 * Value of of the deduction.
46
	 */
47
	value: number
48
	/**
49
	 * Currency.
50
	 */
51
	currency: 'USD'
52
	[k: string]: unknown
53
}
54