0

Update Warehouse

by
Published Oct 17, 2025

Updates an existing Warehouse. • When called, this endpoint may generate one or more of the following audit trail events:* Storage Destination Modified * Storage Destination Enabled

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 Warehouse
8
 * Updates an existing Warehouse.
9

10

11

12
• When called, this endpoint may generate one or more of the following audit trail events:* Storage Destination Modified
13
* Storage Destination Enabled
14
      
15
 */
16
export async function main(
17
  auth: Segment,
18
  warehouseId: string,
19
  body: { name?: string; enabled?: false | true; settings: {} },
20
) {
21
  const url = new URL(`${auth.baseUrl}/warehouses/${warehouseId}`);
22

23
  const response = await fetch(url, {
24
    method: "PATCH",
25
    headers: {
26
      "Content-Type": "application/json",
27
      Authorization: "Bearer " + auth.token,
28
    },
29
    body: JSON.stringify(body),
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37