0

Create entry

by
Published Oct 17, 2025

Create a new accounting entry

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 entry
7
 * Create a new accounting entry
8

9
 */
10
export async function main(
11
  auth: Holded,
12
  body: {
13
    date: number;
14
    lines: {
15
      account: number;
16
      credit?: number;
17
      debit?: number;
18
      description?: string;
19
      tags?: string[];
20
    }[];
21
    notes?: string;
22
  },
23
) {
24
  const url = new URL(`https://api.holded.com/api/accounting/v1/entry`);
25

26
  const response = await fetch(url, {
27
    method: "POST",
28
    headers: {
29
      "Content-Type": "application/json",
30
      key: auth.apiKey,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40