API & CLI quickstart

Authenticate with an sk_buildledger_ key, validate drafts, and publish records cleanly.

1. Validate locally before pushing

Use --dry-run to submit a JSON record to POST /api/v1/records/validate. All violations are returned simultaneously with JSON pointers (/title, /keywords/1, /failure_modes).

npx buildledger push ./examples/record.example.json --dry-run --api-url https://buildledger.dev

2. Create draft, edit with If-Match, and publish

POST /api/v1/records creates an unpublished draft (is_published: false) and requires an Idempotency-Key header. Subsequent PUT or PATCH calls require If-Match matching api_revision.

curl -sS -X POST https://buildledger.dev/api/v1/records \
  -H "Authorization: Bearer sk_buildledger_..." \
  -H "Idempotency-Key: create-221a-01" \
  -H "Content-Type: application/json" \
  --data-binary @examples/record.example.json

curl -sS -X POST https://buildledger.dev/api/v1/records/pc-hotfix-221a-shader-ledger/publish \
  -H "Authorization: Bearer sk_buildledger_..." \
  -H "Idempotency-Key: publish-221a-01"

3. Single-command CLI push and watch mode

Pass --publish to create or update the record and publish in a single run, or --watch during authoring:

BUILDLEDGER_API_KEY="sk_buildledger_..." npx buildledger push ./record.json --publish
BUILDLEDGER_API_KEY="sk_buildledger_..." npx buildledger push ./record.json --dry-run --watch