0

Update an employee

by
Published Oct 17, 2025

Update an employee.

Script holded Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Holded = {
3
  apiKey: string;
4
};
5
/**
6
 * Update an employee
7
 * Update an employee.
8
 */
9
export async function main(
10
  auth: Holded,
11
  employeeId: string,
12
  body: {
13
    name?: string;
14
    lastName?: string;
15
    mainEmail?: string;
16
    email?: string;
17
    nationality?: string;
18
    phone?: string;
19
    mobile?: string;
20
    dateOfBirth?: string;
21
    gender?: string;
22
    mainLanguage?: string;
23
    iban?: string;
24
    timeOffPolicyId?: string;
25
    timeOffSupervisors?: string[];
26
    reportingTo?: string;
27
    code?: string;
28
    socialSecurityNum?: string;
29
    address?: {
30
      address?: string;
31
      city?: string;
32
      postalCode?: string;
33
      province?: string;
34
      country?: string;
35
    };
36
    fiscalResidence?: false | true;
37
    fiscalAddress?: {
38
      idNum?: string;
39
      address?: string;
40
      city?: string;
41
      cityOfBirth?: string;
42
      postalCode?: string;
43
      province?: string;
44
      country?: string;
45
      countryOfBirth?: string;
46
      endSituationDate?: string;
47
    };
48
    workplace?: string;
49
    teams?: string[];
50
    holdedUserId?: string;
51
  },
52
) {
53
  const url = new URL(
54
    `https://api.holded.com/api/team/v1/employees/${employeeId}`,
55
  );
56

57
  const response = await fetch(url, {
58
    method: "PUT",
59
    headers: {
60
      "Content-Type": "application/json",
61
      key: auth.apiKey,
62
    },
63
    body: JSON.stringify(body),
64
  });
65
  if (!response.ok) {
66
    const text = await response.text();
67
    throw new Error(`${response.status} ${text}`);
68
  }
69
  return await response.json();
70
}
71