Cloudzero API
This page documents the 6 gateway endpoints tagged cloudzero in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| DELETE | /cloudzero/delete | Disconnect CloudZero |
| POST | /cloudzero/dry-run | Preview the rows a CloudZero export would send |
| POST | /cloudzero/export | Send spend to CloudZero now |
| POST | /cloudzero/init | Connect a CloudZero account |
| GET | /cloudzero/settings | Show the CloudZero export settings |
| PUT | /cloudzero/settings | Change the CloudZero export settings |
Endpoints
DELETE /cloudzero/delete
Disconnect CloudZero
Remove the saved CloudZero connection and stop the scheduled export. Data already sent to CloudZero stays there. Proxy admins only, and a 404 means nothing was set up. Docs (https://docs.spanway.ai/docs/proxy/cost_exports)
Example request:
curl -X DELETE "http://localhost:4000/cloudzero/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json CloudZeroInitResponse |
| 403 | Forbidden | application/json ErrorDetail |
| 404 | Not Found | application/json ErrorDetail |
| 500 | Internal Server Error | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
status | string | Yes | Status |
POST /cloudzero/dry-run
Preview the rows a CloudZero export would send
Build the export from the daily spend rollups and return the rows, the CloudZero billing format they become and a summary, without sending anything. limit caps the rows (10000 by default). Proxy admins only. Docs (https://docs.spanway.ai/docs/proxy/cost_exports)
Request body (application/json, schema CloudZeroExportRequest):
| Field | Type | Required | Description |
|---|---|---|---|
end_time_utc | string or null | No | End time for data export in UTC |
limit | integer or null | No | Optional limit on number of records to export |
operation | enum: "replace_hourly", "sum" | No | CloudZero operation type (replace_hourly or sum) |
start_time_utc | string or null | No | Start time for data export in UTC |
Example request:
curl -X POST "http://localhost:4000/cloudzero/dry-run" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"end_time_utc": "2026-10-08T00:00:00Z",
"limit": 10,
"start_time_utc": "2026-10-01T00:00:00Z"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json CloudZeroExportResponse |
| 403 | Forbidden | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Internal Server Error | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
dry_run_data | object or null | No | Dry run data including usage data and CBF transformed data |
message | string | Yes | Message |
records_exported | integer or null | No | Records Exported |
status | string | Yes | Status |
summary | object or null | No | Summary statistics for dry run |
POST /cloudzero/export
Send spend to CloudZero now
Export the daily spend rollups to CloudZero at once instead of waiting for the schedule. operation is replace_hourly (the default, replaces the matching hours) or sum, and start_time_utc, end_time_utc and limit narrow what is sent. Proxy admins only. Docs (https://docs.spanway.ai/docs/proxy/cost_exports)
Request body (application/json, schema CloudZeroExportRequest):
| Field | Type | Required | Description |
|---|---|---|---|
end_time_utc | string or null | No | End time for data export in UTC |
limit | integer or null | No | Optional limit on number of records to export |
operation | enum: "replace_hourly", "sum" | No | CloudZero operation type (replace_hourly or sum) |
start_time_utc | string or null | No | Start time for data export in UTC |
Example request:
curl -X POST "http://localhost:4000/cloudzero/export" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"end_time_utc": "2026-10-08T00:00:00Z",
"limit": 10,
"start_time_utc": "2026-10-01T00:00:00Z"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json CloudZeroExportResponse |
| 403 | Forbidden | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Internal Server Error | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
dry_run_data | object or null | No | Dry run data including usage data and CBF transformed data |
message | string | Yes | Message |
records_exported | integer or null | No | Records Exported |
status | string | Yes | Status |
summary | object or null | No | Summary statistics for dry run |
POST /cloudzero/init
Connect a CloudZero account
Save the CloudZero API key, connection id and timezone so the scheduled export can send daily spend. The key is encrypted with the salt key before it is stored. Proxy admins only. Docs (https://docs.spanway.ai/docs/proxy/cost_exports)
Request body (application/json, schema CloudZeroInitRequest):
| Field | Type | Required | Description |
|---|---|---|---|
api_key | string | Yes | CloudZero API key for authentication |
connection_id | string | Yes | CloudZero connection ID for data submission |
timezone | string | No | Timezone for date handling (default: UTC) |
Example request:
curl -X POST "http://localhost:4000/cloudzero/init" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"api_key": "czk_...",
"connection_id": "conn-12345",
"timezone": "UTC"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json CloudZeroInitResponse |
| 403 | Forbidden | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Internal Server Error | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
status | string | Yes | Status |
GET /cloudzero/settings
Show the CloudZero export settings
Return the saved CloudZero connection with the API key masked to its first and last four characters. Proxy admins and admin viewers only, empty fields and a null status mean nothing is set up yet. Docs (https://docs.spanway.ai/docs/proxy/cost_exports)
Example request:
curl -X GET "http://localhost:4000/cloudzero/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json CloudZeroSettingsView |
| 403 | Forbidden | application/json ErrorDetail |
| 500 | Internal Server Error | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
api_key_masked | string or null | No | Masked API key showing only first 4 and last 4 characters |
connection_id | string or null | No | CloudZero connection ID for data submission |
status | string or null | No | Configuration status |
timezone | string or null | No | Timezone for date handling |
PUT /cloudzero/settings
Change the CloudZero export settings
Change only the fields you send, api_key, connection_id or timezone, and keep the others. The key is encrypted before it is stored. Proxy admins only, and a 404 means there is nothing to change yet. Docs (https://docs.spanway.ai/docs/proxy/cost_exports)
Request body (application/json, schema CloudZeroSettingsUpdate):
| Field | Type | Required | Description |
|---|---|---|---|
api_key | string or null | No | New CloudZero API key for authentication |
connection_id | string or null | No | New CloudZero connection ID for data submission |
timezone | string or null | No | New timezone for date handling |
Example request:
curl -X PUT "http://localhost:4000/cloudzero/settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"timezone": "America/New_York"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json CloudZeroInitResponse |
| 400 | Bad Request | application/json ErrorDetail |
| 403 | Forbidden | application/json ErrorDetail |
| 404 | Not Found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Internal Server Error | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
status | string | Yes | Status |