0

Create a project

by
Published Oct 17, 2025

Create a project.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Create a project
7
 * Create a project.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    project_name: string;
14
    customer_id: string;
15
    currency_id?: string;
16
    description?: string;
17
    billing_type: string;
18
    rate?: string;
19
    budget_type?: string;
20
    budget_hours?: string;
21
    budget_amount?: string;
22
    cost_budget_amount?: number;
23
    user_id: string;
24
    tasks?: {
25
      task_name: string;
26
      description?: string;
27
      rate?: string;
28
      budget_hours?: string;
29
    }[];
30
    users?: {
31
      user_id?: string;
32
      is_current_user?: false | true;
33
      user_name?: string;
34
      email?: string;
35
      user_role?: string;
36
      status?: string;
37
      rate?: string;
38
      budget_hours?: string;
39
      total_hours?: string;
40
      billed_hours?: string;
41
      un_billed_hours?: string;
42
      cost_rate?: number;
43
    }[];
44
  },
45
) {
46
  const url = new URL(`https://www.zohoapis.com/books/v3/projects`);
47
  for (const [k, v] of [["organization_id", organization_id]]) {
48
    if (v !== undefined && v !== "" && k !== undefined) {
49
      url.searchParams.append(k, v);
50
    }
51
  }
52
  const response = await fetch(url, {
53
    method: "POST",
54
    headers: {
55
      "Content-Type": "application/json",
56
      Authorization: "Zoho-oauthtoken " + auth.token,
57
    },
58
    body: JSON.stringify(body),
59
  });
60
  if (!response.ok) {
61
    const text = await response.text();
62
    throw new Error(`${response.status} ${text}`);
63
  }
64
  return await response.json();
65
}
66