Orgs
The 15 operations under orgs, as typed calls on the generated REST client.
Orgs
Available from @codespar/sdk 0.12.0, which is not on npm yet. The published version today is 0.11.0, and it has no cs.api; 0.12.0 is on the main branch of codespar-core. The examples below are not compiled against the installed package for that reason.
Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.
import { CodeSpar } from "@codespar/sdk";
const cs = new CodeSpar({ apiKey: process.env.CODESPAR_API_KEY });POST /v1/orgs/{orgId}/agents
/v1/orgs/{orgId}/agentsRegister an agent identity and mint its first signing key
const r = await cs.api.response("post", "/v1/orgs/{orgId}/agents", {
path: {
orgId: "org_0000000000000000"
},
body: {
agent_id: "agt_0000000000000000",
display_name: "Example",
principal_ref: "string"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/orgs/{orgId}/agents in the HTTP reference.
POST /v1/orgs/{orgId}/agents/{agentId}/keys/rotate
/v1/orgs/{orgId}/agents/{agentId}/keys/rotateRetire the agent's active key and mint a fresh one
const r = await cs.api.response("post", "/v1/orgs/{orgId}/agents/{agentId}/keys/rotate", {
path: {
orgId: "org_0000000000000000",
agentId: "agt_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/orgs/{orgId}/agents/{agentId}/keys/rotate in the HTTP reference.
POST /v1/orgs/{orgId}/agents/{agentId}/keys/{kid}/revoke
/v1/orgs/{orgId}/agents/{agentId}/keys/{kid}/revokeHard-revoke one of an agent's signing keys
const r = await cs.api.response("post", "/v1/orgs/{orgId}/agents/{agentId}/keys/{kid}/revoke", {
path: {
orgId: "org_0000000000000000",
agentId: "agt_0000000000000000",
kid: "string"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/orgs/{orgId}/agents/{agentId}/keys/{kid}/revoke in the HTTP reference.
GET /v1/orgs/{orgId}/approvals/health
/v1/orgs/{orgId}/approvals/healthQueue depth and the age of the oldest pending approval
const result = await cs.api.get("/v1/orgs/{orgId}/approvals/health", {
path: {
orgId: "org_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/orgs/{orgId}/approvals/health in the HTTP reference.
GET /v1/orgs/{orgId}/approvals/{id}
/v1/orgs/{orgId}/approvals/{id}Read one approval, including the tool arguments held for review
const result = await cs.api.get("/v1/orgs/{orgId}/approvals/{id}", {
path: {
orgId: "org_0000000000000000",
id: "approval_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/orgs/{orgId}/approvals/{id} in the HTTP reference.
GET /v1/orgs/{orgId}/audit/config
/v1/orgs/{orgId}/audit/configRead the chain verification windows and staleness budgets
const r = await cs.api.response("get", "/v1/orgs/{orgId}/audit/config", {
path: {
orgId: "org_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: GET /v1/orgs/{orgId}/audit/config in the HTTP reference.
PATCH /v1/orgs/{orgId}/audit/config
/v1/orgs/{orgId}/audit/configUpdate the chain verification windows and staleness budgets
const r = await cs.api.response("patch", "/v1/orgs/{orgId}/audit/config", {
path: {
orgId: "org_0000000000000000"
},
body: {
verification_window_days: 0,
hot_window_days: 0,
hot_max_staleness_seconds: 1,
warm_window_days: 0,
warm_max_staleness_seconds: 1,
cold_max_staleness_seconds: 1
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: PATCH /v1/orgs/{orgId}/audit/config in the HTTP reference.
GET /v1/orgs/{orgId}/audit/health
/v1/orgs/{orgId}/audit/healthHow far the chain verifier got, and whether what it walked was linked
const r = await cs.api.response("get", "/v1/orgs/{orgId}/audit/health", {
path: {
orgId: "org_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: GET /v1/orgs/{orgId}/audit/health in the HTTP reference.
GET /v1/orgs/{orgId}/audit/incidents
/v1/orgs/{orgId}/audit/incidentsList chain-integrity incidents
const r = await cs.api.response("get", "/v1/orgs/{orgId}/audit/incidents", {
path: {
orgId: "org_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: GET /v1/orgs/{orgId}/audit/incidents in the HTTP reference.
POST /v1/orgs/{orgId}/audit/incidents/{id}/acknowledge
/v1/orgs/{orgId}/audit/incidents/{id}/acknowledgeAcknowledge a chain-integrity incident and write the acknowledgement into the chain
const r = await cs.api.response("post", "/v1/orgs/{orgId}/audit/incidents/{id}/acknowledge", {
path: {
orgId: "org_0000000000000000",
id: "incident_0000000000000000"
},
body: {
resolution_summary: "string",
anpd_notification_status: "not_required",
personal_data_affected: true
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/orgs/{orgId}/audit/incidents/{id}/acknowledge in the HTTP reference.
POST /v1/orgs/{orgId}/data-subjects/{userId}/anonymize
/v1/orgs/{orgId}/data-subjects/{userId}/anonymizeErase a data subject's personal data across the audit chain (LGPD Art. 18)
const r = await cs.api.response("post", "/v1/orgs/{orgId}/data-subjects/{userId}/anonymize", {
path: {
orgId: "org_0000000000000000",
userId: "user_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/orgs/{orgId}/data-subjects/{userId}/anonymize in the HTTP reference.
GET /v1/orgs/{orgId}/mandates
/v1/orgs/{orgId}/mandatesList the org's mandates
const result = await cs.api.get("/v1/orgs/{orgId}/mandates", {
path: {
orgId: "org_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/orgs/{orgId}/mandates in the HTTP reference.
POST /v1/orgs/{orgId}/mandates
/v1/orgs/{orgId}/mandatesIssue an org-side mandate (off by default, see the 501)
const r = await cs.api.response("post", "/v1/orgs/{orgId}/mandates", {
path: {
orgId: "org_0000000000000000"
},
body: {
agent_id: "agt_0000000000000000",
type: "payment",
amount: "1000",
currency: "BRL",
purposes: [
"string"
],
expires_at: 0
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/orgs/{orgId}/mandates in the HTTP reference.
GET /v1/orgs/{orgId}/mandates/{id}
/v1/orgs/{orgId}/mandates/{id}Read one mandate with its consumption history
const result = await cs.api.get("/v1/orgs/{orgId}/mandates/{id}", {
path: {
orgId: "org_0000000000000000",
id: "mandate_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/orgs/{orgId}/mandates/{id} in the HTTP reference.
POST /v1/orgs/{orgId}/mandates/{id}/revoke
/v1/orgs/{orgId}/mandates/{id}/revokeRevoke a mandate
const result = await cs.api.post("/v1/orgs/{orgId}/mandates/{id}/revoke", {
path: {
orgId: "org_0000000000000000",
id: "mandate_0000000000000000"
},
body: {
reason: "string"
}
});Parameters, body and every documented response: POST /v1/orgs/{orgId}/mandates/{id}/revoke in the HTTP reference.