# Turn Continuous Security on, change it, or pause it

PUT

/projects/{projectId}/repositories/{repositoryId}/continuous-testing

```js
const url = 'https://zkao.io/api/v1/projects/example/repositories/example/continuous-testing';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"branch":"main","enableFeatures":["formal-verification"]}'
};


try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```sh
curl --request PUT \
  --url https://zkao.io/api/v1/projects/example/repositories/example/continuous-testing \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "branch": "main", "enableFeatures": [ "formal-verification" ] }'
```

* Production`zkao.io/api/v1/projects/{projectId}/repositories/{repositoryId}/continuous-testing`
* Staging`staging.zkao.io/api/v1/projects/{projectId}/repositories/{repositoryId}/continuous-testing`

Requires scope: `automations:write`. Every field is optional. To start a schedule, send `enabled: true` with the branch and its authorized monthly budget. A new schedule uses `defaultMonthlyCredits` when no budget is given. The default is a low limit that funds at least one analysis step. When a month’s budget is used, automatic analysis waits until the budget is raised or the month resets. The budget sets the interval smoothly from once a month to twice a day. A budget outside the returned minimum and maximum is refused with `400`. Administrators can raise the maximum monthly budget. `areaKeys` replaces the audit areas runs rotate through, one per run. Use `enableFeatures` to add analyses or `enabledFeatures` to replace the selection. Omit both to keep it. A selection sent without `enabled` or `monthlyBudgetCredits` requires an existing schedule and returns `409` if none exists. The resulting selection must include at least one analysis that can run on its own. `enabled: false` pauses the schedule and keeps it. A change re-arms a schedule that had stopped. Each run still needs spendable credits when it launches. A budget above what the organization or the project can fund is saved, and the response lists why in `warnings`. To fund work once instead of every month, give credits.

## Authorizations

* **[bearerAuth](https://docs.staging.zkao.io/api/#bearerauth)**

## Parameters

### Path Parameters

* **projectId**

  required

  string

* **repositoryId**

  required

  string

## Request Bodyrequired

application/json

object

* **enabled**

  False pauses the schedule; true turns it on or resumes it.

  boolean

* **monthlyBudgetCredits**

  Re-plans the interval and the per-run budget within the returned minimum and maximum.

  integer

  \>= 1

* **areaKeys**

  Replaces the rotation set. An empty array scans the whole repository every run.

  Array\<string>

  <= 20 items

* **enableFeatures**

  Adds the listed analyses to the current selection. Mutually exclusive with enabledFeatures.

  Array\<string>

  \>= 1 items unique items

  Allowed values: bug-hunting formal-verification dependency-analysis weak-key-analysis security-invariants

* **enabledFeatures**

  Replaces the selection with exactly these analyses. Mutually exclusive with enableFeatures.

  Array\<string>

  \>= 1 items unique items

  Allowed values: bug-hunting formal-verification dependency-analysis weak-key-analysis security-invariants

* **branch**

  The scheduled branch. Defaults to the repository’s default branch.

  string

not matching

* **enableFeatures**

  required

* **enabledFeatures**

  required

##### Examples

addFormalVerification

Add formal verification to an existing schedule

```json
{
  "branch": "main",
  "enableFeatures": [
    "formal-verification"
  ]
}
```

formalVerificationOnly

Start or resume formal verification alone with an approved monthly budget

```json
{
  "branch": "main",
  "enabled": true,
  "monthlyBudgetCredits": 50000,
  "enabledFeatures": [
    "formal-verification"
  ]
}
```

## Responses

### 200

OK

application/json

object

* **repositoryId**

  required

  string

* **available**

  required

  False when Continuous Security is not offered.

  boolean

* **enabled**

  required

  False when there is no schedule or it is paused.

  boolean

* **state**

  required

  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.

  string | null

  Allowed values: active converged budget_reached needs_credits error

* **branch**

  required

  string

* **monthlyBudgetCredits**

  required

  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.

  integer | null

* **leftThisMonthCredits**

  required

  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.

  integer | null

* **cadence**

  required

  Legacy fixed cadence. Null for a custom interval or no schedule. Use intervalHours for the actual interval.

  string | null

  Allowed values: daily weekly biweekly monthly

* **intervalHours**

  required

  Hours between scheduled runs. Null when no schedule exists.

  integer | null

  \>= 1

* **perRunBudgetCredits**

  required

  integer | null

* **areaKeys**

  required

  Audit areas the runs rotate through, one per run, least recently scanned first. Empty means every run scans the whole repository.

  Array\<string>

* **availableFeatures**

  required

  Analyses offered on this branch. Empty when Continuous Security is unavailable.

  Array\<string>

  unique items

  Allowed values: bug-hunting formal-verification dependency-analysis weak-key-analysis security-invariants

* **enabledFeatures**

  required

  Selected analyses. A new branch starts with all analyses offered by its preset. Existing schedules keep their selection. A paused schedule keeps its selection.

  Array\<string>

  unique items

  Allowed values: bug-hunting formal-verification dependency-analysis weak-key-analysis security-invariants

* **spentThisMonthCredits**

  required

  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.

  integer

* **runsThisMonth**

  required

  Runs the schedule launched since the UTC month began.

  integer

* **lastRunAt**

  required

  string | null format: date-time

* **nextRunAt**

  required

  When the next run becomes due. A past time means within the hour. Null when paused or stopped.

  string | null format: date-time

* **defaultMonthlyCredits**

  required

  The monthly budget a new schedule gets when the request names none. It funds at least one analysis step.

  integer | null

* **recommendedMonthlyCredits**

  required

  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.

  integer | null

* **minimumMonthlyCredits**

  required

  The smallest month that funds one analysis step. Less is refused.

  integer | null

* **maximumMonthlyCredits**

  required

  The largest monthly budget currently allowed for the repository. Administrators can raise it.

  integer | null

* **warnings**

  required

  What may stop an enabled schedule before it uses what it has. Empty when nothing does, and always empty for a paused schedule.

  Array\<object>

  object

  * **code**

    required

    `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.

    string

    Allowed values: balance_below_step balance_below_budget project_limit_below_budget

  * **message**

    required

    A sentence to show the user.

    string

  * **availableCredits**

    required

    What the organization’s balance, or the project’s monthly limit, still holds.

    integer

  * **neededCredits**

    required

    The step, monthly budget or remaining credits it falls short of.

    integer

##### Example

```json
{
  "state": "active",
  "cadence": "daily",
  "availableFeatures": [
    "bug-hunting"
  ],
  "enabledFeatures": [
    "bug-hunting"
  ],
  "warnings": [
    {
      "code": "balance_below_step"
    }
  ]
}
```

### 400

Invalid request

application/json

object

* **error**

  required

  object

  * **code**

    required

    string

    Allowed values: unauthorized forbidden not_found bad_request conflict insufficient_credits budget_below_minimum repository_initializing diff_base_required diff_base_not_allowed diff_base_invalid diff_empty rate_limited internal

  * **message**

    required

    string

  * **minimumCredits**

    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.

    integer

##### Example

```json
{
  "error": {
    "code": "unauthorized"
  }
}
```

### 401

Missing, malformed, expired, or revoked token

application/json

object

* **error**

  required

  object

  * **code**

    required

    string

    Allowed values: unauthorized forbidden not_found bad_request conflict insufficient_credits budget_below_minimum repository_initializing diff_base_required diff_base_not_allowed diff_base_invalid diff_empty rate_limited internal

  * **message**

    required

    string

  * **minimumCredits**

    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.

    integer

##### Example

```json
{
  "error": {
    "code": "unauthorized"
  }
}
```

### 403

The token lacks the required scope

application/json

object

* **error**

  required

  object

  * **code**

    required

    string

    Allowed values: unauthorized forbidden not_found bad_request conflict insufficient_credits budget_below_minimum repository_initializing diff_base_required diff_base_not_allowed diff_base_invalid diff_empty rate_limited internal

  * **message**

    required

    string

  * **minimumCredits**

    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.

    integer

##### Example

```json
{
  "error": {
    "code": "unauthorized"
  }
}
```

### 404

Resource not in this token’s project or repo allowlist

application/json

object

* **error**

  required

  object

  * **code**

    required

    string

    Allowed values: unauthorized forbidden not_found bad_request conflict insufficient_credits budget_below_minimum repository_initializing diff_base_required diff_base_not_allowed diff_base_invalid diff_empty rate_limited internal

  * **message**

    required

    string

  * **minimumCredits**

    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.

    integer

##### Example

```json
{
  "error": {
    "code": "unauthorized"
  }
}
```

### 409

A compare-and-set (`expectedContent`) missed: the guidance changed since it was read. Re-read the current guidance and retry.

application/json

object

* **error**

  required

  object

  * **code**

    required

    string

    Allowed values: unauthorized forbidden not_found bad_request conflict insufficient_credits budget_below_minimum repository_initializing diff_base_required diff_base_not_allowed diff_base_invalid diff_empty rate_limited internal

  * **message**

    required

    string

  * **minimumCredits**

    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.

    integer

##### Example

```json
{
  "error": {
    "code": "unauthorized"
  }
}
```
