0

List Reverse ETL Sync Statuses from Model And Subscription Id

by
Published Oct 17, 2025

Get the sync statuses for a Reverse ETL mapping subscription. The sync status includes all detailed information about the sync - sync status, duration, details about the extract and load phase if applicable, etc. The default page count is 10, and then the next page can be fetched by passing the `cursor` query parameter.

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
 * List Reverse ETL Sync Statuses from Model And Subscription Id
8
 * Get the sync statuses for a Reverse ETL mapping subscription. 
9
The sync status includes all detailed information about the sync - sync status, duration, details about the extract and load phase if applicable, etc. 
10
The default page count is 10, and then the next page can be fetched by passing the `cursor` query parameter.
11
 */
12
export async function main(
13
  auth: Segment,
14
  modelId: string,
15
  subscriptionId: string,
16
  count: string | undefined,
17
  cursor: string | undefined,
18
) {
19
  const url = new URL(
20
    `${auth.baseUrl}/reverse-etl-models/${modelId}/subscriptionId/${subscriptionId}/syncs`,
21
  );
22
  for (const [k, v] of [
23
    ["count", count],
24
    ["cursor", cursor],
25
  ]) {
26
    if (v !== undefined && v !== "" && k !== undefined) {
27
      url.searchParams.append(k, v);
28
    }
29
  }
30
  const response = await fetch(url, {
31
    method: "GET",
32
    headers: {
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: undefined,
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.text();
42
}
43