The AI invoice API quickstart for agent developers.
A four-section walkthrough of Arcflow's public REST surface for external AI agents: per-account API key issuance, multipart invoice ingest, the approval state machine, and a programmatic review queue.
Quickstart: this app has no GraphQL endpoint or runtime schema. The invoice examples below are illustrative; use the REST endpoint and authentication steps shown here.
Illustrative, non-executable shape for a hypothetical submitInvoice mutation. It shows vendor, amount, due date, and line items, with an invoice identifier in the example response.
Arcflow requires a valid, non-revoked Bearer API key for the invoice intake, approve, and reject POST routes. The server resolves each key to its account. Keys are minted by the operator running Arcflow and tied to one account.
Issuance (operator side, one-time)
API keys are issued by running the seed script against the Arcflow database. Each run prints the raw key exactly once — after the script exits, the key is unrecoverable. The server stores only the SHA-256 hash in agent_api_keys.key_hash.
# Mint a new key (account name + key label are optional)
node scripts/seed-agent-key.js --name <name> --label <label>
# stdout:account_id=42api_key=a3f9… (64 hex chars)
Save the api_key now — it cannot be retrieved later.
Copy the api_key value into your secret manager immediately. The account_id is informational; on each protected POST request, the server resolves the account from the Bearer key.
Header usage (protected POST routes)
Send a valid, non-revoked Bearer key on POST /v1/invoices, POST /v1/invoices/:id/approve, and POST /v1/invoices/:id/reject; the server resolves its account on each request. The GET /v1/invoices listing currently does not check authentication, and its results are not restricted to the account associated with any API key.
# Authorization header for protected POST routesAuthorization: Bearer <ARCFLOW_KEY>
Key rotation. To rotate, run node scripts/seed-agent-key.js again to mint a fresh key, then revoke the old row in agent_api_keys by setting revoked_at. The lookup query already filters revoked_at IS NULL so old keys stop working the moment you revoke them.
Creation also sets approval_status="pending_review", which is not a response field.
Errors
These explicit endpoint errors return a JSON object with an error field:
HTTP 401
{"error":"Missing or invalid Authorization header"}
HTTP 401
{"error":"Invalid API key"}
HTTP 400
{"error":"No file provided. Send as multipart/form-data with field name \"file\"."}
HTTP 502
{"error":"Failed to upload file to storage","upstream":"<upstream status and response body>"}
HTTP 500
{"error":"Failed to ingest invoice"}
The upstream value varies with the storage response and contains its status and body, truncated to 500 characters. The 500 response is used for both API-key lookup failures and other invoice-ingestion failures.
Account ownership. Submission records the account resolved from the Bearer key on the invoice's invoice_received event; that account owns the invoice.
Once an invoice is on the queue, an agent (or a human reviewer working through one) decides approved or rejected. The transitions are single-shot — you can't bounce between states.
4 mutations shown
From
Action
To
pending_review
POST /v1/invoices/<id>/approve
approved
pending_review
POST /v1/invoices/<id>/reject
rejected
approved
(later) Stripe payment flow
paid
The pending side of the queue surfaces both pending_review and pending_approval when you list with ?status=pending_review — treat them all as "still waiting for a human decision."
Approve
POST/v1/invoices/<id>/approve
Requires a valid, non-revoked Bearer key for the account that owns this invoice. A valid key for another account is denied with HTTP 403. The approver recorded is the account name attached to your Bearer key.
Requires a valid, non-revoked Bearer key for the account that owns this invoice. A valid key for another account is denied with HTTP 403. The body is a JSON object with an optional reason string (max 1,000 chars), recorded on the rejection event for downstream auditors.
# Reject invoice 42 as a duplicate of an earlier submission
curl -X POST https://arcflow.com/v1/invoices/42/reject \
-H "Authorization: Bearer $ARCFLOW_KEY" \
-H "Content-Type: application/json" \
-d '{"reason":"duplicate of invoice 38"}'
Edge case. Reject returns 409 if the invoice's underlying status is already paid — you can't reject something the ledger has already cleared. The response is {"error":"cannot reject a paid invoice"}. Approve is unaffected: it succeeds on any non-final state.
04 —
Review queue
The invoice listing is an unauthenticated GET. Approve and reject actions are protected POST requests and require the Bearer key described in API keys.
This handler does not check authentication or scope results by API key. Results are not restricted to any account, including the account associated with an API key, so no authentication or request headers are required. It returns the 50 most recent invoices, newest first.
# Pull the latest 50 invoices
curl -s https://arcflow.com/v1/invoices
ID of the invoice this record is marked as a duplicate of
created_at
timestamp when the invoice row was created
approval_status
invoice review status
approver
name recorded as the approver
approved_at
timestamp recorded for the approval workflow transition
notes
notes stored on the invoice
workflow_stage
workflow stage stored on the invoice
payment_link_url
payment link URL stored on the invoice
payment_initiated_at
timestamp stored when payment was initiated
payment_status
invoice payment status
paid_at
timestamp when the invoice was marked paid
vendor_name
joined vendor name, or null when no vendor is linked
Errors
If listing fails, the endpoint returns:
HTTP 500
{"error":"Failed to list invoices"}
Filter by review state
Add ?status= with one of these four supported values to filter invoices:
pending_review matches invoices whose approval_status is pending_review or pending_approval.
approved matches invoices with approval_status=approved, excluding invoices with status=paid.
rejected matches invoices with approval_status=rejected.
paid matches invoices with status=paid.
Filtered results are ordered newest first and limited to 50. If status is omitted or has an unsupported value, the endpoint uses the unfiltered latest-50 listing instead of returning an error or an empty filtered result.
# What still needs a decision?
curl -s "https://arcflow.com/v1/invoices?status=pending_review"# Which invoices are approved but not paid?
curl -s "https://arcflow.com/v1/invoices?status=approved"# Which invoices were rejected?
curl -s "https://arcflow.com/v1/invoices?status=rejected"# Which invoices are marked paid?
curl -s "https://arcflow.com/v1/invoices?status=paid"