Sync Data Connection API with Custom Start Time #
This guide shows you two ways to manually sync data for any supported data connection starting from a custom timestamp:
- (Recommended) Use the Ready-to-Run Script – Fastest and simplest method.
- Manual Method with Developer Tools – See exactly what’s going on behind the scenes.
Option 1: Use the Ready-to-Run Script #
Run the following script directly in your browser’s Developer Console (press F12 and open the “Console” tab):
(async () => {
const baseUrl = location.origin;
// Step 1: Get workspace ID from session storage
const workspaceId = sessionStorage.getItem("workspace_id");
// Step 2: Fetch data connections
const headers = {
"accept": "application/json"
};
if (workspaceId) {
headers["x-workspace-id"] = workspaceId;
}
const res = await fetch(`${baseUrl}/api/data_connections`, {
method: "GET",
credentials: "include",
headers
});
const { ok, response } = await res.json();
const connections = response?.data_connections ?? [];
if (!ok) {
console.error("Failed to fetch data connections.");
return;
}
if (connections.length === 0) {
console.error("No data connections found.");
return;
}
// Step 3: Show available connections
console.log("Available Data Connections:");
connections.forEach((c, i) => {
console.log(`${i + 1}: ${c.name} (${c.id}) [${c.type}]`);
});
// Step 4: Prompt for comma-separated indices
const input = prompt("Enter connection numbers to sync. Use comma to separate in case of multi select. (e.g., 1,3,4):");
const indices = input.split(",").map(i => parseInt(i.trim(), 10)).filter(i => i >= 1 && i <= connections.length);
if (indices.length === 0) {
console.error("No valid selections.");
return;
}
// Step 5: Prompt for sync date
const dateInput = prompt("Enter sync start date (YYYY-MM-DD):");
const date = new Date(dateInput);
if (isNaN(date.getTime())) {
console.error("Invalid date.");
return;
}
const fromTimestamp = Math.floor(date.getTime() / 1000);
// Step 6: Sync each selected connection
for (const idx of indices) {
const conn = connections[idx - 1];
console.log(`Starting sync for ${conn.name} (${conn.id})...`);
const syncUrl = `${baseUrl}/api/data_connections/${conn.id}/sync?from=${fromTimestamp}`;
const syncHeaders = {
"accept": "application/json",
"content-type": "application/json"
};
if (workspaceId) {
syncHeaders["x-workspace-id"] = workspaceId;
}
const syncRes = await fetch(syncUrl, {
method: "POST",
credentials: "include",
headers: syncHeaders
});
const syncData = await syncRes.json();
if (syncData.ok) {
console.log(`Sync started for ${conn.name}:`, syncData.response);
} else {
console.error(`Sync failed for ${conn.name}:`, syncData.error || syncData);
}
}
})();
How to Use:
- Make sure you are logged in to the application UI.
- Paste the script into the browser console and run it.
- The script will:
- Automatically detect your workspace ID and list all available data connections.
- Prompt you to select one or more data connections to sync (by entering their numbers).
- Prompt you to enter the start date (in YYYY-MM-DD format) from which you want to trigger the sync.
- The selected connections will be synced from your specified date. Progress and any errors will be shown in the console.
- After sync, refresh the Connections page to see the updated information.
Video guide: View Here
Option 2: Manual Method via Developer Tools #
-
Initiate a Sync from the App UI
- Start a sync for your target connection in the application.
-
Open Developer Tools → Network Tab
- Open Developer Tools (
F12). - Go to the “Network” tab and locate a POST request matching:
/api/data_connections/{connection_id}/sync
- Open Developer Tools (
-
Copy as Fetch
- Right-click your request and select
Copy → Copy as fetch.
- Right-click your request and select
-
Customize and Run
- Go to the Console tab, paste the fetch command.
- Modify the URL to add the
fromquery parameter (your Unix timestamp in seconds):fetch("https://app.funnelstory.ai/api/data_connections/{connection_id}/sync?from=<timestamp>", { ... }) - Update
{connection_id}and<timestamp>, then pressEnterto run.
-
Check Your Results
- The status will be output to the console.
- Or, find the new sync API call in Network → Response tab for full details.
API Specification #
Endpoint
POST /api/data_connections/{connection_id}/sync?from={timestamp}
Parameters
connection_id(string, required): The unique ID for your data connection.from(integer, optional): Unix timestamp (seconds) – start syncing from this time.- If not provided, syncs data from the last 30 days by default.
- Must not be a future timestamp.
until(integer, optional): Unix timestamp (seconds) – end syncing at this time.- For Zoom meetings, if only
fromoruntilis provided, the other defaults as follows to create a valid range:- Missing
fromis set to 30 days beforeuntil. - Missing
untilis set to the current time.
- Missing
- For Zoom meetings, if only
Supported Connections
- Zendesk
- Gong
- Slack
- Zoom
Responses #
Success (200 OK):
{
"ok": true,
"response": {
"id": "id",
"data_connection_id": "data_connection_id",
"started_at": "2025-03-21T08:16:34.861137436Z",
"ended_at": "2025-03-21T08:16:35.100433349Z"
}
}
Error (400 Bad Request):
{
"ok": false,
"error": "from time is in the future"
}
Error (500 Internal Server Error):
{
"ok": false,
"error": "Internal Server Error"
}
Summary #
- Fastest Way: Paste and run the ready-to-use script in your browser console.
- Manual Way: Copy and modify the fetch request via Developer Tools.
- Review output directly in the console or the Network tab.