0

Create an immigration case

by
Published Oct 17, 2025

Create an immigration case. **Token scopes**: `immigration:write`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create an immigration case
4
 * Create an immigration case.
5
 **Token scopes**: `immigration:write`
6
 */
7
export async function main(auth: RT.Deel, body: Body) {
8
	const url = new URL(`https://api.letsdeel.com/rest/v2/immigration/client/cases`)
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
		| RightToWorkCase
35
		| EORVisaCase
36
		| SponsoredVisaCase
37
		| PreHireEORVisaCase
38
		| PreHireSponsorshipVisaCase
39
	[k: string]: unknown
40
}
41
export interface RightToWorkCase {
42
	/**
43
	 * The type of immigration case to be created. Determines the workflow and requirements
44
	 */
45
	case_type: 'RIGHT_TO_WORK'
46
	/**
47
	 * The contract object identifier. Required for document reviews and visa applications
48
	 */
49
	contract_id: string
50
	/**
51
	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
52
	 */
53
	country_code: string
54
	[k: string]: unknown
55
}
56
export interface EORVisaCase {
57
	/**
58
	 * The type of immigration case to be created. Determines the workflow and requirements
59
	 */
60
	case_type: 'EOR_VISA'
61
	/**
62
	 * The contract object identifier. Required for document reviews and visa applications
63
	 */
64
	contract_id: string
65
	/**
66
	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
67
	 */
68
	country_code: string
69
	/**
70
	 * The id of visa type that is being applied for. Identifies the type of the visa.
71
	 */
72
	visa_type_id?: string
73
	[k: string]: unknown
74
}
75
export interface SponsoredVisaCase {
76
	/**
77
	 * The type of immigration case to be created. Determines the workflow and requirements
78
	 */
79
	case_type: 'SPONSORED_VISA'
80
	/**
81
	 * The unique identifier of the entity sponsoring the visa. Required for sponsored visa applications
82
	 */
83
	entity_id: string
84
	/**
85
	 * The contract object identifier. Required for document reviews and visa applications
86
	 */
87
	contract_id: string
88
	/**
89
	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
90
	 */
91
	country_code: string
92
	/**
93
	 * The id of visa type that is being applied for. Identifies the type of the visa.
94
	 */
95
	visa_type_id?: string
96
	[k: string]: unknown
97
}
98
export interface PreHireEORVisaCase {
99
	team_id: string
100
	/**
101
	 * The type of immigration case to be created. Determines the workflow and requirements
102
	 */
103
	case_type: 'PRE_HIRE_EOR_VISA'
104
	/**
105
	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
106
	 */
107
	country_code: string
108
	/**
109
	 * The id of visa type that is being applied for. Identifies the type of the visa.
110
	 */
111
	visa_type_id?: string
112
	[k: string]: unknown
113
}
114
export interface PreHireSponsorshipVisaCase {
115
	team_id: string
116
	/**
117
	 * The type of immigration case to be created. Determines the workflow and requirements
118
	 */
119
	case_type: 'PRE_HIRE_SPONSORSHIP_VISA'
120
	/**
121
	 * The unique identifier of the entity sponsoring the visa. Required for sponsored visa applications
122
	 */
123
	entity_id?: string
124
	/**
125
	 * ISO 3166-1 alpha-2 country code where the immigration case needs to be processed
126
	 */
127
	country_code: string
128
	/**
129
	 * The id of visa type that is being applied for. Identifies the type of the visa.
130
	 */
131
	visa_type_id?: string
132
	[k: string]: unknown
133
}
134