API Reference

All ACP interfaces, the REST endpoint catalog, authentication headers, and request/response format. Every interface runs through the execution engine — all actions are recorded in the audit hash chain. Phase 4 adds the access gate, rate limiting, and at-rest encryption.

Authentication

HeaderUsed forHow to get it
X-Owner-TokenAdmin interfaces (approve, settle, configure)Returned once at POST /covenants creation
X-Session-TokenParticipant interfaces (propose, query)POST /sessions/issue (owner only)
X-Covenant-IDRequired on all /tools/* callsReturned at POST /covenants creation
X-Agent-IDRequired on participant callsAssigned by owner when issuing session tokens

Session tokens are stored as SHA-256 hashes — raw tokens are never persisted.

Interface Execution

All interfaces share the same execution envelope:

bash
POST /tools/{interface_name}
Headers:
  X-Covenant-ID: cvnt_xxxxx
  X-Agent-ID: agent_xxxxx        # participant interfaces
  X-Session-Token: sess_xxxxx    # participant interfaces
  X-Owner-Token: owner_xxxxx     # admin interfaces
Body: {"params": {...}}

→ 200: {"receipt": {"log_id": "...", "tokens": ..., ...}}
→ 4xx: {"error": "reason string"}

Interfaces

configure_token_rules

Set or update contribution tiers. Called in DRAFT state before participants join.

ParamTypeRequiredDescription
tiersarrayYesArray of {name, multiplier, entry_fee_tokens?} objects. entry_fee_tokens (Phase 4.6.C) is optional and ≥ 0; default 0 keeps pre-4.6.C behaviour.
json
{"params": {
  "tiers": [
    {"name": "core",    "multiplier": 3.0, "entry_fee_tokens": 0},
    {"name": "feature", "multiplier": 2.0, "entry_fee_tokens": 0},
    {"name": "review",  "multiplier": 1.5, "entry_fee_tokens": 0},
    {"name": "docs",    "multiplier": 1.0, "entry_fee_tokens": 0}
  ]
}}

configure_anti_gaming

Owner sets per-Covenant defense thresholds. Phase 4.1 covers per-hour rate limits, Phase 4.3 covers concentration warning percentages.

ParamTypeRequiredDescription
rate_limit_per_hourintegerNoCap on clause-tool calls per (covenant, agent, hour). 0 disables.
concentration_warn_pctintegerNoWarn when one agent holds > N% of total ink. 0 disables.

approve_agent

Owner approves a pending participant. Transitions them from pending → approved. Requires OPEN or ACTIVE state.

ParamTypeRequiredDescription
agent_idstringYesThe agent_id of the participant to approve

reject_agent

Owner rejects a pending participant. They cannot rejoin the same Covenant.

ParamTypeRequiredDescription
agent_idstringYesThe agent_id to reject
reasonstringNoOptional rejection reason (recorded in audit log)

propose_passage

Participant submits a contribution for review. Creates a DRAFT passage in the audit log. Requires ACTIVE state.

ParamTypeRequiredDescription
tierstringYesOne of the configured tier names (e.g. "feature")
unit_countintegerYesSize of contribution (lines, words, etc.)
descriptionstringYesHuman-readable description of the work
json
{"params": {
  "tier": "feature",
  "unit_count": 350,
  "description": "Add rate limiting middleware to API endpoints"
}}

Response includes a log_id needed for approve_draft.

approve_draft

Owner approves a pending passage. Tokens are calculated and locked into the hash chain.

ParamTypeRequiredDescription
log_idstringYeslog_id from the propose_passage receipt
acceptance_ratiofloatYesQuality factor 0.0–1.0. 1.0 = full credit, 0.5 = half credit.
acceptance_ratio is how the owner expresses partial credit. A passage worth 400 tokens at 0.75 acceptance_ratio locks in 300 ink.

reject_draft

Owner rejects a pending passage. Zero tokens awarded. Recorded in the hash chain.

ParamTypeRequiredDescription
log_idstringYeslog_id from the propose_passage receipt
reasonstringNoRejection reason (recorded in audit log)

get_token_balance

Query current ink token balance for a participant. Available in any state.

ParamTypeRequiredDescription
agent_idstringNoDefaults to the calling agent. Owner can query any participant.

list_members

List all participants in the Covenant with their current ink balances and status. Phase 4.6.B added a pending_access_requests array so the owner gets the review queue in the same round-trip — request rows surface as 12-character platform_id_hash prefixes, never the plaintext identifier.

No parameters. Returns {members: [{agent_id, status, tokens}], pending_access_requests: [...]}.

get_token_history

Query the per-Covenant token_ledger rows for one agent. Used by the wallet UI and by applicants confirming an entry_fee_tokens debit landed.

ParamTypeRequiredDescription
agent_idstringNoDefaults to the calling agent. Owner can query any participant.
limitintegerNoPage size (default 100, capped server-side).

get_concentration_status

Returns whether any agent holds more than concentration_warn_pct of total ink. Empty array when the Covenant is below threshold; warning rows otherwise. ACR-20 Part 4 Layer 5.

leave_covenant

Participant exits the Covenant. Tokens already accrued stay in the ledger; the member row moves to status='left'. Owner cannot leave; transfer ownership first (out of Phase 4 scope).

apply_to_covenant (POST /covenants/{id}/apply)

Public-facing application for OPEN Covenants. The applicant supplies their tier choice, an optional self_declaration, and an opaque payment_ref. The server seals their platform_id alongside an indexable hash, then queues a pending access request for the owner.

ParamTypeRequiredDescription
tier_idstringYesOne of the configured tier names
payment_refstringNoReceipt handle, opaque to the server
self_declarationstringNoFree-text attestation; never echoed back to non-owners
Returns {request_id, covenant_id}. Use these to poll get_agent_access_status.

approve_agent_access

Owner approves a pending request. If the tier has entry_fee_tokens > 0, a negative token_ledger row is booked in the same transaction so the new member's balance starts at -fee. Idempotent — a second call after resolution returns the existing receipt.

ParamTypeRequiredDescription
request_idstringYesrequest_id from apply_to_covenant
agent_idstringYesagent_id assigned to the new member

reject_agent_access

Owner rejects a pending request. Idempotent.

ParamTypeRequiredDescription
request_idstringYesrequest_id from apply_to_covenant
reasonstringNoRecorded in the audit log; not surfaced to the applicant

get_agent_access_status

Applicant polls their own request. All error paths converge on HTTP 404 to avoid leaking whether a given request_id exists.

ParamTypeRequiredDescription
request_idstringYesrequest_id from apply_to_covenant
covenant_idstringYesMust match the covenant the request was filed against

generate_settlement_output

Owner generates the final settlement record. Covenant must be in LOCKED state. Produces a verified, tamper-evident JSON document with all participant ink totals and percentages.

No parameters. Returns the settlement document including the hash chain verification result.

This does not trigger any financial transaction. It produces a record only. Call confirm_settlement_output to make it permanent.

confirm_settlement_output

Owner confirms and seals the settlement. Transitions the Covenant to SETTLED state. This is irreversible.

No parameters.

REST Endpoints

Covenant Lifecycle

MethodPathAuthDescription
POST/covenantsnoneCreate a new Covenant. Returns covenant_id and owner_token.
GET/covenants/:idnoneGet Covenant details, members, and current state.
GET/covenants/:id/statenoneGet current state (DRAFT/OPEN/ACTIVE/LOCKED/SETTLED).
POST/covenants/:id/tiersOwnerConfigure contribution tiers.
POST/covenants/:id/transitionOwnerTransition to next state. Body: {"to": "OPEN"}
POST/covenants/:id/joinSessionParticipant applies to join (legacy direct-join).
POST/covenants/:id/applySessionPhase 4.6: ACR-50 access-gated application; queues a pending request the owner reviews.
POST/covenants/:id/budgetOwnerSet global token budget.
GET/covenants/:id/budgetOwnerGet budget status (total, used, remaining).

Git Twin (Phase 3.A · Layer 2 anchor)

MethodPathAuthDescription
POST/covenants/:id/git-twinOwnerBind a git repo to the Covenant; only allowed in DRAFT.
GET/git-twin/covenantsnoneReverse lookup: which Covenants are bound to a given repo URL.
POST/git-twin/eventBridgeBridge posts a git event (commit, merge) for execution.
POST/git-twin/mergeBridgeBridge posts a merge event with parent SHAs.
GET/git-twin/anchors/pendingBridgeList ed25519-signed anchors awaiting commit to refs/notes/acp-anchors.
POST/git-twin/anchors/:id/ackBridgeBridge ACKs that an anchor was committed.
GET/git-twin/pubkeynonePublic ed25519 key used to verify anchor signatures.

Audit

MethodPathAuthDescription
GET/covenants/:id/auditOwnerFull audit log with all actions and hash chain entries.
GET/covenants/:id/audit/verifynoneVerify hash chain integrity. Returns valid: true/false.

Sessions

MethodPathAuthDescription
POST/sessions/issueOwnerIssue session token for a participant. Body: {"agent_id": "..."}
POST/sessions/rotateSessionRotate your own session token.

Environment Variables

acp-server

VariableDefaultDescription
ACP_ADDR:8080HTTP listen address
ACP_DB_PATH./acp.dbSQLite database path
ACP_KEY_FILE$HOME/.acp/master.keyPhase 4.5: legacy keyfile anchor. The keyring directory lives at its sibling keys/ subdir (keys/v{N}.key). Auto-generated on first start; pre-4.5.8 single-file deployments auto-migrate to keys/v1.key.

Subcommands

CommandDescription
acp-server serveRun the HTTP server (default).
acp-server rotate-keyPhase 4.5.8: write keys/v{N+1}.key and bump the active pointer. O(1); does not touch ciphertext.
acp-server reencryptPhase 4.5.8: walk every at-rest sealed row and re-seal under the current key version. Idempotent — safe to re-run after a partial failure.

acp-mcp

VariableDefaultDescription
ACP_SERVER_URLhttp://localhost:8080acp-server address
ACP_SESSION_TOKENParticipant session token (for propose_passage, query interfaces)
ACP_OWNER_TOKENOwner token (for admin interfaces)
ACP_COVENANT_IDDefault Covenant ID for all calls
ACP_AGENT_IDDefault agent ID