Begin the OAuth authorization-code flow for Xero or QuickBooks Online (ADMIN+)
const url = 'https://api.invogi.com/v1/erp-connections/oauth/start';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"provider":"XERO","mode":"SCAN","history_months":12}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.invogi.com/v1/erp-connections/oauth/start \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "provider": "XERO", "mode": "SCAN", "history_months": 12 }'Returns the provider’s own authorize URL with a signed, short-lived
state parameter bound to this organization, provider, and target
company. apps/app redirects the browser to it directly; this endpoint
does not redirect. See docs/20_ERP_CONNECTORS.md “OAuth
(authorization-code) connectors” for what state encodes and why.
mode: SYNC (default) sets up the recurring connection and requires
an active subscription. mode: SCAN is available on the free tier: a
read-only, one-shot historical risk scan of the bills issued in the
last history_months, counted against the one-time history-import
allowance (docs/20_ERP_CONNECTORS.md “Free historical scan”). The
connection is created as SCAN_ONLY, never syncs, and its grant is
revoked as soon as the scan finishes. A free workspace gets one ERP
scan with results. After subscribing, the recurring connect (mode: SYNC) reuses the same connection, so scanned bills are not imported
again.
mode: TRIAL starts a free workspace’s 14-day monitoring trial after
its ERP scan scan_id (docs/20_ERP_CONNECTORS.md “Free monitoring
trial”): the same provider and company as that scan, read-only, no
card. The connection is created as TRIAL, syncs new bills hourly up
to 300 bills outside the usage allowance, and its grant is revoked
when the trial ends unless the workspace subscribed. One per
workspace. The callback redirects to /scans/{scan_id}?trial=started.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”For a Clerk session, selects a workspace in which the user has an active membership. If omitted, the remembered accessible workspace is used. API keys remain bound to their own workspace and cannot select another tenant.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Defaults to the organization’s default company
SCAN only: read bills issued in this many months before today
TRIAL only (required): the completed ERP scan the trial follows
Examples
Free 12-month historical scan from Xero
{ "provider": "XERO", "mode": "SCAN", "history_months": 12}Free 14-day monitoring trial after a Xero scan
{ "provider": "XERO", "mode": "TRIAL", "scan_id": "4f1c2a9e-6f4b-4b8e-9a51-2f1d3c7b8e10"}Responses
Section titled “Responses”Authorize URL to redirect the browser to
object
Example generated
{ "authorize_url": "https://example.com"}Invalid request
Missing or invalid API key
API key lacks required scope/role
SCAN: the company already has a recurring connection to this provider (a scan never replaces it), or a scan of it is still running. TRIAL: the workspace has a subscription, the scan is not a completed ERP scan with results, or the company already has a recurring connection
USAGE_LIMIT_EXCEEDED. SCAN: the free workspace already had its free ERP scan, or has no history-import allowance left. TRIAL: the workspace already had its monitoring trial