0

Edit a legal entity

by
Published Oct 17, 2025

Update the details of an existing legal entity. **Token scopes**: `legal-entity:read`, `legal-entity:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit a legal entity
4
 * Update the details of an existing legal entity.
5
 **Token scopes**: `legal-entity:read`, `legal-entity:write`
6
 */
7
export async function main(auth: RT.Deel, id: string, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/legal-entities/${id}`)
9

10
	const response = await fetch(url, {
11
		method: 'PATCH',
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
	/**
34
	 * The name of the legal entity.
35
	 */
36
	name?: string
37
	/**
38
	 * The phone number of the legal entity.
39
	 */
40
	phone?: string
41
	address?: {
42
		/**
43
		 * The city.
44
		 */
45
		city?: string
46
		/**
47
		 * The state.
48
		 */
49
		state?: string
50
		/**
51
		 * The street address.
52
		 */
53
		street?: string
54
		/**
55
		 * The ISO 2-letter country code.
56
		 */
57
		country?: string
58
		[k: string]: unknown
59
	}
60
	/**
61
	 * The SIC number of the legal entity.
62
	 */
63
	sic_number?: string
64
	/**
65
	 * The type of the legal entity.
66
	 */
67
	entity_type?: string
68
	/**
69
	 * The industry name of the legal entity.
70
	 */
71
	industry_name?: string
72
	/**
73
	 * Identifiers associated with the legal entity.
74
	 */
75
	company_identifiers?: {
76
		/**
77
		 * The tax identification number of the legal entity.
78
		 */
79
		tax_number?: string
80
		/**
81
		 * The registration number of the legal entity.
82
		 */
83
		registration_number?: string
84
		[k: string]: unknown
85
	}
86
	[k: string]: unknown
87
}
88