0

Send contract to worker

by
Published Oct 17, 2025

Invite a worker to sign the contract. Worker will be notified via email **Token scopes**: `contracts:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Send contract to worker
4
 * Invite a worker to sign the contract. Worker will be notified via email
5
 **Token scopes**: `contracts:write`
6
 */
7
export async function main(auth: RT.Deel, contract_id: string, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/contracts/${contract_id}/invitations`)
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
		 * Worker email
36
		 */
37
		email?: string
38
		/**
39
		 * Locale of the email
40
		 */
41
		locale?:
42
			| 'en'
43
			| 'es'
44
			| 'fr'
45
			| 'de'
46
			| 'it'
47
			| 'pt'
48
			| 'pl'
49
			| 'nn'
50
			| 'nl'
51
			| 'da'
52
			| 'deAT'
53
			| 'fi'
54
			| 'sv'
55
			| 'nlBE'
56
			| 'ja'
57
		/**
58
		 * Message to the worker
59
		 */
60
		message?: string
61
		[k: string]: unknown
62
	}
63
	[k: string]: unknown
64
}
65