Skip to main content
Version: 0.1.0

API Reference

Programmatic: decide(signals, context)​

import { decide } from "basecred-decision-engine";
import type { NormalizedSignals } from "basecred-decision-engine/types";

const decision = decide(signals, "allowlist.general");

Response Example​

{
"decision": "ALLOW",
"confidence": "HIGH",
"constraints": [],
"retryAfter": null,
"ruleIds": ["allow_strong_builder"],
"version": "v1",
"explain": ["Strong builder credibility with sufficient social trust"],
"subjectHash": "subj_48c9a1"
}

HTTP: GET /v1/contexts​

Returns a list of all available decision contexts.

Response​

{
"contexts": [
"allowlist.general",
"comment",
"publish",
"apply",
"governance.vote"
]
}

HTTP: POST /v1/decide​

The authoritative, billable surface of BaseCred.

Request​

{
"subject": "0xabc...",
"context": "allowlist.general"
}

Response​

{
"decision": "ALLOW",
"confidence": "HIGH",
"constraints": [],
"retryAfter": null,
"ruleIds": ["allow_strong_builder"],
"version": "v1",
"explain": ["Strong builder credibility with sufficient social trust"],
"subjectHash": "subj_48c9a1",
"policyHash": "sha256:<policy-hash>"
}
FieldDescription
decisionALLOW, DENY, or ALLOW_WITH_LIMITS
confidenceLOW, MEDIUM, HIGH, or VERY_HIGH
ruleIdsArray of rule IDs that triggered the decision
explainHuman-readable array of reasons
constraintsApplied when decision is ALLOW_WITH_LIMITS

Response Headers​

HeaderDescription
x-policy-hashPolicy hash used for the decision context

Status Codes​

CodeMeaning
200Decision made successfully
400Invalid request (missing subject/context)
500Internal server error

AI Integration Policy​

AI must never:

  • Decide ALLOW / DENY
  • Override deterministic rules
  • Act as source of truth

AI may:

  • Generate explanations
  • Suggest rule tuning
  • Detect anomalies
  • Simulate what-if scenarios

Rule: Rules decide. AI explains.