Documentation
Getting Started
Data Grid
Modeling
Business Rules
Approvals
Users, Roles & Security
Administration
Installation
Migrating from MDS
Architecture
Documentation/Integration & API/Staging API Reference

Staging API Reference

Technical reference for the staging endpoints. Every path is prefixed with /api/staging and requires an authenticated administrator session.

These endpoints drive the staging screens. They are not part of the public /api/v1/ surface described in REST API, which is the one to use for ordinary record reads and writes with an API key.

Writing rows into a stg table is done in SQL, not over HTTP. These endpoints configure staging, start batches and report on them.

Configuration endpoints

Get staging configuration

GET /api/staging/:entityId/config

FieldTypeDescription
configuration.tableNamestringThe staging table name, for example stg.Currency
configuration.defaultImportActionstringDefault import action
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[].isRequiredbooleanRequired attribute — onValidationError is fixed at error_row
fieldRules[].mergeModestringOverride merge mode. auto inherits the default
fieldRules[].onValidationErrorstringerror_row or skip_field

Merge mode values are overwrite, overwrite_all, fill_empty, ignore and overwrite_with_sentinel.

Save staging configuration

PUT /api/staging/:entityId/config

Body fields, all optional: defaultImportAction, defaultMergeMode, sentinelText, sentinelNumber, sentinelDateTime, fieldRules.

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.

Get staging drift

GET /api/staging/drift

Query parameter entityId is optional — omit it to check every staging-enabled entity at once. Only entities with drift are returned, so an empty array means nothing is out of sync.

FieldTypeDescription
entityIdintegerEntity id
entityNamestringEntity name
modelIdintegerParent model id
modelNamestringParent model name
tableNamestringStaging table name
tableMissingbooleantrue when the stg table no longer exists
severitystringerror (a missing column) or warning (orphans only)
missingColumns[]array of stringAttributes with no matching staging column
orphanColumns[]array of stringStaging columns with no matching attribute

Rebuild staging table

POST /api/staging/:entityId/rebuild

Adds missing columns and drops orphan columns so the table matches the entity's attributes. Staged rows are kept — only the values in dropped columns are lost.

Returns columnsAdded, columnsDropped and tableName.

Data endpoints

Get staged rows

GET /api/staging/:entityId/rows

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

The response carries three parts:

  1. rows[] — the staged rows, with every system and attribute column
  2. summaryTotalRows, ReadyRows, OkRows, ErrorRows, ProcessingRows
  3. columns[] — attribute metadata: attributeId, name, displayName, dataType, sortOrder

Process a batch

POST /api/staging/:entityId/process

Body: batchTag (optional label) and batchId (optional, to reprocess a specific batch).

Returns batchId, status, totalRows, successRows, errorRows and skippedRows.

Retry failed rows

POST /api/staging/:entityId/retry

Puts failed rows back in the queue as Ready, clearing each row's error and detaching it from the batch it failed in. Body: batchId (optional) scopes it to one batch; without it every failed row for the entity is requeued.

Returns requeuedRows.

Recover a stuck batch

POST /api/staging/:entityId/recover

Releases rows left claimed by a batch that never finished, and closes the dead batch as Failed. Body: staleMinutes (default 60) sets how old a claim must be to count as stuck.

Returns recoveredBatches and releasedRows.

Clear rows

DELETE /api/staging/:entityId/rows?status=processed

Deletes finished rows across every batch for the entity. status accepts processed (the default) or all.

DELETE /api/staging/batches/:batchId/clear?status=processed does the same for one batch.

Both return deletedRows.

Batch history endpoints

Get batches

GET /api/staging/:entityId/batches

Query parameters pageSize (default 50) and page (default 1). Returns batches[] and totalCount.

Get batch errors

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

Query parameters pageSize (default 100) and page (default 1). Returns errors[] with row-level detail, and summary with aggregate counts.

Clear batch history

DELETE /api/staging/:entityId/history

Removes all completed and failed batch records for the entity, with their staging rows and error details. Running and queued batches are kept. Returns deletedBatches.

Scheduler endpoints

Get scheduler configuration

GET /api/staging/:entityId/scheduler

Returns the configuration plus live runtime fields: isRunning, pendingRows, oldestRowAge, nextScheduledRun, lastCompletedAt.

Save scheduler configuration

PUT /api/staging/:entityId/scheduler

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

Validation is enforced server-side:

  • scheduled requires scheduleType
  • triggered requires at least one trigger
  • manual clears every schedule and trigger field

Get scheduler log

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

Query parameters pageSize (default 50) and page (default 1). Returns log[] and totalCount.

Test the scheduler

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

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

FieldTypeDescription
wouldFirebooleanWhether a batch would fire
reasonstringWhy it would or would not
pendingRowsintegerUnprocessed rows
oldestRowAgeintegerAge of the oldest unprocessed row, in minutes
nextScheduledRundatetimeNext scheduled execution

Database tables

TableContents
StagingConfigurationsPer-entity import action, merge mode and sentinel values. One row per staging-enabled entity
StagingFieldRulesPer-attribute merge mode and error handling
StagingBatchesBatch history: one row per processing run, with status, counts and timing
SchedulerConfigurationsPer-entity processing mode, schedule, triggers and runtime state
SchedulerLogEvery scheduler event — fired, skipped, completed, error

Stored procedures

ProcedureDescription
usp_Staging_CreateTableCreates the staging table in the stg schema
usp_Staging_DropTableDrops the staging table and its configuration
usp_Staging_GetConfigurationReturns configuration and field rules
usp_Staging_SaveConfigurationSaves configuration and field rules
usp_Staging_GetStagedRowsPaginated staged rows with a status filter
usp_Staging_ProcessBatchThe batch processing engine
usp_Staging_GetBatchesPaginated batch history
usp_Staging_GetErrorsRow-level errors for a batch
usp_Staging_RetryErrorsRequeues failed rows as Ready
usp_Staging_RecoverStuckReleases rows held by a batch that never finished
usp_Staging_ClearRowsDeletes rows by status across every batch
usp_Staging_ClearBatchDeletes rows from one batch
usp_Staging_ClearBatchHistoryClears completed batch records
usp_Staging_GetDriftCompares staging tables against entity attributes
usp_Staging_RebuildTableSyncs staging columns with entity attributes
usp_Scheduler_GetConfigScheduler configuration with live stats
usp_Scheduler_SaveConfigSaves scheduler configuration
usp_Scheduler_GetLogPaginated scheduler event log
usp_Scheduler_TestRunDry-run evaluation of current conditions
usp_Scheduler_CalculateNextRunCalculates the next scheduled execution
usp_Scheduler_DispatchThe dispatcher, called every 60 seconds by SQL Agent

Ready to get started?

Start managing your master data with Primentra today.

View Pricing
Staging API Reference | Integration & API | Docs | Primentra