Documentation
Getting Started
Installation
Data Grid
Approvals
Administration
Account & Security
Integration & Staging
Architecture
Documentation/Integration & Staging/Staging API Reference

Staging API Reference

Technical reference for the staging REST API. All endpoints are prefixed with /api/staging and require authentication.

Approval workflows and staging

The staging pipeline writes directly to master data and does not go through the approval workflow, even if the entity has Requires approval enabled. This applies to both scheduled and manually triggered batch processing. Staging is treated as a trusted, pre-validated data channel — the assumption is that validation happens in the source system before rows are written to the staging table.


Configuration endpoints

Get staging configuration

GET /api/staging/:entityId/config

Returns the staging configuration and field rules for an entity.

Response:

FieldTypeDescription
configuration.tableNamestringThe staging table name (e.g. stg.Currency)
configuration.defaultImportActionstringDefault import action code
configuration.defaultMergeModestringDefault merge mode
configuration.sentinelTextstringText sentinel value
configuration.sentinelNumberstringNumber sentinel value
configuration.sentinelDateTimestringDateTime sentinel value
fieldRules[]arrayPer-attribute merge and error rules
fieldRules[].attributeNamestringAttribute name
fieldRules[].mergeModestringOverride merge mode (null = inherit default)
fieldRules[].onValidationErrorstringErrorRow or SkipField

Save staging configuration

PUT /api/staging/:entityId/config

Request body:

FieldTypeRequired
defaultImportActionstringNo
defaultMergeModestringNo
sentinelTextstringNo
sentinelNumberstringNo
sentinelDateTimestringNo
fieldRulesarrayNo

Enable staging

POST /api/staging/:entityId/enable

Creates the staging table in the stg schema and initializes the configuration record. Returns the new configuration.

Disable staging

DELETE /api/staging/:entityId/disable

Drops the staging table and removes the configuration. Batch history is preserved.

Rebuild staging table

POST /api/staging/:entityId/rebuild

Adds missing columns and removes orphan columns to match the current entity attributes. Returns a list of changes made.


Data endpoints

Get staged rows

GET /api/staging/:entityId/rows

Query parameters:

ParameterTypeDefaultDescription
importStatusinteger(all)Filter by ImportStatus (0=Ready, 1=OK, 2=Error)
batchIdinteger(all)Filter by batch ID
pageSizeinteger50Rows per page
pageinteger1Page number

Response: Three result sets:

  1. rows[] — the staged data rows with all system and attribute columns
  2. summary — counts by status: TotalRows, ReadyRows, OkRows, ErrorRows, ProcessingRows
  3. columns[] — attribute metadata: attributeId, name, displayName, dataType, sortOrder

Process a batch

POST /api/staging/:entityId/process

Request body:

FieldTypeRequiredDescription
batchTagstringNoOptional label for the batch
batchIdintegerNoProcess a specific batch (re-process)

Response:

FieldTypeDescription
batchIdintegerThe batch ID
statusstringFinal status
totalRowsintegerTotal rows processed
successRowsintegerRows processed successfully
errorRowsintegerRows that failed
skippedRowsintegerRows skipped

Clear batch rows

DELETE /api/staging/batches/:batchId/clear?status=processed

Deletes staging rows from a specific batch. The status parameter filters which rows to delete (all or processed).


Batch history endpoints

Get batches

GET /api/staging/:entityId/batches

Query parameters: pageSize (default 50), page (default 1).

Response: batches[] array with batch metadata, and totalCount.

Get batch errors

GET /api/staging/batches/:batchId/errors

Query parameters: pageSize (default 100), page (default 1).

Response: errors[] array with row-level error details, and summary with aggregate counts.

Clear batch history

DELETE /api/staging/:entityId/history

Removes all completed and failed batch records for the entity, including their staging rows and error details. Running and queued batches are preserved.


Scheduler endpoints

Get scheduler configuration

GET /api/staging/:entityId/scheduler

Returns the scheduler config with live runtime status fields: isRunning, pendingRows, oldestRowAge, nextScheduledRun, lastCompletedAt.

Save scheduler configuration

PUT /api/staging/:entityId/scheduler

Request body:

FieldTypeDescription
processingModestringmanual, scheduled, or triggered
scheduleTypestringinterval, daily, weekly, or monthly (required when mode is scheduled)
intervalMinutesintegerInterval in minutes (for interval type)
runTimesstringComma-separated times, e.g. 06:00,18:00
runDaysstringComma-separated days, e.g. Mon,Wed,Fri
runDaysOfMonthstringComma-separated days, e.g. 1,15
triggerOnNewRowsbooleanEnable new-rows trigger
triggerRowThresholdintegerRow count threshold
triggerIdleMinutesintegerIdle timeout in minutes
triggerDebounceSecondsintegerDebounce window (default 60)
isEnabledbooleanEnable/disable the scheduler

Validation (enforced server-side):

  • Mode scheduled requires scheduleType to be set
  • Mode triggered requires at least one trigger to be configured
  • Mode manual clears all schedule and trigger fields

Get scheduler log

GET /api/staging/:entityId/scheduler/log

Query parameters: pageSize (default 50), page (default 1).

Response: log[] array of scheduler events, and totalCount.

Test scheduler (dry run)

POST /api/staging/:entityId/scheduler/test

Evaluates current conditions without firing a batch. Returns what the dispatcher would do right now.

Response:

FieldTypeDescription
wouldFirebooleanWhether the scheduler would fire a batch
reasonstringExplanation of why it would or would not fire
pendingRowsintegerCurrent number of unprocessed rows
oldestRowAgeintegerAge of the oldest unprocessed row in minutes
nextScheduledRundatetimeNext scheduled execution time

Database tables

StagingConfigurations

Stores per-entity staging configuration (import action, merge mode, sentinel values). One row per entity with staging enabled.

StagingBatches

Stores batch processing history. Each row represents one processing run with status, row counts, and timing.

SchedulerConfigurations

Stores per-entity scheduler configuration (processing mode, schedule settings, trigger settings, runtime state). One row per entity.

SchedulerLog

Audit log of all scheduler events (fired, skipped, completed, error). Used for troubleshooting and monitoring.


Stored procedures

ProcedureDescription
usp_Staging_CreateTableCreates the staging table in the stg schema
usp_Staging_DropTableDrops the staging table and configuration
usp_Staging_GetConfigurationReturns config + field rules
usp_Staging_SaveConfigurationSaves config and field rules
usp_Staging_GetStagedRowsReturns paginated staged rows with status filter
usp_Staging_ProcessBatchCore batch processing engine
usp_Staging_GetBatchesReturns paginated batch history
usp_Staging_GetErrorsReturns row-level errors for a batch
usp_Staging_ClearBatchDeletes rows from a specific batch
usp_Staging_ClearBatchHistoryClears completed batch records
usp_Staging_RebuildTableSyncs staging table columns with entity attributes
usp_Scheduler_GetConfigReturns scheduler config with live stats
usp_Scheduler_SaveConfigSaves scheduler configuration
usp_Scheduler_GetLogReturns paginated scheduler event log
usp_Scheduler_TestRunDry-run evaluation of current conditions
usp_Scheduler_CalculateNextRunCalculates next scheduled execution time
usp_Scheduler_DispatchThe dispatcher — called every 60s by SQL Agent

Ready to get started?

Start managing your master data with Primentra today.

View Pricing