Skip to main content
API reference

Policies

Generated HTTP reference for the 6 operations the published OpenAPI document describes under policies.

4 min read
View MarkdownEdit on GitHub

Policies

This page is generated from the published OpenAPI document. It is complete with respect to that document and says nothing about surfaces the document does not describe yet. See what is generated here for what that means.

Base URL: https://api.codespar.dev

Every operation below requires a Bearer token. See Authentication.

GET /v1/policies

List policy rules for the authenticated org, sorted by order ASC.

Responses

StatusBodyDescription
200array of PolicyOK

Example response

[
  {
    "id": "pol_0000000000000000",
    "name": "Example",
    "type": "allow",
    "config": {},
    "agents": [
      "string"
    ],
    "tools": [
      "string"
    ],
    "enabled": true,
    "order": 1,
    "createdAt": "2026-01-15T12:00:00.000Z",
    "updatedAt": "2026-01-15T12:00:00.000Z"
  }
]

Example request

curl -X GET https://api.codespar.dev/v1/policies \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

POST /v1/policies

Create a new policy rule.

Request bodyPolicyCreate

FieldTypeRequiredDescription
agentsarray of stringno
configno
enabledbooleanno
namestringyes
toolsarray of stringno
type"allow" | "deny" | "budget" | "rate-limit" | "time-window" | "approval-required"yes

Responses

StatusBodyDescription
201PolicyOK

Response 201

FieldTypeRequiredDescription
agentsarray of stringyes
configobjectyes
createdAtstring (date-time)yes
enabledbooleanyes
idstringyes
namestringyes
ordernumberyes
toolsarray of stringyes
type"allow" | "deny" | "budget" | "rate-limit" | "time-window" | "approval-required"yes
updatedAtstring (date-time)yes

Example response

{
  "id": "pol_0000000000000000",
  "name": "Example",
  "type": "allow",
  "config": {},
  "agents": [
    "string"
  ],
  "tools": [
    "string"
  ],
  "enabled": true,
  "order": 1,
  "createdAt": "2026-01-15T12:00:00.000Z",
  "updatedAt": "2026-01-15T12:00:00.000Z"
}

Example request

curl -X POST https://api.codespar.dev/v1/policies \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "name": "Example",
       "type": "allow",
       "agents": [],
       "tools": [],
       "enabled": true
     }'

POST /v1/policies/reorder

Reorder policy rules. Atomic: if any id does not belong to the org, the entire operation rolls back and returns 404.

Request bodyPolicyReorder

FieldTypeRequiredDescription
idsarray of stringyes

Responses

StatusBodyDescription
204No Content
404objectNot Found

Example request

curl -X POST https://api.codespar.dev/v1/policies/reorder \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "ids": [
         "string"
       ]
     }'

GET /v1/policies/{id}

Read one policy rule

Responses

StatusBodyDescription
200PolicyOK
404objectNot Found

Response 200

FieldTypeRequiredDescription
agentsarray of stringyes
configobjectyes
createdAtstring (date-time)yes
enabledbooleanyes
idstringyes
namestringyes
ordernumberyes
toolsarray of stringyes
type"allow" | "deny" | "budget" | "rate-limit" | "time-window" | "approval-required"yes
updatedAtstring (date-time)yes

Example response

{
  "id": "pol_0000000000000000",
  "name": "Example",
  "type": "allow",
  "config": {},
  "agents": [
    "string"
  ],
  "tools": [
    "string"
  ],
  "enabled": true,
  "order": 1,
  "createdAt": "2026-01-15T12:00:00.000Z",
  "updatedAt": "2026-01-15T12:00:00.000Z"
}

Example request

curl -X GET https://api.codespar.dev/v1/policies/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

PATCH /v1/policies/{id}

Update a policy rule. Cross-org ids return 404. Invalidates the per-org cache on success.

Path parameters

NameTypeRequiredDescription
idstringyes

Request bodyPolicyUpdate

FieldTypeRequiredDescription
agentsarray of stringno
configno
enabledbooleanno
namestringno
toolsarray of stringno
type"allow" | "deny" | "budget" | "rate-limit" | "time-window" | "approval-required"no

Responses

StatusBodyDescription
200PolicyOK
404objectNot Found

Response 200

FieldTypeRequiredDescription
agentsarray of stringyes
configobjectyes
createdAtstring (date-time)yes
enabledbooleanyes
idstringyes
namestringyes
ordernumberyes
toolsarray of stringyes
type"allow" | "deny" | "budget" | "rate-limit" | "time-window" | "approval-required"yes
updatedAtstring (date-time)yes

Example response

{
  "id": "pol_0000000000000000",
  "name": "Example",
  "type": "allow",
  "config": {},
  "agents": [
    "string"
  ],
  "tools": [
    "string"
  ],
  "enabled": true,
  "order": 1,
  "createdAt": "2026-01-15T12:00:00.000Z",
  "updatedAt": "2026-01-15T12:00:00.000Z"
}

Example request

curl -X PATCH https://api.codespar.dev/v1/policies/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "name": "Example",
       "type": "allow",
       "agents": [
         "string"
       ],
       "tools": [
         "string"
       ],
       "enabled": true
     }'

DELETE /v1/policies/{id}

Delete a policy rule. Cross-org ids return 404. Invalidates the per-org cache on success.

Path parameters

NameTypeRequiredDescription
idstringyes

Responses

StatusBodyDescription
204No Content
404objectNot Found

Example request

curl -X DELETE https://api.codespar.dev/v1/policies/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
Policies | CodeSpar