> ## Documentation Index
> Fetch the complete documentation index at: https://docs.adrelay.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sync Connections

> Sync all connected ad accounts to refresh account data and connection status.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.adrelay.dev/v1/connections/sync" \
    -H "X-API-Key: $ADRELAY_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.adrelay.dev/v1/connections/sync", {
    method: "POST",
    headers: { "X-API-Key": process.env.ADRELAY_API_KEY },
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.adrelay.dev/v1/connections/sync",
      headers={"X-API-Key": "your-api-key-here"},
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "synced": 2,
    "connections": [
      {
        "id": "conn_abc123",
        "platform": "google_ads",
        "status": "ACTIVE",
        "last_synced_at": "2026-03-21T10:00:00Z"
      },
      {
        "id": "conn_def456",
        "platform": "meta_ads",
        "status": "ACTIVE",
        "last_synced_at": "2026-03-21T10:00:01Z"
      }
    ]
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Invalid or missing API key.",
    "code": "UNAUTHORIZED",
    "timestamp": 1711036800,
    "request_id": "req_abc123"
  }
  ```
</ResponseExample>

Sync refreshes OAuth tokens if needed, verifies platform access, and updates each connection's status. Connections where access has been revoked will be updated to `REVOKED` status.
