0

Create Contact

by
Published Oct 17, 2025

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

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