Skip to content
These docs describe staging.zkao.io and the @zksecurity/zkao-cli@next release. For production, see docs.zkao.io.

Set or clear a repository's guidance

View .md
PUT
/projects/{projectId}/repositories/{repositoryId}/guidance
curl --request PUT \
--url https://zkao.io/api/v1/projects/example/repositories/example/guidance \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "content": "example", "expectedContent": "example" }'

Requires scope: guidance:write. Sets content as the repository’s guidance (or clears it with null), recording a revision. Writing the same content that is already stored is a no-op (unchanged: true, no revision). Pass expectedContent for an optimistic compare-and-set: omit it for last-writer-wins, or send the content you last read (or null for “currently cleared”) to get a 409 instead of clobbering a concurrent change. The response’s diff shows what the write replaced.

projectId
required
string
repositoryId
required
string
Media typeapplication/json
object
content
required

New guidance content; null clears it.

string | null
<= 100000 characters
expectedContent

Optional compare-and-set. Omit for last-writer-wins. Send the content you last read (or null for “currently cleared”) to receive a 409 if the guidance changed underneath you instead of overwriting it.

string | null
Examplegenerated
{
"content": "example",
"expectedContent": "example"
}

OK

Media typeapplication/json
object
repositoryId
required
string
revisionId
required

The recorded revision id, or null on a no-op write.

string | null
unchanged
required

True when the content already matched (no revision recorded).

boolean
diff
required

Unified diff from the guidance this write replaced to the new content, with before and after as file names. Empty on a no-op write. Read it to confirm the write changed only what you meant to.

string
Examplegenerated
{
"repositoryId": "example",
"revisionId": "example",
"unchanged": true,
"diff": "example"
}

Invalid request

Media typeapplication/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
{
"error": {
"code": "unauthorized"
}
}

Missing, malformed, expired, or revoked token

Media typeapplication/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
{
"error": {
"code": "unauthorized"
}
}

The token lacks the required scope

Media typeapplication/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
{
"error": {
"code": "unauthorized"
}
}

Resource not in this token’s project or repo allowlist

Media typeapplication/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
{
"error": {
"code": "unauthorized"
}
}

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

Media typeapplication/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
{
"error": {
"code": "unauthorized"
}
}