Data exchange and synchronization
iTop exchanges data with people and external systems through CSV, XML, and web service flows. These flows either write objects at once or stage source data for a later synchronization run that reconciles source rows with iTop objects.
The page Integrations and automation gives the wider integration view. For request-level API details, see Web service APIs. For the task runner and operational alerts, see Background processing and notifications.
Exchange paths
Data transfer modes
Each mode serves a different point in the data life cycle. A direct bulk import changes iTop objects during the import. A synchronization import first records external rows in a source area, then a later execution applies those rows to destination objects.
| Mode | Main purpose | Result |
|---|---|---|
| Interactive CSV import | Let a user inspect, map, preview, and load tabular data | New, changed, or unchanged iTop objects with a row report |
| CSV bulk import web service | Let a script send rows for one iTop class | Direct bulk changes with summary or detail output |
| XML data loader | Load related object sets from XML | A transaction that commits only when the load passes its checks |
| Synchronization import | Receive rows for a configured synchronization data source | Source rows and replica status ready for synchronization |
| Bulk export | Select an object set with OQL or a saved query | A downloadable file or response in the selected format |
The common boundary is the iTop data model. Import paths validate class and field names against that model, while export paths use an object query to define the data set.
This diagram shows how direct loads differ from the staged synchronization path.
flowchart LR
A[CSV or XML input] --> B{Transfer mode}
B -->|Direct bulk load| C[Validate and map fields]
C --> D[Write iTop objects]
B -->|Synchronization load| E[Write source rows]
E --> F[Track source rows as replicas]
F --> G[Reconcile and update iTop objects]
H[OQL or saved query] --> I[Select object set]
I --> J[CSV XML spreadsheet or other export]
References: webservices/import.php• L59-152 webservices/export-v2.php• L71-101 webservices/backoffice.dataloader.php• L21-25 synchro/synchro_import.php• L53-80
CSV and bulk import
Interactive CSV import
The interactive CSV import is a guided path for data that needs human review. It accepts an uploaded file or pasted text, detects common separators and text qualifiers, lets the user choose the target class, maps columns, and runs a preview before the real load.
The mapping also selects search fields. Those fields form the reconciliation scheme that tells the import whether a row matches an existing object. A row can then create an object, update one, remain unchanged, or be rejected with an issue.
The wizard keeps the same input and mapping choices across its steps. It also supports date formats, character encodings, skipped lines, header handling, and a restricted synchronization scope when the user is updating a known set of objects.
References: pages/csvimport.php• L157-214 pages/csvimport.php• L241-251 pages/csvimport.php• L258-365 pages/csvimport.php• L608-682
CSV bulk import service
The CSV bulk import service is the script-friendly form of direct import. A caller supplies a class and CSV data through HTTP or a local file through the command line. The service accepts localized field labels or internal field codes and can use direct IDs, external keys, or related fields as reconciliation keys.
The service checks the caller's bulk-modify rights before it writes. A simulation produces the expected report without saving changes. A real load records one change entry and reports issues, warnings, creations, updates, and unchanged rows.
This path is not the same as synchronization import. It uses the bulk-change flow to write destination objects directly, so it does not create synchronization replicas or apply a synchronization data source's delete policy.
References: webservices/import.php• L223-278 webservices/import.php• L314-367 webservices/import.php• L433-509 webservices/import.php• L631-725
XML data loader
The XML data loader is intended for a set of related objects, such as data produced by an export or an installation step. It loads object IDs and values first, keeps links that refer to objects in the same load, and resolves those links when the session ends.
The back-office loader requires administrator access and wraps the session in a database transaction. In strict mode, both errors and warnings prevent the commit. This gives an all-or-nothing result for the load instead of leaving a partial object set in the database.
References: webservices/backoffice.dataloader.php• L36-41 webservices/backoffice.dataloader.php• L78-126 setup/xmldataloader.class.inc.php• L20-38 setup/xmldataloader.class.inc.php• L63-84 setup/xmldataloader.class.inc.php• L197-272 setup/xmldataloader.class.inc.php• L347-396
Bulk export
Export scope and formats
Bulk export starts with an OQL expression or a saved query from the query phrasebook. The selected object set is then rendered in a chosen format, such as CSV, XML, HTML, spreadsheet, or PDF when that format is available.
The export can run in the browser or from the command line. CSV output supports field selection, localization control, character encoding, text qualifiers, separators, date formats, and optional formatted text. The export layer reads the object set in chunks so that a large result can be produced without loading every row into one operation.
References: webservices/export-v2.php• L71-101 webservices/export-v2.php• L232-316 webservices/export-v2.php• L422-493 core/bulkexport.class.inc.php• L162-187 core/bulkexport.class.inc.php• L321-333 core/csvbulkexport.class.inc.php• L28-75 core/csvbulkexport.class.inc.php• L283-387
External synchronization sources
Synchronization data source
A synchronization data source defines how one external data set maps to one iTop target class. It names the source, identifies the target class, selects the fields to reconcile and update, and sets what happens when a source row matches zero, one, or many destination objects.
The source also defines how missing rows are handled. The policy can ignore them, delete their destination objects, mark them with an update, or update them first and delete them after a retention period. A source must have at least one reconciliation key when it does not use the source primary key.
The source has an owner and can name a contact for error notices. A source in the obsolete state cannot start a run. Its status view combines the latest run log with replica counts and the create, update, delete, and error results.
References: synchro/synchrodatasource.class.inc.php• L16-32 synchro/synchrodatasource.class.inc.php• L50-175 synchro/synchrodatasource.class.inc.php• L220-239 synchro/synchrodatasource.class.inc.php• L849-887 synchro/synchrodatasource.class.inc.php• L386-428
Source rows and replicas
A replica is the durable link between one source row and its destination object. It stores the source status, the destination class and ID when a match exists, the last seen time, and the last error or warning.
The source data area holds the values received from the external system. Database change tracking creates a replica when a source row arrives, marks it as changed when the row changes, and removes the replica when the source row is removed. This lets the execution phase process only rows that need work while still detecting rows that disappeared from a full load.
The main replica states describe the relationship rather than the health of the external system:
| State | Meaning |
|---|---|
new | The source row has no completed destination match |
synchronized | The source row and destination object are linked |
modified | A linked source row has new values to apply |
orphan | The linked destination object no longer exists |
obsolete | The source row is no longer current under the source's missing-row policy |
References: synchro/synchrodatasource.class.inc.php• L923-1014 synchro/synchrodatasource.class.inc.php• L1970-2058 synchro/synchrodatasource.class.inc.php• L2168-2213
Reconciliation and field policy
Reconciliation is the search for the destination object that represents a source row. A source can use the row's primary_key, or it can use one or more configured attributes. External keys can resolve by destination ID or by a selected attribute of the related object.
After a match is found, each configured field follows its update policy. A field can replace the destination value, write only when the destination is empty, or remain protected from the source. A missing source value means that the field is ignored, while an empty value can reset it when the field type supports that meaning.
The zero, one, and multiple match actions are separate choices. They allow a source to create on no match, update on one match, reject an ambiguous match, create another object, or take the first match according to its data contract.
References: synchro/synchrodatasource.class.inc.php• L114-165 synchro/synchrodatasource.class.inc.php• L1391-1449 synchro/synchrodatasource.class.inc.php• L2215-2357 synchro/synchrodatasource.class.inc.php• L2483-2531 synchro/synchrodatasource.class.inc.php• L2660-2744
Synchronization execution lifecycle
Import and execution phases
Synchronization separates receipt of external data from changes to iTop objects. The import phase writes the current source rows and records the load start time. The execution phase uses that time as the boundary for deciding which rows were seen in the load.
The combined import command can run both phases. Separate commands can load data first and execute one or more data sources later. The same source can therefore support an external producer that sends data on its own schedule and an operator or scheduler that applies it on another schedule.
This diagram shows the normal lifecycle of one synchronization run.
sequenceDiagram
participant S as External system
participant L as Synchronization import
participant R as Source rows and replicas
participant E as Synchronization execution
participant I as iTop objects
participant N as Notice and run history
S->>L: Send a complete or incremental CSV load
L->>R: Store source values and mark replicas
E->>R: Select current and missing replicas
E->>I: Reconcile, create, update, or remove objects
E->>R: Save replica state and errors
E->>N: Save run log and send error notice when needed
References: synchro/synchro_import.php• L299-330 synchro/synchro_import.php• L395-447 synchro/synchro_import.php• L633-673 synchro/synchrodatasource.class.inc.php• L3020-3032
Execution jobs
Each execution moves through three logical jobs. The jobs protect the order of operations: first classify rows that are no longer current, then apply current new or changed rows, and finally remove replicas that have remained obsolete for the configured retention period.
- Missing-row handling: Rows not seen since the full-load boundary are ignored, updated, marked obsolete, or deleted according to the source policy. A safety check can stop a run when it would make every replica appear missing.
- Object synchronization: New replicas are reconciled and can create or update objects. Modified replicas update their linked objects. Replicas with warnings are retried.
- Retention cleanup: With
update_then_delete, obsolete replicas pass the retention boundary before their destination objects and replica records are deleted.
An execution has a change record for its object changes and a synchronization log for its state, counts, dates, errors, and traces. A completed run can still contain row-level errors. A run that cannot start or that stops on an exception records the failure and can notify the configured contact.
References: synchro/synchrodatasource.class.inc.php• L3051-3111 synchro/synchrodatasource.class.inc.php• L3235-3308 synchro/synchrodatasource.class.inc.php• L3443-3567 synchro/synchrodatasource.class.inc.php• L3570-3659 synchro/synchrodatasource.class.inc.php• L3661-3748
Scheduled and chunked runs
The synchronization entry points are designed for a scheduler to call through HTTP or the command line. synchro_import.php can load and execute one data source, while synchro_exec.php can execute a comma-separated set of sources. A deployment can therefore schedule data receipt and object application as separate tasks.
Large runs can use a maximum replica count per worker. The parent execution stores the current job and replica position in the synchronization log, starts a worker for one chunk, and starts the next worker when the prior worker returns continue. The last worker returns finished, after which the run is closed as completed or error.
The general cron service records task start and end times, prevents two cron loops from running at once, and computes the next planned run for registered background processes. The synchronization scripts still own their source-specific load and execution contract.
References: synchro/synchro_exec.php• L39-49 synchro/synchro_exec.php• L129-180 synchro/synchrodatasource.class.inc.php• L3323-3385 synchro/synchrodatasource.class.inc.php• L3405-3441 synchro/priv_sync_chunk.php• L72-109 webservices/cron.php• L88-167 webservices/cron.php• L187-291
Run results and operator actions
The run log gives both a high-level result and counts by outcome. Operators can inspect the latest run, open replicas with errors or warnings, view traces when enabled, and retry or unlink an individual replica.
Unlinking removes the destination association and returns the replica to new. A later synchronization can then reconcile it again. A manual replica synchronization applies the same source rules to one row without requiring a full source run.
References: synchro/synchrodatasource.class.inc.php• L398-428 synchro/synchrodatasource.class.inc.php• L624-662 synchro/synchrodatasource.class.inc.php• L2403-2468 synchro/replica.php• L39-109 synchro/synchrodatasource.class.inc.php• L1823-1867
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to CSV field names, localization, or reconciliation rules must stay aligned between the interactive mapping, the CSV service, and generated CSV templates.
- Changes to a synchronization target class must be checked against its source field rules, external-key rules, source data columns, and replica change tracking.
- Changes to missing-row or retention policy must be checked against the full-load boundary and the safety check that prevents an accidental delete of all destinations.
- Changes to chunk execution must preserve the shared log fields for current job and position, plus the worker's final
continueorfinishedresponse. - Changes to synchronization result counters or statuses must stay aligned between the run log, the data-source status view, replica searches, and error notices.
- Changes to export formats or options must preserve both the command-line parameters and the interactive form state used for chunked output.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A source row has no valid reconciliation key | The row cannot be matched and may become a reconciliation error | Require at least one configured key and validate it before the run |
| Reconciliation matches several destination objects | The source cannot identify one safe destination; the result follows the multiple-match policy | Use unique source keys and keep ambiguous matches as errors unless the data contract allows another action |
| A full load is incomplete or a load boundary is wrong | Current destinations can look missing and become obsolete or deleted | Use a complete load, set the full-load interval correctly, and keep the prevent-delete-all safeguard enabled |
| An external key does not resolve to one related object | The destination field can be reset, skipped, or recorded with a warning depending on the value and field rule | Reconcile related objects with a unique key and inspect replica warnings |
| A source has no update field or no reconciliation field | The synchronization cannot start | Validate the data-source definition before scheduling it |
| A strict XML load has an error or warning | The transaction rolls back and no loaded objects remain | Review the loader report and correct the source before retrying |
| A chunk worker does not return the expected completion marker | The parent cannot know whether to start another chunk or close the run | Keep the worker output contract and inspect the run log when a process fails |
Key files
| File | Why to read it |
|---|---|
| pages/csvimport.php | Follow the user-facing CSV wizard from input through preview and final load. |
| pages/ajax.csvimport.php | See how the wizard previews data, builds field mappings, and creates CSV templates. |
| webservices/import.php | Understand direct CSV bulk import, reconciliation keys, simulation, and result reporting. |
| webservices/backoffice.dataloader.php | See the administrator-only XML load transaction and strict commit rule. |
| setup/xmldataloader.class.inc.php | Understand the high-level XML object and link load lifecycle. |
| webservices/export-v2.php | Follow query selection, format selection, and browser or CLI export entry points. |
| core/bulkexport.class.inc.php | Understand the shared export contract and chunk state. |
| core/csvbulkexport.class.inc.php | See the CSV format options and row output behavior. |
| synchro/synchrodatasource.class.inc.php | Read the synchronization source, replica, run log, and execution model in one place. |
| synchro/synchro_import.php | Follow the CSV-to-source-row synchronization import path. |
| synchro/synchro_exec.php | Follow standalone execution for one or more data sources. |
| synchro/priv_sync_chunk.php | Understand the worker boundary used for large synchronization runs. |
| synchro/replica.php | See the operator view and manual actions for individual replicas. |
| webservices/cron.php | Understand the general scheduler loop that runs registered background tasks. |