Skip to content

Quickstart

The sandbox runs with synthetic organizations and lets you sign in as any of their people without single sign-on, so you can try the API in minutes. Production instances accept only single sign-on.

In the examples, $SPEND is the instance’s address, such as https://app.s2p.productexec.co or http://localhost:8787 for a local copy.

Terminal window
curl -s $SPEND/api/demo/users | jq '.tenants[] | {tenantId, name}'
curl -s $SPEND/api/demo/users | jq '.users[] | select(.tenantId=="ten_demo_utility") | {id, name, roles}'
Terminal window
TOKEN=$(curl -s -X POST $SPEND/api/session \
-H 'content-type: application/json' \
-d '{"tenantId":"ten_demo_utility","userId":"<a user id from step 1>"}' | jq -r .token)

The response is {"token": "...", "expiresInMinutes": 480}. Send the token as a bearer token on every call.

Terminal window
curl -s $SPEND/api/me -H "authorization: Bearer $TOKEN" | jq
curl -s "$SPEND/api/invoices?status=exception&pageSize=5" -H "authorization: Bearer $TOKEN" | jq '.invoices[] | {number, supplierName, status, exceptions}'
Terminal window
curl -s -X POST $SPEND/api/documents \
-H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
-d "{\"filename\":\"invoice.pdf\",\"contentBase64\":\"$(base64 < invoice.pdf | tr -d '\n')\"}" | jq

Each document comes back with what capture made of it and, for an invoice, the invoice id and status.

Terminal window
curl -s -X POST $SPEND/api/session/logout -H "authorization: Bearer $TOKEN"

Agencies that run Spend in their own cloud account get the container image (or the source) and run it the same way locally, with Docker providing Postgres and S3-compatible storage:

Terminal window
pnpm install
pnpm db:up
cp .env.example .env
pnpm start # http://localhost:8787, with the sandbox organizations

See Install and configure for a hosted instance.