Skip to main content

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.

MethodPathSummary
DELETE/cloudzero/deleteDisconnect CloudZero
POST/cloudzero/dry-runPreview the rows a CloudZero export would send
POST/cloudzero/exportSend spend to CloudZero now
POST/cloudzero/initConnect a CloudZero account
GET/cloudzero/settingsShow the CloudZero export settings
PUT/cloudzero/settingsChange 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:

StatusDescriptionBody
200Successful Responseapplication/json CloudZeroInitResponse
403Forbiddenapplication/json ErrorDetail
404Not Foundapplication/json ErrorDetail
500Internal Server Errorapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
statusstringYesStatus

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):

FieldTypeRequiredDescription
end_time_utcstring or nullNoEnd time for data export in UTC
limitinteger or nullNoOptional limit on number of records to export
operationenum: "replace_hourly", "sum"NoCloudZero operation type (replace_hourly or sum)
start_time_utcstring or nullNoStart 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:

StatusDescriptionBody
200Successful Responseapplication/json CloudZeroExportResponse
403Forbiddenapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Internal Server Errorapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
dry_run_dataobject or nullNoDry run data including usage data and CBF transformed data
messagestringYesMessage
records_exportedinteger or nullNoRecords Exported
statusstringYesStatus
summaryobject or nullNoSummary 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):

FieldTypeRequiredDescription
end_time_utcstring or nullNoEnd time for data export in UTC
limitinteger or nullNoOptional limit on number of records to export
operationenum: "replace_hourly", "sum"NoCloudZero operation type (replace_hourly or sum)
start_time_utcstring or nullNoStart 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:

StatusDescriptionBody
200Successful Responseapplication/json CloudZeroExportResponse
403Forbiddenapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Internal Server Errorapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
dry_run_dataobject or nullNoDry run data including usage data and CBF transformed data
messagestringYesMessage
records_exportedinteger or nullNoRecords Exported
statusstringYesStatus
summaryobject or nullNoSummary 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):

FieldTypeRequiredDescription
api_keystringYesCloudZero API key for authentication
connection_idstringYesCloudZero connection ID for data submission
timezonestringNoTimezone 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:

StatusDescriptionBody
200Successful Responseapplication/json CloudZeroInitResponse
403Forbiddenapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Internal Server Errorapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
statusstringYesStatus

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:

StatusDescriptionBody
200Successful Responseapplication/json CloudZeroSettingsView
403Forbiddenapplication/json ErrorDetail
500Internal Server Errorapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
api_key_maskedstring or nullNoMasked API key showing only first 4 and last 4 characters
connection_idstring or nullNoCloudZero connection ID for data submission
statusstring or nullNoConfiguration status
timezonestring or nullNoTimezone 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):

FieldTypeRequiredDescription
api_keystring or nullNoNew CloudZero API key for authentication
connection_idstring or nullNoNew CloudZero connection ID for data submission
timezonestring or nullNoNew 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:

StatusDescriptionBody
200Successful Responseapplication/json CloudZeroInitResponse
400Bad Requestapplication/json ErrorDetail
403Forbiddenapplication/json ErrorDetail
404Not Foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Internal Server Errorapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
statusstringYesStatus