AI invoice API · v1

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.

On this page
00 —

GraphQL reference

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.

Submit invoice #

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.

Variables

# GraphQL mutation
mutation SubmitInvoice {
  submitInvoice(vendor: "Acme Supplies", amount: 1250, dueDate: "2026-07-15", lineItems: []) {
    invoice_id
  }
}

# Variables
{
  "vendor": "Acme Supplies",
  "amount": 1250,
  "dueDate": "2026-07-15",
  "lineItems": []
}
Variables
vendor
Name of the supplier that issued the invoice.
amount
Total amount to record for the invoice.
dueDate
Date payment is due, in YYYY-MM-DD format.
lineItems
Itemized charges on the invoice; empty in this example.
Response selection
invoice_id
Identifier assigned to the newly submitted invoice.

Payload

# GraphQL response selection (illustrative; schema pending)
{
  invoice_id
}

# Example response JSON
{
  "invoice_id": 42
}
invoice_id
Identifier assigned to the newly submitted invoice.
Back to GraphQL quickstart

Request invoice review #

Illustrative signature: requestInvoiceReview(invoiceId: ID!, reason: String). The optional reason explains why invoice 42 needs manual review.

Mutation & variables

# GraphQL mutation (illustrative; schema pending)
mutation RequestInvoiceReview($invoiceId: ID!, $reason: String) {
  requestInvoiceReview(invoiceId: $invoiceId, reason: $reason) {
    invoice_id
    status
    event_id
  }
}

# Variables
{
  "invoiceId": 42,
  "reason": "Vendor details need manual verification"
}
Variables
invoiceId
Identifier of the invoice that needs manual review.
reason
Optional explanation for why the invoice needs review.
Response selection
invoice_id
Identifier of the invoice sent for review.
status
Current invoice status after the review request.
event_id
Identifier of the recorded review request event.

Payload & response

# GraphQL response selection (illustrative; schema pending)
{
  invoice_id
  status
  event_id
}

# Expected response JSON
{
  "invoice_id": 42,
  "status": "pending_review",
  "event_id": 13
}
invoice_id
Identifier of the invoice sent for review.
status
Current invoice status after the review request.
event_id
Identifier of the recorded review request event.
Back to GraphQL quickstart

Approve invoice #

Illustrative payload for a hypothetical approve mutation. The invoice identifier is 42 in this example.

Variables

{
  "invoice_id": 42
}
invoice_id
Identifier of the invoice to approve.

Payload

# GraphQL response selection (illustrative; schema pending)
{
  invoice_id
  status
  event_id
}

# Example response JSON
{
  "invoice_id": 42,
  "status": "approved",
  "event_id": 11
}
invoice_id
Identifier of the approved invoice.
status
Invoice status after approval.
event_id
Identifier of the recorded approval event.
Back to GraphQL quickstart

For the confirmed REST error shape, see Error response handling. That example documents REST behavior only.

Reject invoice #

Illustrative payload for a hypothetical reject mutation. The optional reason is limited to 1,000 characters in the REST API.

Variables

{
  "invoice_id": 42,
  "reason": "duplicate of invoice 38"
}
invoice_id
Identifier of the invoice to reject.
reason
Optional explanation for rejecting the invoice.

Payload

# GraphQL response selection (illustrative; schema pending)
{
  invoice_id
  status
  event_id
}

# Example response JSON
{
  "invoice_id": 42,
  "status": "rejected",
  "event_id": 12
}
invoice_id
Identifier of the rejected invoice.
status
Invoice status after rejection.
event_id
Identifier of the recorded rejection event.
Back to GraphQL quickstart
01 —

API keys

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=42  api_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 routes
Authorization: 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.
02 —

Inbox / POST /v1/invoices #

Submit an invoice PDF or image and Arcflow stores it, records the receipt, and lands it on the review queue with approval_status=pending_review.

POST /v1/invoices

Request

  • Headers: Authorization: Bearer <ARCFLOW_KEY>
  • Body: multipart/form-data
  • Required field: file — one of application/pdf, image/jpeg, image/png, image/gif, image/webp. 50 MB max.
  • Optional fields: vendor_name, external_id (stored as the invoice source reference; the endpoint does not enforce idempotency), notes.
# Submit a PDF to the inbox
curl -X POST https://arcflow.com/v1/invoices \
  -H "Authorization: Bearer $ARCFLOW_KEY" \
  -F file=@invoice.pdf \
  -F vendor_name="Acme Corp" \
  -F external_id="acme-2026-07-001" \
  -F notes="Submitted by procurement agent"

Response (201 Created)

{
  "invoice_id": 42,
  "event_id": 7,
  "status": "pending",
  "r2_url": "https://arcflow-polsia.svc.r2.dev/invoice-acme-2026-07-001.pdf"
}

Response fields

invoice_id
integer ID of the created invoice
event_id
ID of the recorded invoice_received event
status
invoice status (pending)
r2_url
durable storage URL for the uploaded file

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.
View the REST invoice listing
03 —

Approval state machine

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
FromActionTo
pending_reviewPOST /v1/invoices/<id>/approveapproved
pending_reviewPOST /v1/invoices/<id>/rejectrejected
approved(later) Stripe payment flowpaid

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.

# Approve invoice 42
curl -X POST https://arcflow.com/v1/invoices/42/approve \
  -H "Authorization: Bearer $ARCFLOW_KEY"

Response

{
  "invoice_id": 42,
  "status": "approved",
  "event_id": 11
}

Reject

POST /v1/invoices/<id>/reject

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"}'

Response

{
  "invoice_id": 42,
  "status": "rejected",
  "event_id": 12
}
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.

List the latest invoices #

GET /v1/invoices

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

Response

{
  "invoices": [
    {
      "id": 42,
      "vendor_id": 7,
      "vendor_name_raw": "Acme Corp",
      "invoice_number": "AC-42",
      "amount": 1280.50,
      "currency": "USD",
      "due_date": "2026-08-12",
      "issue_date": "2026-07-29",
      "status": "pending",
      "source": "email",
      "source_id": "message-42",
      "raw_data": { "ingestion": "email" },
      "duplicate_of": null,
      "created_at": "2026-07-29T18:24:11.000Z",
      "approval_status": "pending_review",
      "approver": null,
      "approved_at": null,
      "notes": null,
      "workflow_stage": "ingestion",
      "payment_link_url": null,
      "payment_initiated_at": null,
      "payment_status": "unpaid",
      "paid_at": null,
      "vendor_name": "Acme Corp"
    }
  ]
}

Response fields

invoices
array of invoice rows
id
invoice row ID
vendor_id
linked vendor row ID, or null
vendor_name_raw
raw vendor name stored on the invoice
invoice_number
invoice number
amount
invoice amount
currency
invoice currency code
due_date
invoice due date
issue_date
invoice issue date
status
invoice status
source
invoice intake source
source_id
source reference stored on the invoice
raw_data
raw data stored with the invoice
duplicate_of
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 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"
Back to REST API reference

A typical agent loop

# 1. Pull the open queue
QUEUE=$(curl -s "https://arcflow.com/v1/invoices?status=pending_review")

# 2. For each id, decide approve or reject (your logic here):
curl -X POST https://arcflow.com/v1/invoices/42/approve \
  -H "Authorization: Bearer $ARCFLOW_KEY"

curl -X POST https://arcflow.com/v1/invoices/43/reject \
  -H "Authorization: Bearer $ARCFLOW_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"vendor not approved"}'