0

Create a new legal entity

by
Published Oct 17, 2025

Create a new legal entity under an organization. **Token scopes**: `legal-entity:write`, `legal-entity:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a new legal entity
4
 * Create a new legal entity under an organization.
5
 **Token scopes**: `legal-entity:write`, `legal-entity:read`
6
 */
7
export async function main(auth: RT.Deel, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/legal-entities`)
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
		 * The legal name of the entity.
36
		 */
37
		name: string
38
		/**
39
		 * Contact phone number for the entity.
40
		 */
41
		phone: string
42
		/**
43
		 * The physical address of the entity.
44
		 */
45
		address: {
46
			/**
47
			 * Zip code.
48
			 */
49
			zip: string
50
			/**
51
			 * City name.
52
			 */
53
			city: string
54
			/**
55
			 * State
56
			 */
57
			state?: string
58
			/**
59
			 * Street address.
60
			 */
61
			street: string
62
			/**
63
			 * Country code.
64
			 */
65
			country: string
66
			[k: string]: unknown
67
		}
68
		/**
69
		 * The SIC number for the entity.
70
		 */
71
		sic_number: string
72
		/**
73
		 * Type of the entity.
74
		 */
75
		entity_type: string
76
		company_identifiers: {
77
			/**
78
			 * Tax number of the entity.
79
			 */
80
			tax_number: string
81
			/**
82
			 * Registration number of the entity.
83
			 */
84
			registration_number: string
85
			[k: string]: unknown
86
		}
87
		[k: string]: unknown
88
	}
89
	[k: string]: unknown
90
}
91