Welcome to docs|Multi-tenancy|Working with tenant data

Working with tenant data

This page describes how to work with tenant-scoped data in Serialized.

To operate on data (aggregates, projections, reactions) in a multi-tenant project, the client application must indicate to Serialized which tenant is the target. The tenant ID is used as the unique identifier for the tenant and is used to route the request to the correct data store.

Some of the most important operations that are tenant-scoped are:

Making a tenant-scoped operation

To make a tenant-scoped operation, the client application must include the tenant ID in the request.

If, for example, you have a tenant with ID 13a1addc-1d81-4425-af84-50b1b960880a you can write an OrderPlaced event to an order aggregate with ID 5df2e445-99bb-4e19-9d82-f2ace1b2eee6 for that tenant using the example code below.

var eventBatch = List.of(newEvent(new OrderPlaced()).build());    var request = saveRequest()      .withTenantId("13a1addc-1d81-4425-af84-50b1b960880a")      .withAggregateId("5df2e445-99bb-4e19-9d82-f2ace1b2eee6")      .withEvents(eventBatch)      .build();
const event = {  eventType: 'OrderPlaced'}const request = {  tenantId: '"13a1addc-1d81-4425-af84-50b1b960880a"',  aggregateId: '"5df2e445-99bb-4e19-9d82-f2ace1b2eee6"',  events: [event]}await;

All the clients in our SDKs provide similar options for making tenant-scoped operations. See the SDK documentation for more details for each operation.

If you're using the Serialized API without our SDKs, you should include the tenant ID as a header with name Serialized-Tenant-Id.

Data processing in multi-tenant projects

Some data processing, such as projection processing and reaction scheduling and triggering is automatically performed in Serialized. In a multi-tenant project, this processing is performed for each tenant separately.

All definitions, such as (projection definitions and reaction definitions) are shared between tenants in the same project. This means that if you update a projection definition, all tenants in that project will be affected.