Pipelines across a Tenant Subtree
A pipeline is registered in one tenant and, by default, reads and writes only that tenant. A group of companies often needs more: the companies use master data that the group maintains, they send documents to each other, and the group consolidates the figures of all companies. For this, a few data nodes can reach another tenant of the same subtree — the parent, a sibling or a child of the pipeline's tenant.
This page describes which tenants a pipeline may reach, which identity it needs there, how a refusal looks, a complete example for a group with two companies, and the contract of the one-way master-data sync.
Related pages:
- Tenant Topology API — how parent and child tenants are registered.
- Tenant Authorization and Tenant Generations — why a token is valid for one tenant only.
- Cross-Tenant Authentication — how a user of a parent tenant gets roles in a child.
- Cross-Tenant Access for Sibling Tenants — how a sibling tenant permits and grants access.
- Tenant Lifecycle — detaching and deleting tenants.
- Child tenants (User Guide) — managing child tenants in the UI.
- Service Accounts — the identity a pipeline uses when it runs on its own.
The rule
A pipeline registered in tenant T reads or writes another tenant U only when
- U is in the relation the node names, computed from the platform's tenant registry when the pipeline runs, and
- the identity the node runs as holds the needed rights in U, proven by the identity service with a token issued for U and evaluated with U's own roles.
Otherwise the node fails with the error
CROSS_TENANT_FORBIDDENand no data of U is read or written. The system identity is never accepted for another tenant. A node without a target-tenant setting works exactly as before.
Both conditions are needed. The relation limits where a pipeline may go; the right in the target decides whether it may go there. Roles never travel from one tenant to another: role names are the same in every tenant, so the adapter never uses a role of T to access U. It uses only the roles that U's administrator gave to the identity in U.
Allowed relations
The relation is always written in the node; data can never widen it. For a group G with the companies A and B:
| Relation | The target is | Example | Tenant id |
|---|---|---|---|
Parent | the parent of the pipeline's tenant | A reads from G | none (there is exactly one parent) |
Sibling | another child of the same parent | A writes into B | tenantId, or tenantIdPath for an id from the data (only with identity: Caller) |
Child | a direct child of the pipeline's tenant | G reads from A | tenantId, or tenantIdPath for an id from the data (only with identity: Caller) |
Always refused:
- the system tenant, as source or as target; two top-level tenants (children of the system tenant) are no siblings;
- the parent's parent and every tenant further up, nephews and cousins, and every descendant below a direct child (grandchildren);
- tenants that are not registered, also a detached child whose database still exists;
- the pipeline's own tenant through the cross-tenant setting (the own tenant is the default without the setting).
A tenant id from the data context (tenantIdPath) is allowed only for a node that runs as a verified caller
(identity: Caller in a pipeline that a signed-in user starts). It is then checked exactly like a configured one, and
the caller's own right in the chosen tenant is proven. A node that runs as the service account or as the system context
never takes its target from data: it names it in the configuration (tenantId, a tenantIds list, or targetTenants
without a list for all registered direct children). Otherwise the data would choose the tenant the service account acts
in. Ids are trimmed and compared case-insensitively.
Identity and grants
Each data node runs as an identity (identity of the node). For another tenant, the identity service must issue a
token for the target tenant, and only the roles of that token are used there.
| Node identity | How the right in the target is proven | What the target's administrator provisions |
|---|---|---|
Caller with a signed-in user | The caller's token is exchanged for a token of the target tenant (OAuth 2.0 token exchange). The user acts in the target as its cross-tenant user and gets only the roles provisioned there. | Child target: a mapping of the parent-tenant user (Cross-Tenant Authentication). Parent or Sibling target: the source tenant permits the target and the target grants the user (Cross-Tenant Access for Sibling Tenants). |
Caller without a user (schedule, watch and event triggers) | Falls back to the pipeline's service account, see the next row. | as for ServiceAccount |
ServiceAccount | The service account's token of T is exchanged for a token of the target tenant. | A shadow client xt_{T}_{clientId} in the target (for example xt_companya_crm-sync for client crm-sync of companya) with the roles it needs there. It must be a public client without a secret, with the token exchange as its only grant, without redirect URIs and without offline access, and it needs the scope octo_api; for a Parent or Sibling target the source tenant must also permit the target. A client mirrored from a parent tenant is refused. How to create it: see Provisioning the shadow client. |
System | none | Always refused for another tenant — when the pipeline is deployed and when it runs. |
The fallback Caller → ServiceAccount → System stops before the system identity for every access to another tenant.
A pipeline that should reach another tenant on a schedule or on a change of data therefore needs a service account.
The proof also checks the tenant generation: when a tenant is deleted and created again under the same id, a token of the old tenant is refused (see Tenant Authorization and Tenant Generations). Proofs are kept for one pipeline execution only and are never written into the data context or the log.
When the pipeline is deployed, the communication controller refuses identity: System on a node with a target
setting, and it refuses every data-driven target (tenantIdPath, whatever it reads) on a node that runs as the service
account or the system context. A Caller node with tenantIdPath deploys with a warning. When it runs, the adapter
accepts the path only if the trigger verified a signed-in caller (for example FromHttpRequest@2 without
allowAnonymous) and proves that caller's own right in the chosen tenant; a Caller node without a caller (schedule,
watch or event trigger) would fall back to the service account and is refused.
Provisioning the shadow client
The shadow client is created by an administrator of the target tenant with the CK method createClient of the
type System.Identity/Client. The method needs a token issued for the target tenant: an octosystem or parent-tenant
token is refused (METHOD_FORBIDDEN, tenant-not-allowed). The client forms of the user interface and the octo-cli
Add*Client commands cannot set the token-exchange grant.
With octo-cli, GraphQl -tid <target> exchanges the token of the current context for one of the target tenant
(the user must have access to the target):
mutation {
runtime {
systemIdentityClients {
createClient(input: {
clientId: "xt_companya_octo-pipeline-sa-670000000000000000000002"
clientName: "Shadow of the companya pipeline service account"
enabled: true
allowedGrantTypes: ["urn:ietf:params:oauth:grant-type:token-exchange"]
requireClientSecret: false
allowOfflineAccess: false
allowedScopes: ["octo_api"]
}) { invocationId result }
}
}
}
octo-cli -c GraphQl -tid companyb -f create-shadow-client.graphql
Then give the client the roles it needs in the target, for example
AddClientToRole -id xt_companya_octo-pipeline-sa-670000000000000000000002 -r Development in a context of the target
tenant. The client id of a pipeline's service account is in the System.Communication/ServiceAccountConfiguration of
the source tenant (octo-pipeline-sa-<adapter rtId> by default). Without the scope octo_api the exchange is refused
and the node fails with CROSS_TENANT_FORBIDDEN; the reason (identity_not_provable) is written to the adapter log
only.
Node settings
| Node | Setting | Meaning |
|---|---|---|
GetRtEntitiesByType@1, GetRtEntitiesById@1, GetRtEntitiesByWellKnownName@1 | targetTenant | read from one other tenant |
GetRtEntitiesByType@1, GetRtEntitiesById@1 | targetTenants | read from several child tenants (consolidation) |
ApplyChanges@2 | targetTenant | write into one other tenant |
ApplyChanges@2 | targetTenants | one-way master-data sync into the child tenants |
ApplyChanges@1 and every other node | none | the setting is unknown there and the pipeline is refused when it is loaded |
targetTenant takes relation (Parent, Sibling or Child) and, for Sibling and Child, either tenantId or
tenantIdPath. A Parent with an id, a Sibling or Child without one, and both tenantId and tenantIdPath are
configuration errors.
targetTenants takes relation: Child (the only relation for a set of tenants) and an optional tenantIds list.
Without the list, the targets are the registered direct children of the pipeline's tenant when the pipeline runs; a
child created a few seconds ago can be missing for up to 30 seconds. Each target, listed or not, is checked like a
single Child target. The read nodes also take onRefused:
Fail(default): one refused tenant fails the execution withCROSS_TENANT_FORBIDDEN, the message names every refused tenant, and nothing of any tenant is read;Report: the allowed tenants are read, the refused ones are listed inRefusedTenantsof the result and none of their data is returned. The identitySystemand a configuration error fail also withReport.
targetTenant and targetTenants cannot be combined in one node.
Errors
| Code | When |
|---|---|
CROSS_TENANT_FORBIDDEN | The target is outside the relation, not registered, refused by the identity service, of an older generation, or the identity is System. For security, "not registered", "outside the relation" and "no right" give the same message; the reason is written to the adapter log only. |
CROSS_TENANT_WRITE_FAILED | A write into another tenant failed after the target was opened: a validation error of the target with targetTenant, or, with targetTenants, one or more failed targets. The message names every failed target with its code and the targets that were written. |
SYNC_OWNED_ENTITY | Someone other than the sync tried to change, delete or mark synced master data, or the sync met an entity under the same id that it does not own. |
A write into another tenant also refuses what needs a method run of the entity's type: attributes that only a CK method
may write, inserts of a type whose method replaces the generic create, and identity data. An association whose end is
neither inserted by the same batch nor present in the target is refused with CROSS_TENANT_FORBIDDEN.
Example: a group with two companies
The group tenant group has the companies companya and companyb as children. The CK types are examples
(Acme.Accounting, Acme.Crm); use the types of your own model.
Grants used in the example:
- the users of
companyawho call pipeline 1 have a grant ingroup(sibling and parent grants: the source tenant permits the target); - the users of
companyawho release invoices (pipeline 2) have a grant incompanybwith a role that may create incoming documents, andcompanyapermitscompanyb; - each company has the shadow client
xt_group_<client id>of the group's service account with a role that may write contacts; - the controller of
groupis mapped into both companies with a role that may read invoices.
1. A company reads master data of the group
An HTTP pipeline of companya returns the chart of accounts that the group maintains. The node runs as the caller, so
the user sees exactly what their grant in group allows.
triggers:
- type: FromHttpRequest@2
method: GET
path: /group-accounts
transformations:
- type: GetRtEntitiesByType@1
ckTypeId: Acme.Accounting/Account
identity: Caller
targetTenant:
relation: Parent
targetPath: $.accounts
2. An inter-company document
When companya releases an invoice to companyb, a pipeline of companya creates an incoming document in
companyb. The addressee comes from the invoice (tenantIdPath), and the pipeline checks it like a configured id.
Because the target comes from data, the write runs as the user who releases the invoice (identity: Caller): the
adapter proves that user's own right in companyb. A service-account node could only name companyb statically
(tenantId: companyb); with tenantIdPath its deploy is refused.
triggers:
- type: FromHttpRequest@2
method: POST
path: /release-invoice
transformations:
- type: GetRtEntitiesByType@1
ckTypeId: Acme.Accounting/InterCompanyInvoice
targetPath: $.invoice
fieldFilters:
- attributePath: InvoiceNumber
operator: Equals
comparisonValuePath: $.body.invoiceNumber
- attributePath: InvoiceStatus
operator: Equals
comparisonValue: Released
- type: CreateUpdateInfo@1
targetPath: $._inserts
targetValueKind: Array
updateKind: INSERT
ckTypeId: Acme.Accounting/IncomingDocument
generateRtId: true
attributeUpdates:
- attributeName: InvoiceNumber
attributeValueType: String
valuePath: $.invoice.Items[0].Attributes.InvoiceNumber
- attributeName: SourceInvoiceRtId
attributeValueType: String
valuePath: $.invoice.Items[0].RtId
- type: ApplyChanges@2
entityUpdatesPath: $._inserts
identity: Caller
targetTenant:
relation: Sibling
tenantIdPath: $.invoice.Items[0].Attributes.RecipientTenantId
The target is opened before anything is checked or written, also in a dry run. The batch is checked with the CK model
of companyb and written in one transaction there.
3. The contact sync
The group maintains contacts once and syncs them one way into every company. The pipeline runs in group, triggered
by changes of the group's own contacts. A watch trigger has no caller, so the write runs as the service account.
A deletion in the group reaches the watch in two forms: the default delete archives the entity (an update event
whose $.Document.RtState is 1), an erase removes it (a delete event with $.UpdateType 8, which the trigger
delivers only with includeDeletes: true). Both delete the copies; every other event creates or updates them. Enum
values are numbers in the data context.
triggers:
- type: FromWatchRtEntity@1
ckTypeId: Acme.Crm/Contact
updateTypes: All
includeDeletes: true
transformations:
- type: If@1 # erased in the group
path: $.UpdateType
operator: Equals
valueType: Integer
value: 8
transformations:
- type: CreateUpdateInfo@1
targetPath: $._erased
targetValueKind: Array
updateKind: DELETE
ckTypeId: Acme.Crm/Contact
rtIdPath: $.DocumentRtId
- type: ApplyChanges@2
identity: ServiceAccount
entityUpdatesPath: $._erased
targetTenants:
relation: Child
- type: If@1 # archived in the group (default delete)
path: $.Document.RtState
operator: Equals
valueType: Integer
value: 1
transformations:
- type: CreateUpdateInfo@1
targetPath: $._archived
targetValueKind: Array
updateKind: DELETE
ckTypeId: Acme.Crm/Contact
rtIdPath: $.DocumentRtId
- type: ApplyChanges@2
identity: ServiceAccount
entityUpdatesPath: $._archived
targetTenants:
relation: Child
- type: If@1 # created or changed: create or update the copies
path: $.UpdateType
operator: NotEquals
valueType: Integer
value: 8
transformations:
- type: If@1
path: $.Document.RtState
operator: NotEquals
valueType: Integer
value: 1
transformations:
- type: CreateUpdateInfo@1
targetPath: $._sync
targetValueKind: Array
updateKind: UPDATE
ckTypeId: Acme.Crm/Contact
rtIdPath: $.DocumentRtId
attributeUpdates:
- attributeName: Name
attributeValueType: String
valuePath: $.Document.Attributes.Name
- type: ApplyChanges@2
identity: ServiceAccount
entityUpdatesPath: $._sync
targetTenants:
relation: Child
The watch on erased entities needs the contact type to be the root of its collection (a type derived directly from
System/Entity) or a collection that keeps the state before a change (pre-images); otherwise the trigger does not
start. In a company, the copies cannot be changed or deleted locally: they change in the group and reach the company
with the next sync.
With targetTenants, ApplyChanges@2 does not support association updates, onDuplicateKey: Report, record array
item updates or clearing secrets; such a configuration fails before any target is opened.
4. The consolidation
The controller of the group wants the invoice totals of every company in one place. The consolidation pipeline runs in
group, reads all companies in one node and sums up with ordinary transform nodes.
triggers:
- type: FromHttpRequest@2
method: GET
path: /consolidation
transformations:
- type: GetRtEntitiesByType@1
ckTypeId: Acme.Accounting/Invoice
identity: Caller # the controller; use ServiceAccount for a scheduled run
targetTenants:
relation: Child
tenantIds: [companya, companyb] # optional; without it every direct child
onRefused: Fail
targetPath: $.invoices
- type: SumAggregation@1
targetPath: $.figures.companya
aggregations:
- path: $.invoices.Items[*]
filterPath: $.SourceTenantId
comparisonValue: companya
aggregationPath: $.Attributes.InvoiceAmount
value: 1
- type: SumAggregation@1
targetPath: $.figures.companyb
aggregations:
- path: $.invoices.Items[*]
filterPath: $.SourceTenantId
comparisonValue: companyb
aggregationPath: $.Attributes.InvoiceAmount
value: 1
- type: SumAggregation@1
targetPath: $.figures.total
aggregations:
- path: $.invoices.Items[*]
aggregationPath: $.Attributes.InvoiceAmount
value: 1
The result of a read with targetTenants names the tenant of every item:
{
"Items": [ { "RtId": "...", "Attributes": { "InvoiceAmount": 100.0 }, "SourceTenantId": "companya" } ],
"TotalCount": 3,
"Tenants": [ { "TenantId": "companya", "TotalCount": 2 }, { "TenantId": "companyb", "TotalCount": 1 } ],
"RefusedTenants": [ ]
}
Paging (skip, take), filters and sort orders apply per tenant. RefusedTenants is filled only with
onRefused: Report; it lists the tenant id and CROSS_TENANT_FORBIDDEN, never the reason.
The asset repository's GraphQL API does not offer such a read on purpose: a GraphQL request is answered only from the tenant in its URL, and only tokens of that tenant are accepted. The pipeline keeps this boundary: it reads in the adapter, with a right proven in every company, and only the figures it builds leave it.
Sync trigger and writer contract
The contact sync above is the first writer of a one-way master-data sync. Every further target writer reuses the same contract — the first reuse is the sync into an external PostgreSQL database.
Trigger
- The sync pipeline runs in the source tenant and is triggered by changes of the source tenant's own entities
(
FromWatchRtEntity@1). A trigger never watches another tenant. - A deletion arrives as an update event of an archived entity (
$.Document.RtState1) or, withincludeDeletes: true, as a delete event ($.UpdateType8, the id at$.DocumentRtId). Both must delete the copy. - A watch trigger has no caller, so the writer runs as the pipeline's service account; its right is proven in every target.
Idempotency key and owner marker
- The key of a copy is source tenant + source RtId. The copy keeps the source RtId.
- Every copy carries the owner marker, the System record
SyncOrigin(attributeRtSyncOrigin, from System 2.10.0):SourceTenantId,SourceRtIdandSyncedAt. The writer sets it itself, with the pipeline's tenant as the source, and ignores any origin in the input, so a sync can never claim another source. - Per entity the writer decides by the key: no copy → create it; a copy of this source → update it; a delete → delete the copy (nothing to do when it is gone). Running the same change twice leaves exactly one copy.
Ownership rules
- The writer touches only its own copies. An entity under the same id without a marker, or with the marker of
another source, refuses the whole target with
SYNC_OWNED_ENTITY; nothing of that target is written. - In the target, nobody else may set the marker or change, delete or archive a copy: the platform refuses it for every
writer (GraphQL, REST, every pipeline node, bots, also system sessions) with
SYNC_OWNED_ENTITY. The data is changed in the source and reaches the target with the next sync. - Associations of a local entity to a copy are allowed.
Failure semantics
- Every target is opened and checked on its own (relation, right of the identity, generation) and written in its own transaction.
- A refused or failed target does not stop the others. After the last target, the execution fails with
CROSS_TENANT_WRITE_FAILED; the message names every failed target with a stable code (CROSS_TENANT_FORBIDDEN,SYNC_OWNED_ENTITY,ATTRIBUTE_WRITE_RESTRICTED,VALIDATION_FAILED,WRITE_CONFLICT,WRITE_FAILED) and the targets that were written. A message never contains a value of the data. - A dry run writes nothing and lists per target the planned creates, updates and deletes.
What a new target writer implements
A writer for another kind of target (another tenant, an external database, a file) provides:
- Target resolution and admission — the list of targets and, for each, a check that the pipeline may write there before anything is written; a refusal is a failed target, never a silent skip.
- Lookup by key — find the stored copy by source tenant + source RtId.
- The owner marker — store source tenant, source RtId and sync time with every copy, set by the writer only.
- Create, update and delete by key — the plan per entity as above, idempotent for repeated changes.
- Ownership check — refuse a target that holds an entry under the key without this source's marker
(
SYNC_OWNED_ENTITY), and leave entries without a marker untouched. - One transaction per target — all changes of a target in one transaction, or none.
- Failure report — go on with the other targets and fail the execution at the end with
CROSS_TENANT_WRITE_FAILED, naming each failed target with its stable code. - Dry run — the plan per target without writing.
Known limitations
- A detached or removed group leaves its copies locked in the company: they can no longer be changed or deleted, and no sync comes. The way out is an export and import of the data.
- The import of runtime data, blueprint seed data, a restore and CK model or blueprint migration scripts are not covered by the ownership rules; the next sync of a changed source entity overwrites the copy.
- An update or delete by filter (GraphQL or REST) skips copies without an error instead of refusing them.