0

Create child organization

by
Published Oct 17, 2025

Creates a new organization along with: - An API token scoped to the new organization.

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create child organization
4
 * Creates a new organization along with:
5

6
- An API token scoped to the new organization.
7
 */
8
export async function main(auth: RT.Deel, body: Body) {
9
	const url = new URL(`https://api.letsdeel.com/rest/v2/organizations/children`)
10

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

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

33
export interface Body {
34
	/**
35
	 * The request payload.
36
	 */
37
	data: {
38
		/**
39
		 * The object that contains all the information related to the child organization that will be created.
40
		 */
41
		child_organization: {
42
			/**
43
			 * The organization's name.
44
			 */
45
			name: string
46
			/**
47
			 * The department's name where the manager will be added
48
			 */
49
			department?: string
50
			/**
51
			 * The flag that enables the public API for the child organization.
52
			 */
53
			is_api_enabled?: boolean
54
			/**
55
			 * The workforce size of the child organization.
56
			 */
57
			workforce_size?: number
58
			/**
59
			 * The 2-letter country code of the organization's headquarters.
60
			 */
61
			headquarters_country?: string
62
			[k: string]: unknown
63
		}
64
		/**
65
		 * The object that contains the information related to the parent_organization.
66
		 */
67
		parent_organization: {
68
			/**
69
			 * The email of one of the managers of the parent organization that will be used to create an user for the child organization, it should exists on the parent organization.
70
			 */
71
			admin_email?: string
72
			[k: string]: unknown
73
		}
74
		[k: string]: unknown
75
	}
76
	[k: string]: unknown
77
}
78