/api/v1/accounting/sage/start
auth: jwt (administrator)Begin a Sage OAuth2 authorisation flow for the caller's business. Generates PKCE + state, persists in OAuthStates, returns the Sage authorisation URL. Rate-limited (10/min open bucket).
handlers: SageAccountingAuthController.start
No parameters.
APIResponseDataObject<SageStartResponse>APIErrorAPIError/api/v1/accounting/sage/callback
auth: noneSage OAuth callback. Validates state, exchanges the code, upserts a single SageConnections row (Sage has one business per token — no tenant selection), then 302 redirects (desktop) or serves a 200 text/html bridge page (mobile) opening `vsms://auth/sage/{success|failure}`.
handlers: SageAccountingAuthController.callback
| name | required | default | description |
|---|---|---|---|
code querystring | no | — | OAuth authorisation code returned by Sage. |
state querystring | no | — | PKCE state issued by `/start`. |
error querystring | no | — | Set by Sage on failure or user denial. |
redirecttext/html/api/v1/accounting/sage/status
auth: jwtSage connection summary — whether a Sage connection exists, the connected Sage business, and the current `autoFiscaliseInvoices` flag.
handlers: SageAccountingAuthController.status
No parameters.
APIResponseDataObject<SageStatusResponse>APIError/api/v1/accounting/sage/connection
auth: jwt (administrator)Soft-deactivate the Sage connection for the caller's business (`IsActive=0`). Rows are retained for history; the user may re-authorise via `/sage/start`. Fires `SAGE_DISCONNECTED` audit.
handlers: SageAccountingAuthController.disconnect
No parameters.
APIResponseDataObject<{ deactivatedCount: number }>/api/v1/accounting/sage/tax-mappings
auth: jwt (administrator)List all Sage tax-type to V-SDC tax-label mappings for the business (`Provider='sage'`). Mirrors `/accounting/xero/tax-mappings`.
handlers: SageAccountingTaxMappingsController.list
No parameters.
APIResponseDataList<TaxRateMappingDTO>/api/v1/accounting/sage/tax-mappings/auto-map
auth: jwt (administrator)Pull Sage tax-rates + V-SDC `/status` and return match suggestions. Does NOT persist. Rate-limited (10/min open bucket).
handlers: SageAccountingTaxMappingsController.autoMap
No parameters.
APIResponseDataObject<SageTaxMappingAutoMapResponse>APIError/api/v1/accounting/sage/tax-mappings
auth: jwt (administrator)Create or update one Sage tax-mapping. Re-activates an inactive row on match. Fires `SAGE_TAX_MAPPING_UPDATED` audit (resource type `SAGE_CONNECTION`).
handlers: SageAccountingTaxMappingsController.upsert
| name | required | default | description |
|---|---|---|---|
providerTaxType bodystring | yes | — | Sage tax-type code. |
providerTaxName bodystring | null | no | — | Human-readable Sage tax name. |
providerRate bodynumber | null | no | — | Sage tax rate. |
vsdcTaxLabel bodystring | yes | — | V-SDC label — one of `F/N/P/E/T/A/B/C/D`. |
vsdcRate bodynumber | null | no | — | V-SDC rate percent. |
APIResponseDataObject<TaxRateMappingDTO>APIError/api/v1/accounting/sage/tax-mappings/:providerTaxType
auth: jwt (administrator)Soft-delete a Sage tax-mapping (`IsActive=0`). Idempotent.
handlers: SageAccountingTaxMappingsController.remove
| name | required | default | description |
|---|---|---|---|
providerTaxType pathstring | yes | — | Sage tax-type code to deactivate. |
empty/api/v1/accounting/sage/tax-mappings/:providerTaxType/restore
auth: jwt (administrator)Re-activate a deactivated Sage tax-mapping (`IsActive=1`). Idempotent.
handlers: SageAccountingTaxMappingsController.restore
| name | required | default | description |
|---|---|---|---|
providerTaxType pathstring | yes | — | Sage tax-type code to re-activate. |
empty/api/v1/accounting/sage/sync
auth: jwt (administrator | view_invoices | submit_invoices)Pull-sync invoices from the active Sage connection. Fetches OUTSTANDING / OVERDUE / PAID via three API calls merged client-side, normalises, persists to `Invoices` (`Source='sage'`). Idempotency key = `SHA-256(businessId:sageBusinessId:sageInvoiceId)`. `modifiedSince` is silently ignored (Sage's `sales_invoices` has no date filter). Auto-fiscalisation behaviour matches Xero. HTTP caching disabled. Runs in the background: replies `202 { runId }` at once and stores the outcome on the run. The finished run's `result` is the old synchronous body: `data` is now an empty list, `totalRows` the fetched count and `message` the counters string.
handlers: AccountingInvoicesController.sageSync
| name | required | default | description |
|---|---|---|---|
contactId querystring | no | — | Sage contact id — narrows the result to one contact. |
modifiedSince queryISO-8601 datetime | no | — | Silently ignored for Sage. |
dateTo queryISO-8601 datetime | no | — | Post-fetch filter on `updatedAt`. |
page queryinteger | no | — | 1-based page. |
pageSize queryinteger | no | — | 1–100. |
APIResponseDataObject<BackgroundRunAcceptedDTO>APIErrorAPIErrorAPIErrorAPIError