0

Update Contact

by
Published Oct 17, 2025

Update a specific contact. Only the params included in the operation will update the contact.

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 Contact
7
 * Update a specific contact.
8

9
Only the params included in the operation will update the contact.
10
 */
11
export async function main(
12
  auth: Holded,
13
  contactId: string,
14
  body: {
15
    name?: string;
16
    code?: string;
17
    tradeName?: string;
18
    email?: string;
19
    mobile?: string;
20
    phone?: string;
21
    type?: string;
22
    isperson?: false | true;
23
    iban?: string;
24
    swift?: string;
25
    sepaRef?: string;
26
    sepaDate?: number;
27
    clientRecord?: number;
28
    supplierRecord?: number;
29
    groupId?: string;
30
    taxOperation?: string;
31
    billAddress?: {
32
      address?: string;
33
      city?: string;
34
      postalCode?: string;
35
      province?: string;
36
      country?: string;
37
      countryCode?: string;
38
    };
39
    shippingAddresses?: {
40
      name?: string;
41
      address?: string;
42
      city?: string;
43
      postalCode?: string;
44
      province?: string;
45
      country?: string;
46
      notes?: string;
47
      privateNote?: string;
48
    }[];
49
    defaults?: {
50
      expensesAccountRecord?: number;
51
      expensesAccountName?: string;
52
      salesAccountRecord?: number;
53
      salesAccountName?: string;
54
      dueDays?: number;
55
      salesTax?: number;
56
      purchasesTax?: number;
57
      accumulateInForm347?: string;
58
      paymentMethod?: string;
59
      discount?: number;
60
      currency?: string;
61
      language?: string;
62
      showTradeNameOnDocs?: false | true;
63
      showCountryOnDocs?: false | true;
64
    };
65
    socialNetworks?: { website?: string };
66
    numberingSeries?: {
67
      invoice?: string;
68
      receipt?: string;
69
      salesOrder?: string;
70
      purchasesOrder?: string;
71
      proform?: string;
72
      waybill?: string;
73
    };
74
  },
75
) {
76
  const url = new URL(
77
    `https://api.holded.com/api/invoicing/v1/contacts/${contactId}`,
78
  );
79

80
  const response = await fetch(url, {
81
    method: "PUT",
82
    headers: {
83
      "Content-Type": "application/json",
84
      key: auth.apiKey,
85
    },
86
    body: JSON.stringify(body),
87
  });
88
  if (!response.ok) {
89
    const text = await response.text();
90
    throw new Error(`${response.status} ${text}`);
91
  }
92
  return await response.json();
93
}
94