vsmsconnect — API — sage100

← all endpoints

POST/api/v1/businesses/:businessId/accounting/sage100/sync auth: apikey

On-premise Sage 100 agent push. Headless agent POSTs a batch of normalised `AccountingInvoice[]` for the business; the helper inserts → dedupes → auto-fiscalises (when the flag is on). API key must have `scope=sage100` (enforced by `requireScope`); empty array is allowed (used by the agent's first-run dry-run wizard).

handlers: AccountingAgentSyncController.syncSage100

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID. Must match the API key's `BusinessId`.
Authorization header
string
yes—`ApiKey <key>` — validated by `requireApiKey` against `ApiKeys.KeyHash`.
invoices body
PushInvoice[]
yes—Array of pushed invoices. Each entry mirrors `AccountingInvoice` with optional `posSaleId`/`posRegisterId`/`originalPosSaleId`/`cashierId`/payment `tenders[]`. Empty array allowed.

Outputs

200
APIResponseDataObject<PushInvoicesResponse>
`{ fetched, inserted, duplicates, jobIds[], outcomes[] }`.
401
APIError
Missing or invalid API key.
403
APIError
API key scope does not match `sage100`.
GET/api/v1/accounting/sage100/tax-mappings auth: jwt (administrator)

List Sage 100 tax-mappings for the business (`Provider='sage100'`).

handlers: AccountingAgentTaxMappingsController.listFor('sage100')

Inputs

No parameters.

Outputs

200
APIResponseDataList<TaxRateMappingDTO>
Sage 100 mappings.
PUT/api/v1/accounting/sage100/tax-mappings auth: jwt (administrator)

Upsert one Sage 100 tax-mapping. Same body shape as the other tax-mapping CRUD surfaces.

handlers: AccountingAgentTaxMappingsController.upsertFor('sage100')

Inputs

namerequireddefaultdescription
providerTaxType body
string
yes—Sage 100 tax-code.
providerTaxName body
string | null
no—Human-readable tax name.
providerRate body
number | null
no—Provider tax rate.
vsdcTaxLabel body
string
yes—V-SDC label.
vsdcRate body
number | null
no—V-SDC rate percent.

Outputs

200
APIResponseDataObject<TaxRateMappingDTO>
Upserted mapping.
422
APIError
Invalid V-SDC label.
DELETE/api/v1/accounting/sage100/tax-mappings/:providerTaxType auth: jwt (administrator)

Soft-delete a Sage 100 tax-mapping (`IsActive=0`). Idempotent.

handlers: AccountingAgentTaxMappingsController.removeFor('sage100')

Inputs

namerequireddefaultdescription
providerTaxType path
string
yes—Sage 100 tax-code to deactivate.

Outputs

204
empty
No content.
PATCH/api/v1/accounting/sage100/tax-mappings/:providerTaxType/restore auth: jwt (administrator)

Re-activate a deactivated Sage 100 mapping (`IsActive=1`). Idempotent.

handlers: AccountingAgentTaxMappingsController.restoreFor('sage100')

Inputs

namerequireddefaultdescription
providerTaxType path
string
yes—Sage 100 tax-code to re-activate.

Outputs

204
empty
No content.
POST/api/v1/businesses/:businessId/accounting/sage100/register-manifest auth: apikey

Sage 100 branch and register discovery. The agent posts its `F_DEPOT` depots and optionally its `F_CAISSE` registers. The cloud upserts one `Locations` row per depot, left `proposed` for admin review (not auto-accepted), and, when `tills` is non-empty, one `Tills` row per register keyed on `PosRegisterId` at its depot's location with a null `MachineId`. `tills` defaults to `[]`, which is what every measured install and any older agent sends. Fires `SAGE100_MANIFEST_RECEIVED` plus per-row rename/move audits.

handlers: AccountingAgentSyncController.registerSage100Manifest

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID. Must match the API key's `BusinessId`; a mismatch is rejected with 403.
Authorization header
string
yes—`ApiKey <key>` — validated by `requireApiKey` against the stored key hash.
capturedAt body
number
yes—Epoch-ms time the agent captured the snapshot.
depots body
{ branchId: string; code?: string|null; name: string; city?: string|null; isPrimary?: boolean }[]
yes—Sage 100 depots.
tills body
{ posRegisterId: string; tillName: string; branchId: string }[]
no[]Sage 100 registers. A register whose depot cannot be resolved is skipped.

Outputs

200
APIResponseDataObject<{ branchesCreated; branchesExisting; branchesRenamed; tillsCreated; tillsExisting; tillsRenamed; tillsMoved }>
Counts of what the manifest created / already had / renamed / moved.
401
APIError
AUTH_UNAUTHORIZED — missing or invalid (unknown or revoked) API key.
403
APIError
USER_FORBIDDEN — the API key does not belong to the business in the path.
403
APIError
USER_FORBIDDEN — API key scope does not match `sage100`. Unscoped keys pass.
422
APIError
VALIDATION_ERROR — body or path failed schema validation.
POST/api/v1/accounting/sage100/tax-mappings/seed-from-agent auth: apikey

Sage 100 agent tax-rate seed. The sales agent posts its `dbo.F_TAXE` snapshot on startup and whenever a push response carries `requestTaxRateSeed`. Every not-yet-confirmed code is written as a PROPOSAL (`UnmappedTaxTypes`) with its name and rate; nothing is auto-confirmed into `TaxRateMappings`. Already-confirmed codes are skipped unless the source rate or name has drifted, in which case the mapping is deactivated for admin review. Drift is checked on percentage taxes only; levies are skipped. The business comes from the API key (no path businessId); only `requireApiKey` runs, with no scope check.

handlers: Sage100TaxMappingsController.seedFromAgent

Inputs

namerequireddefaultdescription
Authorization header
string
yes—`ApiKey <key>` — validated by `requireApiKey` against the stored key hash.
taxRates body
{ code: string; name?: string|null; rate?: number|null; rateKind?: number|null; group?: string|null }[]
yes—Sales-side rows from `dbo.F_TAXE`. Each `TA_Code` is proposed on its own; `rateKind` non-zero marks a fixed-amount levy, which is proposed with a null rate and its amount in the name. `group` is accepted but no longer used for keying.

Outputs

200
APIResponseDataObject<{ proposed: { code: string; name: string|null; rate: number|null }[]; alreadyMapped: number; driftDetected: number }>
Codes proposed this call, count of already-confirmed codes and count of drift deactivations.
401
APIError
AUTH_UNAUTHORIZED — missing or invalid (unknown or revoked) API key.
422
APIError
VALIDATION_ERROR — body or path failed schema validation.
POST/api/v1/accounting/sage100/tax-mappings/request-seed auth: jwt (administrator)

Admin request for a Sage 100 tax-rate re-seed. Sets an in-memory per-business flag; the next Sage 100 agent push response carries `requestTaxRateSeed: true`, prompting the agent to call seed-from-agent again. Business is taken from the JWT. Fires `SAGE100_TAX_MAPPING_SEED_REQUESTED`.

handlers: Sage100TaxMappingsController.requestSeed

Inputs

No parameters.

Outputs

202
APIResponseDataObject<{ requested: true }>
Re-seed flagged for the next agent push.
401
APIError
AUTH_UNAUTHORIZED — missing or invalid access token.
403
APIError
USER_FORBIDDEN — caller is not an administrator.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
GET/api/v1/businesses/:businessId/accounting/sage100/branch-mappings auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

List every Sage 100 depot the admin should see: the union of currently discovered depots and stored mappings, so a mapping whose depot vanished from the source is still visible. Each row carries branchId, branchName, locationId (null when unmapped), status ('active' | 'inactive'), discoveredLocationId and proposalStatus.

handlers: Sage100BranchMappingController.list

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

200
APIResponseDataObject<{ branches: Sage100BranchMappingView[] }>
Wrapped list of depot mappings under `branches`.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
POST/api/v1/businesses/:businessId/accounting/sage100/branch-mappings/resync-blocked auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Re-evaluate every invoice blocked by depot-certificate routing and dispatch the ones that can now be signed. A parallel action to POST /invoices/reprocess-unmapped, which is scoped to unmapped tax codes and cannot see these block reasons. Quotes (PROFORMA) that become eligible are counted but not dispatched. 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: Sage100BranchMappingController.resyncBlocked

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

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.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
501
APIError
NOT_IMPLEMENTED — the branch-routed re-sync action is not wired on this deployment.
POST/api/v1/businesses/:businessId/accounting/sage100/branch-mappings/request-manifest auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Ask the Sage 100 sales agent to re-send its depots and registers, so a depot or register added on the Sage 100 side appears without restarting the agent. Sets a request that the agent receives as `requestManifest: true` on its next push; the agent then re-sends asynchronously, so the new rows appear shortly after this call returns.

handlers: Sage100BranchMappingController.requestManifest

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

202
empty
Request recorded; no body. The agent re-sends its depots and registers on its next push.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
501
APIError
NOT_IMPLEMENTED — the manifest re-send request is not wired on this deployment.
POST/api/v1/businesses/:businessId/accounting/sage100/branch-mappings/backfill auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Seed depot mappings from what already-fiscalised invoices attest to, and report which target locations hold no usable certificate. Idempotent and never overwrites an admin's own mapping; a depot whose history names several signing locations is skipped ('conflicting_history') rather than guessed.

handlers: Sage100BranchMappingController.backfill

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

200
APIResponseDataObject<object>
written[] ({ branchId, locationId }), skipped[] ({ branchId, reason: 'conflicting_history' | 'already_mapped' }), locationsWithoutCertificate[] ({ locationId, name }).
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
501
APIError
NOT_IMPLEMENTED — the backfill action is not wired on this deployment.
PUT/api/v1/businesses/:businessId/accounting/sage100/branch-mappings/:branchId auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Assign this Sage 100 depot to a business Location (re-activating the mapping if it was revoked). The mapping decides which certificate signs the depot's invoices. locationId is required and non-null; several depots may map to one Location. Un-mapping is done with PATCH .../revoke.

handlers: Sage100BranchMappingController.setMapping

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
branchId path
string
yes—Sage 100 F_DEPOT.DE_No — the source system's own identifier (1-100 chars, not a uuid).
locationId body
uuid
yes—Business Location whose certificate signs this depot's invoices.
branchName body
string
no—Depot display name at assignment time (max 255 chars), cached so the row stays labelled if the depot later disappears from the source.

Outputs

204
empty
Mapping stored.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
404
APIError
LOCATION_NOT_FOUND — the Location does not belong to this business.
422
APIError
VALIDATION_ERROR — schema violation.
PATCH/api/v1/businesses/:businessId/accounting/sage100/branch-mappings/:branchId/revoke auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Stop this Sage 100 depot routing invoices without deleting the mapping or its history. The depot's next invoice blocks (LOCATION_NOT_MAPPED) rather than falling back to the business default; already-fiscalised invoices are untouched. There is no un-revoke endpoint: re-assigning a location through PUT re-activates the mapping.

handlers: Sage100BranchMappingController.revokeMapping

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
branchId path
string
yes—Sage 100 F_DEPOT.DE_No — the source system's own identifier (1-100 chars, not a uuid).

Outputs

204
empty
Mapping revoked.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
404
APIError
LOCATION_NOT_FOUND — branch not found for this business.
422
APIError
VALIDATION_ERROR — schema violation.