Skip to content

Begin the OAuth authorization-code flow for Xero or QuickBooks Online (ADMIN+)

POST
/erp-connections/oauth/start
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.

X-Invogi-Organization
string format: uuid

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.

Media typeapplication/json
object
provider
required
string
Allowed values: XERO QUICKBOOKS_ONLINE
company_id

Defaults to the organization’s default company

string format: uuid
mode
string
default: SYNC
Allowed values: SYNC SCAN TRIAL
history_months

SCAN only: read bills issued in this many months before today

integer
default: 12
Allowed values: 6 12
scan_id

TRIAL only (required): the completed ERP scan the trial follows

string format: uuid

Examples

Free 12-month historical scan from Xero

{
"provider": "XERO",
"mode": "SCAN",
"history_months": 12
}

Authorize URL to redirect the browser to

Media typeapplication/json
object
authorize_url
required
string format: uri

Example generated

{
"authorize_url": "https://example.com"
}

Invalid request

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: NOT_FOUND UNAUTHORIZED FORBIDDEN INVALID_REQUEST CONFLICT RATE_LIMITED USAGE_LIMIT_EXCEEDED PROCESSING_FAILED
message
required
string
request_id
required
string
details

Optional stable, content-free context, e.g. {reason, resets_at, preparation_id}.

object
key
additional properties
One of:
string

Example

{
"error": {
"code": "NOT_FOUND"
}
}

Missing or invalid API key

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: NOT_FOUND UNAUTHORIZED FORBIDDEN INVALID_REQUEST CONFLICT RATE_LIMITED USAGE_LIMIT_EXCEEDED PROCESSING_FAILED
message
required
string
request_id
required
string
details

Optional stable, content-free context, e.g. {reason, resets_at, preparation_id}.

object
key
additional properties
One of:
string

Example

{
"error": {
"code": "NOT_FOUND"
}
}

API key lacks required scope/role

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: NOT_FOUND UNAUTHORIZED FORBIDDEN INVALID_REQUEST CONFLICT RATE_LIMITED USAGE_LIMIT_EXCEEDED PROCESSING_FAILED
message
required
string
request_id
required
string
details

Optional stable, content-free context, e.g. {reason, resets_at, preparation_id}.

object
key
additional properties
One of:
string

Example

{
"error": {
"code": "NOT_FOUND"
}
}

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