Documentation

Billing Integration

ZopNight reconciles its rack-rate cost estimates against your actual cloud invoices by syncing billing data nightly from each connected cloud account. The endpoints on this page let you check sync state, re-trigger a sync, and verify a freshly-connected account.

Why two cost numbers?

ZopNight computes a rack-rate cost from public pricing as soon as a resource is discovered (so you see "this VM costs $X/month" within minutes of connecting). The billing import then overwrites that with the actual invoiced amount once it's available — typically a 24–48 hour lag. See Reports for how the two reconcile.

Org-Wide Sync Status

GET
/billing/sync-status

Returns sync state for every cloud account in the org. Used by the dashboard's billing health badge.

Responsejson
{
  "data": [
    {
      "cloudAccountID": "ca_abc123",
      "provider": "aws",
      "lastSyncedAt": "2026-04-29T05:00:00Z",
      "status": "ok",
      "monthsBackfilled": 13
    },
    {
      "cloudAccountID": "ca_def456",
      "provider": "gcp",
      "lastSyncedAt": "2026-04-25T05:00:00Z",
      "status": "stale",
      "message": "Last successful sync was 4 days ago"
    }
  ]
}
POST
/billing/verify

Trigger an immediate billing sync across all cloud accounts. Returns a job reference; poll /billing/sync-status until the job completes.

Verify a Single Cloud Account

When a new cloud account is connected, the onboarding wizard runs a verification job: it confirms the billing export is reachable, schemas match, and a sample of recent records lands cleanly. The job is started and polled with the two endpoints below.

POST
/cloud-accounts/{accountID}/billing/verify

Start a billing verification job for a cloud account.

Requestbash
curl -X POST https://zopnight.com/api/cloud-accounts/ca_abc123/billing/verify \
  -H "Authorization: Bearer <token>"
Responsejson
{
  "data": {
    "verifyID": "ver_001",
    "status": "running"
  }
}
GET
/cloud-accounts/{accountID}/billing/verify/{verifyID}

Poll a verification job's status until it reports succeeded or failed.

Responsejson
{
  "data": {
    "verifyID": "ver_001",
    "status": "succeeded",
    "checks": {
      "billingExportReachable": true,
      "schemaMatches": true,
      "sampleRowsParsed": 142
    },
    "completedAt": "2026-04-29T08:02:30Z"
  }
}

Historical Backfill

On first connection, ZopNight backfills up to 13 months of billing history if your provider exposes it (AWS Cost & Usage Reports always do; GCP needs the BigQuery billing export enabled; Azure cost exports need to be configured at the subscription level). Backfill is part of the verify job and reports progress via monthsBackfilled in the sync-status response.

See Cloud Accounts for the full onboarding flow including the steps that precede billing verification.