0

Replace Advanced Sync Schedule for Warehouse

by
Published Oct 17, 2025

Updates the advanced sync schedule for a Warehouse, replacing the sync schedule with a new schedule. The rate limit for this endpoint is 2 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.

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
 * Replace Advanced Sync Schedule for Warehouse
8
 * Updates the advanced sync schedule for a Warehouse, replacing the sync schedule with a new schedule.
9

10

11
The rate limit for this endpoint is 2 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
12
 */
13
export async function main(
14
  auth: Segment,
15
  warehouseId: string,
16
  body: {
17
    enabled: false | true;
18
    schedule?: {
19
      times: { hourOfDay: number; enabled: false | true }[];
20
      timezone: string;
21
    };
22
  },
23
) {
24
  const url = new URL(
25
    `${auth.baseUrl}/warehouses/${warehouseId}/advanced-sync-schedule`,
26
  );
27

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