Skip to main content
API reference

Agents

Generated HTTP reference for the 4 operations the published OpenAPI document describes under agents.

3 min read
View MarkdownEdit on GitHub

Agents

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.

POST /v1/agents

Register an agent identity and mint its first signing key

Request body

FieldTypeRequiredDescription
agent_idstringyes
display_namestringno
principal_refstringyes

Responses

StatusBodyDescription
201objectOK
400objectBad Request — schema failure, or a DID segment outside the URL-safe alphabet.
409objectConflict — the handle or the derived DID is taken.

Response 201

FieldTypeRequiredDescription
agent_didstringyes
kidstringyes\<did\>#\<n\>, where n is the key's ordinal.
pubkeystringyesbase64.
status"active"yes

Example response

{
  "agent_did": "did:web:codespar.dev:org:agent",
  "kid": "string",
  "pubkey": "string",
  "status": "active"
}

Example request

curl -X POST https://api.codespar.dev/v1/agents \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "agent_id": "agt_0000000000000000",
       "display_name": "Example",
       "principal_ref": "string"
     }'

POST /v1/agents/{agentId}/keys/rotate

Mint a new signing key and retire the current one

Path parameters

NameTypeRequiredDescription
agentIdstringyes

Responses

StatusBodyDescription
201objectOK
404objectNot Found — no such agent in this org.
409objectConflict — the agent has no active key to rotate.

Response 201

FieldTypeRequiredDescription
agent_didstringyes
kidstringyes
pubkeystringyesbase64.
retired_kidstringyes
status"active"yes

Example response

{
  "agent_did": "did:web:codespar.dev:org:agent",
  "kid": "string",
  "pubkey": "string",
  "retired_kid": "string",
  "status": "active"
}

Example request

curl -X POST https://api.codespar.dev/v1/agents/{agentId}/keys/rotate \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

POST /v1/agents/{agentId}/keys/{kid}/revoke

Revoke one signing key

Path parameters

NameTypeRequiredDescription
agentIdstringyes
kidstringyesA full kid; the # must be sent as %23.

Responses

StatusBodyDescription
200objectOK
404objectNot Found — no such key on this org's agent.
409objectConflict — the key is already revoked.

Response 200

FieldTypeRequiredDescription
kidstringyes
revoked_atstringyes
status"revoked"yes

Example response

{
  "kid": "string",
  "status": "revoked",
  "revoked_at": "string"
}

Example request

curl -X POST https://api.codespar.dev/v1/agents/{agentId}/keys/{kid}/revoke \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

POST /v1/agents/{did}/revoke

Revoke an agent identity

Path parameters

NameTypeRequiredDescription
didstringyes

Responses

StatusBodyDescription
200objectOK
404objectNot Found
409objectConflict — the agent is already revoked.

Response 200

FieldTypeRequiredDescription
didstringyes
limitsobjectyesWhat this verb reaches and what it does not. Served with every 200 so the limit travels with the act.
revoked_atstringyes
revoked_kidsarray of stringyesThe signing keys the cascade revoked, in creation order.
status"revoked"yes

Example response

{
  "did": "did:web:codespar.dev:org:agent",
  "status": "revoked",
  "revoked_at": "string",
  "revoked_kids": [
    "string"
  ],
  "limits": {
    "stops": [
      "string"
    ],
    "does_not_stop": "string",
    "issue": "string"
  }
}

Example request

curl -X POST https://api.codespar.dev/v1/agents/{did}/revoke \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
Agents | CodeSpar