vsmsconnect — API — lightspeed-x

← all endpoints

GET/api/v1/accounting/lightspeed-x/callback auth: none (Lightspeed-initiated browser redirect)

OAuth callback hit by the user's browser after Lightspeed consent; mounted without the JWT guard because no app session exists on this request. Validates `state` (single-use), exchanges `code` for the store identified by `domain_prefix`, and upserts the connection. Desktop User-Agents get a 302 to the web success/failure page; mobile User-Agents get a 200 HTML bridge page that opens the native deep link and falls back to the web URL. Failures never surface as an API error: the redirect carries a sanitised error code.

handlers: LightspeedXAuthController.callback

Inputs

namerequireddefaultdescription
code query
string
no—Authorisation code returned by Lightspeed on success.
state query
string
no—OAuth state issued by `/start`; an unknown, expired or reused value yields LIGHTSPEED_INVALID_STATE in the failure redirect.
domain_prefix query
string
no—Store domain prefix Lightspeed appends to the redirect.
error query
string
no—Set by Lightspeed when consent is denied or the flow fails; routes to the failure redirect.
error_description query
string
no—Human-readable error from Lightspeed (logged only).

Outputs

302
redirect
Desktop User-Agent — redirect to `${LIGHTSPEED_FRONTEND_WEB_BASE_URL}/auth/lightspeed-x/{success|failure}` carrying the store prefix or a sanitised error code.
200 text/html
text/html
Mobile User-Agent — bridge page that tries the native deep link then falls through to the web URL after 900 ms.
GET/api/v1/accounting/lightspeed-x/start auth: jwt (administrator) + connector licence gate; 10/min rate limit (`open` bucket)

Begin a Lightspeed X-Series OAuth2 authorisation flow (no PKCE — X-Series does not support it). Returns the authorisation URL for the user to open. The licence gate applies only when one is wired on the deployment.

handlers: LightspeedXAuthController.start

Inputs

No parameters.

Outputs

200
APIResponseDataObject<LightspeedXStartResponse>
`{ authorizationUrl }`.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
429
APIError
Rate limit exceeded.
GET/api/v1/accounting/lightspeed-x/status auth: jwt (any authenticated member of the business)

Connection summary: every active Lightspeed store connection (no tokens) with its store name, assigned location and connection-issue state, plus the outlet filter list, `autoFiscaliseInvoices`, `autoFiscaliseConnector` and `syncFromDate`.

handlers: LightspeedXAuthController.status

Inputs

No parameters.

Outputs

200
APIResponseDataObject<LightspeedXStatusResponse>
`connected`, `connections[]`, `outlets[]`, auto-fiscalise flags, `syncFromDate`.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
GET/api/v1/accounting/lightspeed-x/connections/:connectionId/sync auth: jwt (administrator | view_invoices | submit_invoices)

Manual "Sync Now" for ONE store. Pulls sales for the named connection (scope-checked against the business), persists new ones and dispatches auto-fiscalisation when enabled; advances the connection watermark. Replaces the former business-level `GET /accounting/lightspeed-x/sync`. The response message summarises `fetched`, `inserted`, `duplicates`, `voided` and any `jobIds`. Runs in the background: replies `202 { runId }` at once and stores the outcome on the run. `modifiedSince` / `dateTo` are validated (`YYYY-MM-DD` or ISO-8601 datetime). 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: LightspeedXAuthController.sync

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).
modifiedSince query
string
no—Date bound forwarded to the sync as the invoice filter (bare `YYYY-MM-DD`). When omitted the backend resumes from its own watermark.
dateTo query
string
no—Upper date bound forwarded to the sync as the invoice filter.

Outputs

202
APIResponseDataObject<BackgroundRunAcceptedDTO>
Started in the background: `{ runId }`. Poll `GET /api/v1/businesses/:businessId/background-runs/:runId`; once `status` is `done`, `result` holds the response body this endpoint used to return.
409
APIError
BACKGROUND_RUN_IN_PROGRESS — a Sync Now for this store, or the business's Lightspeed X Sync All is already running. `data` is `BackgroundRunInProgressDTO` (`runId`, `kind`, `params`, `startedAt`) of the running run.
409
APIError
BUSINESS_CONTEXT_REQUIRED, or ACCOUNTING_PROVIDER_NOT_CONFIGURED when the connection is missing, inactive or belongs to another business.
502
APIError
Upstream Lightspeed failure.
POST/api/v1/accounting/lightspeed-x/sync-all auth: jwt (administrator | view_invoices | submit_invoices)

Sync All for Lightspeed X: syncs the listed connections one after another in ONE background run, never two at once, so a multi-store backlog does not load the provider or the database in parallel. Each connection takes its own sync lock as it is reached; one already syncing is reported `skipped`, and one failing does not stop the rest. Replies `202 { runId }`; the finished run's `result` is an `APIResponseDataObject<SyncAllResultDTO>` whose `connections[]` hold each connection's status and the body its single Sync Now would have returned.

handlers: LightspeedXAuthController.syncAll

Inputs

namerequireddefaultdescription
connectionIds body
uuid[] (1-50)
yes—The connections to sync, in order.
modifiedSince body
string
no—Optional lower bound, same format as the single-connection sync.
dateTo body
string
no—Optional upper bound, same format as the single-connection sync.

Outputs

202
APIResponseDataObject<BackgroundRunAcceptedDTO>
Started in the background: `{ runId }`. Poll `GET /api/v1/businesses/:businessId/background-runs/:runId`; once `status` is `done`, `result` holds the response body this endpoint used to return.
409
APIError
BACKGROUND_RUN_IN_PROGRESS — a Lightspeed X Sync All for this business is already running. `data` is `BackgroundRunInProgressDTO` (`runId`, `kind`, `params`, `startedAt`) of the running run.
422
APIError
Validation failed (missing or invalid `connectionIds`, bad date).
PATCH/api/v1/accounting/lightspeed-x/connections/:connectionId/location auth: jwt (administrator)

Assign (or clear) the VSMS Location one connected store fiscalises under, so its invoices sign with that location's certificate. `locationId: null` clears the assignment. Assigning also back-fills `LocationId` on that store's already-synced invoices that have none (assign-only; clearing does not un-file history). Reconnecting a store preserves the assignment.

handlers: LightspeedXAuthController.setLocation

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).
locationId body
string (uuid) | null
yes—Location to assign; `null` clears. Required — omission is rejected.

Outputs

200
APIResponseDataObject<LightspeedXConnectionSummary>
Updated connection summary.
400
APIError
Validation failed — `connectionId` or `locationId` is not a UUID, or `locationId` is missing.
404
APIError
ACCOUNTING_PROVIDER_NOT_CONFIGURED — the connection does not exist or belongs to another business.
404
APIError
LOCATION_NOT_FOUND — `locationId` does not belong to this business.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
GET/api/v1/accounting/lightspeed-x/connections/:connectionId/outlets auth: jwt (administrator)

List the connection's outlets with each one's mapped VSMS Location (null = unmapped, which blocks its sales). Returns the union of live outlets and stored mappings, so a mapping whose outlet was deleted in Lightspeed stays visible, flagged inactive.

handlers: LightspeedXAuthController.listOutlets

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).

Outputs

200
APIResponseDataList<object>
Outlets with mapped `locationId`, status and review state.
400
APIError
Validation failed — `connectionId` is not a UUID.
404
APIError
ACCOUNTING_PROVIDER_NOT_CONFIGURED — the connection does not exist or belongs to another business.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
PATCH/api/v1/accounting/lightspeed-x/connections/:connectionId/outlets/:outletId/location auth: jwt (administrator)

Assign (or clear) the VSMS Location for ONE outlet. `locationId: null` clears the mapping, which BLOCKS that outlet's sales. Saves the mapping only; held invoices are released by `outlets/resync-blocked`. Refused while the outlet is rejected.

handlers: LightspeedXAuthController.setOutletLocation

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).
outletId path
string
yes—Lightspeed's own outlet id (not validated as a UUID).
locationId body
string (uuid) | null
yes—Location to map; `null` clears. Required — omission is rejected.
outletName body
string | null
no—Outlet name as the caller sees it (max 255), stored as a display snapshot; never used for routing.

Outputs

204
empty
Mapping saved.
400
APIError
Validation failed.
404
APIError
ACCOUNTING_PROVIDER_NOT_CONFIGURED — the connection does not exist or belongs to another business.
404
APIError
LOCATION_NOT_FOUND — `locationId` does not belong to this business.
409
APIError
OUTLET_REJECTED_CANNOT_MAP — accept the outlet before mapping a location (also BUSINESS_CONTEXT_REQUIRED).
POST/api/v1/accounting/lightspeed-x/connections/:connectionId/outlets/:outletId/reject auth: jwt (administrator)

Decline a discovered outlet. A rejected outlet's sales are held exactly like an unmapped outlet's. Idempotent when already rejected.

handlers: LightspeedXAuthController.rejectOutlet

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).
outletId path
string
yes—Lightspeed's own outlet id (not validated as a UUID).

Outputs

204
empty
Outlet rejected.
400
APIError
Validation failed.
404
APIError
ACCOUNTING_PROVIDER_NOT_CONFIGURED — the connection does not exist or belongs to another business.
404
APIError
LIGHTSPEED_OUTLET_NOT_FOUND — the outlet id is not a live outlet on this connection.
409
APIError
OUTLET_MAPPED_CANNOT_REJECT — clear the outlet mapping first (also BUSINESS_CONTEXT_REQUIRED).
POST/api/v1/accounting/lightspeed-x/connections/:connectionId/outlets/:outletId/accept auth: jwt (administrator)

Accept a previously rejected outlet, returning it to the normal mapping flow.

handlers: LightspeedXAuthController.acceptOutlet

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).
outletId path
string
yes—Lightspeed's own outlet id (not validated as a UUID).

Outputs

204
empty
Outlet accepted.
400
APIError
Validation failed.
404
APIError
ACCOUNTING_PROVIDER_NOT_CONFIGURED — the connection does not exist or belongs to another business.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
POST/api/v1/accounting/lightspeed-x/outlets/resync-blocked auth: jwt (administrator)

Business-wide: re-evaluate every Lightspeed invoice blocked by outlet-certificate routing (unmapped outlet or no usable certificate) and dispatch the ones the current mappings now allow. Mapping an outlet does not do this automatically. Audits `LIGHTSPEED_OUTLET_BLOCKED_RESYNCED`. Runs in the background: replies `202 { runId }` at once and stores the outcome on the run. The finished run's `result` is an `APIResponseDataObject` of the re-sync counts (`reprocessed`, `nowEligible`, `nowEligibleInvoices`, `nowEligibleQuotes`, `stillBlocked`, `autoFiscalisationJobIds`).

handlers: LightspeedXAuthController.resyncOutletBlocked

Inputs

No parameters.

Outputs

202
APIResponseDataObject<BackgroundRunAcceptedDTO>
Started in the background: `{ runId }`. Poll `GET /api/v1/businesses/:businessId/background-runs/:runId`; once `status` is `done`, `result` holds the response body this endpoint used to return.
409
APIError
BACKGROUND_RUN_IN_PROGRESS — a blocked-invoice re-sync for this business (every re-sync entry point shares one lock) is already running. `data` is `BackgroundRunInProgressDTO` (`runId`, `kind`, `params`, `startedAt`) of the running run.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
501
APIError
NOT_IMPLEMENTED — outlet-routed certificate re-sync is not configured on this deployment.
GET/api/v1/accounting/lightspeed-x/register-tills auth: jwt (administrator)

This business's Lightspeed register-tills grouped under their outlet, for the Receipt Printers tab. Business-wide across all connected stores (receipt-printer scope is per connector).

handlers: LightspeedXAuthController.listRegisterTills

Inputs

No parameters.

Outputs

200
APIResponseDataList<object>
Register-tills grouped by outlet.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
POST/api/v1/accounting/lightspeed-x/registers/sync auth: jwt (administrator)

Pull every active connection's registers and upsert one claimable print till per register. Business-wide. A register whose location resolves to nothing (outlet mapping, then the connection location, then the business default) is skipped and counted.

handlers: LightspeedXAuthController.syncRegisters

Inputs

No parameters.

Outputs

200
APIResponseDataObject<LightspeedRegisterSyncResult>
`registersDiscovered`, `tillsCreated`, `tillsExisting`, `skipped`.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
DELETE/api/v1/accounting/lightspeed-x/connections/:connectionId auth: jwt (administrator)

Disconnect ONE Lightspeed store: best-effort deregisters its `sale.update` webhook, then deactivates that connection. Per connection, never business-wide — a business may hold several stores.

handlers: LightspeedXAuthController.disconnect

Inputs

namerequireddefaultdescription
connectionId path
string (uuid)
yes—Lightspeed connection id (one per connected store).

Outputs

200
APIResponseDataObject<{ deactivatedCount: number }>
Number of connections deactivated.
404
APIError
ACCOUNTING_PROVIDER_NOT_CONFIGURED — connection not found for this business.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
GET/api/v1/accounting/lightspeed-x/tax-mappings auth: jwt (administrator)

List all Lightspeed X-Series tax-type to V-SDC tax-label mappings for the business (active and inactive). Mappings are per business and shared across all of its connected stores.

handlers: LightspeedXTaxMappingsController.list

Inputs

No parameters.

Outputs

200
APIResponseDataList<TaxRateMappingDTO>
Mappings for `Provider='lightspeed-x'`.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
POST/api/v1/accounting/lightspeed-x/tax-mappings/auto-map auth: jwt (administrator)

Fetch the live Lightspeed tax rates and V-SDC `/status`, then return match suggestions. Does NOT persist mappings — the admin confirms each via PUT. Best-effort side effects: drift-checks confirmed mappings against the fetched rates and records never-seen codes as proposals under unmapped tax types; failures there never fail the response. Rate-limited (10/min open bucket).

handlers: LightspeedXTaxMappingsController.autoMap

Inputs

No parameters.

Outputs

200
APIResponseDataList<TaxRateMappingSuggestion>
Suggestions per Lightspeed tax code.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
429
APIError
Rate limit exceeded (caller or Lightspeed).
PUT/api/v1/accounting/lightspeed-x/tax-mappings auth: jwt (administrator)

Create or update one Lightspeed tax-type to V-SDC label mapping for the business.

handlers: LightspeedXTaxMappingsController.upsert

Inputs

namerequireddefaultdescription
providerTaxType body
string
yes—Lightspeed tax code. Trimmed, 1–100 chars.
providerTaxName body
string | null
no—Human-readable tax name (max 500).
providerRate body
number | null
no—Lightspeed rate for display.
vsdcTaxLabel body
string
yes—Target V-SDC tax label. Trimmed, 1–10 chars.
vsdcRate body
number | null
no—V-SDC rate for display.

Outputs

200
APIResponseDataObject<TaxRateMappingDTO>
Upserted mapping row.
400
APIError
Validation failed.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
DELETE/api/v1/accounting/lightspeed-x/tax-mappings/:providerTaxType auth: jwt (administrator)

Deactivate a Lightspeed tax mapping. The row is retained and can be re-activated via the restore endpoint.

handlers: LightspeedXTaxMappingsController.remove

Inputs

namerequireddefaultdescription
providerTaxType path
string
yes—Lightspeed tax code to deactivate (1–100 chars).

Outputs

204
empty
No content.
400
APIError
Validation failed.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
PATCH/api/v1/accounting/lightspeed-x/tax-mappings/:providerTaxType/restore auth: jwt (administrator)

Re-activate a previously deactivated Lightspeed tax mapping.

handlers: LightspeedXTaxMappingsController.restore

Inputs

namerequireddefaultdescription
providerTaxType path
string
yes—Lightspeed tax code to re-activate (1–100 chars).

Outputs

204
empty
No content.
400
APIError
Validation failed.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
POST/webhooks/lightspeed-x auth: hmac (x-signature)

Lightspeed-initiated `sale.update` delivery. Verifies HMAC-SHA256 over the raw body with the OAuth app's client secret (constant-time compare against the `signature=<hex>` value of the `X-Signature` header). A valid delivery is acknowledged `200` before anything else, then the sale id and store `domain_prefix` are fanned to a Redis stream; the worker re-fetches the canonical sale, so the payload is only a wake signal. Accepts JSON or form-urlencoded bodies; non-`sale.update` or unroutable deliveries are acknowledged and skipped. NOT mounted under `/api/v1`.

handlers: LightspeedXWebhookController.handle

Inputs

namerequireddefaultdescription
x-signature header
string
yes—`signature=<hex>,algorithm=HMAC-SHA256` — HMAC-SHA256 of the raw request body.
type body
string
no—Event type; only `sale.update` is processed.
payload body
object | string
no—Sale object (or its JSON string): `id`, `domain_prefix`, `updated_at`, `payments`, `user`, line items and `return_for` are used.
domain_prefix body
string
no—Store prefix, if not carried inside the payload.

Outputs

200
empty
Valid signature — acknowledged, empty body.
401
empty
Missing or invalid signature (audited as LIGHTSPEED_WEBHOOK_SIGNATURE_INVALID); empty body.
503
APIError
LIGHTSPEED_WEBHOOK_NOT_CONFIGURED — the client secret is unset.
500
APIError
INTERNAL_ERROR — raw-body capture middleware missing.