Give zkao credits on a branch
const url = 'https://zkao.io/api/v1/projects/example/repositories/example/continuous-testing/credits';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"branch":"main","credits":30000,"enabledFeatures":["formal-verification"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://zkao.io/api/v1/projects/example/repositories/example/continuous-testing/credits \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "branch": "main", "credits": 30000, "enabledFeatures": [ "formal-verification" ] }'Requires scope: automations:write. The credits are spent right away and never repeat. Whatever this month leaves unspent carries into the next. They add to any monthly budget. On a branch with no schedule, this starts Continuous Security funded by these credits alone, with no monthly budget; enabledFeatures or enableFeatures choose its analyses before it starts. On an existing schedule, the other fields change it as PUT does, in the same change: a refused change gives nothing. Giving credits wakes zkao and re-arms a schedule that had stopped. A paused schedule is refused with 409 unless the request also sends enabled: true, which resumes it. Each call gives again, so read the branch before retrying a request whose outcome you did not see. The response lists in warnings anything that may stop the branch before it uses its credits.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Credits to give, within the returned minimum and maximum monthly budget.
Resumes a paused schedule with these credits. A paused schedule refuses credits without it.
The branch. Defaults to the repository’s default branch.
Replaces the rotation set. An empty array scans the whole repository every run.
Adds the listed analyses to the current selection. Mutually exclusive with enabledFeatures.
Replaces the selection with exactly these analyses. Mutually exclusive with enableFeatures.
not matching
Examples
Start formal verification alone, funded once
{ "branch": "main", "credits": 30000, "enabledFeatures": [ "formal-verification" ]}Responses
Section titled “ Responses ”OK
object
False when Continuous Security is not offered.
False when there is no schedule or it is paused.
Why an enabled schedule is not running: budget_reached when the schedule’s or project’s monthly automation cap is reached, needs_credits when the organization’s credits cannot fund the next run (it resumes on its own once they can), error after repeated failures. Null with no schedule.
The configured monthly spending cap, which refills every month. Null when nothing repeats, as on a branch funded only by given credits. Legacy schedules derive the budget from their cadence and per-run budget.
What the branch can still spend this month, from given credits and the monthly budget. Given credits left unspent carry into the next month. Null with no schedule, or for an older schedule without a monthly budget.
Legacy fixed cadence. Null for a custom interval or no schedule. Use intervalHours for the actual interval.
Hours between scheduled runs. Null when no schedule exists.
Audit areas the runs rotate through, one per run, least recently scanned first. Empty means every run scans the whole repository.
Analyses offered on this branch. Empty when Continuous Security is unavailable.
Selected analyses. A new branch starts with all analyses offered by its preset. Existing schedules keep their selection. A paused schedule keeps its selection.
Credits the branch was charged for Continuous Security since the UTC month began, net of refunds. Counts its analysis steps, change assessments, public-key reviews, agent questions and the planning included in steps.
Runs the schedule launched since the UTC month began.
When the next run becomes due. A past time means within the hour. Null when paused or stopped.
The monthly budget a new schedule gets when the request names none. It funds at least one analysis step.
A monthly budget that funds about four analysis steps, within the minimum and maximum. A suggestion to pass as monthlyBudgetCredits. It is never applied when the request names no budget.
The smallest month that funds one analysis step. Less is refused.
The largest monthly budget currently allowed for the repository. Administrators can raise it.
What may stop an enabled schedule before it uses what it has. Empty when nothing does, and always empty for a paused schedule.
object
balance_below_step when the organization’s credits cannot fund one analysis step, balance_below_budget when they fund a step but are less than the monthly budget or what the branch has left this month, project_limit_below_budget when the project’s monthly limit for automated scans will stop the branch first.
A sentence to show the user.
What the organization’s balance, or the project’s monthly limit, still holds.
The step, monthly budget or remaining credits it falls short of.
Example
{ "state": "active", "cadence": "daily", "availableFeatures": [ "bug-hunting" ], "enabledFeatures": [ "bug-hunting" ], "warnings": [ { "code": "balance_below_step" } ]}Invalid request
object
object
Budget_below_minimum only: the least the launch could have reserved, in credits. A diff scan’s first scan of a repository also builds its overview, so its minimum is higher.
Example
{ "error": { "code": "unauthorized" }}Missing, malformed, expired, or revoked token
object
object
Budget_below_minimum only: the least the launch could have reserved, in credits. A diff scan’s first scan of a repository also builds its overview, so its minimum is higher.
Example
{ "error": { "code": "unauthorized" }}The token lacks the required scope
object
object
Budget_below_minimum only: the least the launch could have reserved, in credits. A diff scan’s first scan of a repository also builds its overview, so its minimum is higher.
Example
{ "error": { "code": "unauthorized" }}Resource not in this token’s project or repo allowlist
object
object
Budget_below_minimum only: the least the launch could have reserved, in credits. A diff scan’s first scan of a repository also builds its overview, so its minimum is higher.
Example
{ "error": { "code": "unauthorized" }}A compare-and-set (expectedContent) missed: the guidance changed since it was read. Re-read the current guidance and retry.
object
object
Budget_below_minimum only: the least the launch could have reserved, in credits. A diff scan’s first scan of a repository also builds its overview, so its minimum is higher.
Example
{ "error": { "code": "unauthorized" }}