Edits history of script submission #20055 for ' Get Reverse ETL Sync Status (segment)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Segment = {
      token: string;
      baseUrl: string;
    };
    /**
     * Get Reverse ETL Sync Status
     * Get the sync status for a Reverse ETL sync. 
    The sync status includes all detailed information about the sync - sync status, duration, details about the extract and load phase if applicable, etc.
    
    
    The rate limit for this endpoint is 250 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.
     */
    export async function main(auth: Segment, modelId: string, syncId: string) {
      const url = new URL(
        `${auth.baseUrl}/reverse-etl-models/${modelId}/syncs/${syncId}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 235 days ago