0

Update Function

by
Published Oct 17, 2025

Updates a Function. • In order to successfully call this endpoint, the specified Workspace needs to have the Functions feature enabled. Please reach out to your customer success manager for more information. Config API omitted fields: - `updateMask`

Script segment Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Segment = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * Update Function
8
 * Updates a Function.
9

10

11

12
• In order to successfully call this endpoint, the specified Workspace needs to have the Functions feature enabled. Please reach out to your customer success manager for more information.
13

14
Config API omitted fields:
15
- `updateMask`
16

17
 */
18
export async function main(
19
  auth: Segment,
20
  functionId: string,
21
  body: {
22
    code?: string;
23
    settings?: {
24
      name: string;
25
      label: string;
26
      description: string;
27
      type: "ARRAY" | "BOOLEAN" | "STRING" | "TEXT_MAP";
28
      required: false | true;
29
      sensitive: false | true;
30
    }[];
31
    displayName?: string;
32
    logoUrl?: string;
33
    description?: string;
34
  },
35
) {
36
  const url = new URL(`${auth.baseUrl}/functions/${functionId}`);
37

38
  const response = await fetch(url, {
39
    method: "PATCH",
40
    headers: {
41
      "Content-Type": "application/json",
42
      Authorization: "Bearer " + auth.token,
43
    },
44
    body: JSON.stringify(body),
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52