Skip to content

Declarations

An application owns roles, event types, connections, subscriptions, dispatch pools, service users, processes, scheduled jobs, an OpenAPI document and documentation pages on the platform. The Java SDK lets you declare them in code and sync them with one call, so a deploy leaves the platform matching the code. The workflow is in sync definitions; this page is the Java API.

var set = Definitions.DefinitionSet.define("orders")
.withEventTypes(List.of(
Definitions.EventType.of("orders:sales:order:placed", "Order Placed")))
.withRoles(List.of(Definitions.Role.of("admin")
.withPermissions(List.of(Definitions.Permission.of("sales", "order", "manage")))))
.withConnections(List.of(Definitions.Connection.of("billing-hook", "Billing Webhook")))
.withSubscriptions(List.of(Definitions.Subscription.of(
"order-placed", "Order Placed", "https://billing.example.com/hook",
List.of(Definitions.SubscriptionEventType.of("orders:sales:order:placed")))
.withConnectionCode("billing-hook")));
client.definitions().sync(set, SyncOptions.removingUnlisted());

DefinitionSet.define(code) starts a set for one application. defineFromEnv() reads the code from FLOWCATALYST_APP_CODE and throws IllegalStateException if it is unset or blank. There is no per-definition application override: the set a definition is built into is its application, so a codebase that owns several applications builds one set each.

Category Builder Notes
Roles Role.of(name): withDisplayName, withDescription, withPermissions(List<PermissionRef>), withClientManaged(bool) name is short (admin); the platform stores it as orders:admin. Do not add the prefix. A Permission.of(context, aggregate, action) takes the set’s application as its first segment (override with withApplication); PermissionRef.raw("orders:sales:order:view") passes an already-formatted string. Permissions are lower-cased.
Event types EventType.of(code, name): withDescription The code is the full {app}:{subdomain}:{aggregate}:{event}; its first segment must be the application being synced. Schemas are not synced; attach them through the console or eventTypes().addSchemaVersion(...).
Connections Connection.of(code, name): withDescription, withExternalId, withClient No credentials: the platform assigns the application’s own service account.
Subscriptions Subscription.of(code, name, target, eventTypes) and with* methods See below.
Dispatch pools DispatchPool.of(code, name): withConcurrency, withRateLimit, withoutRateLimit, withDescription Pools are platform-wide, matched by code, and each sync sets every field: an omitted rate limit removes an existing limit and an omitted concurrency becomes 10. removeUnlisted on pools archives every other pool and needs an anchor credential. Rate limit and concurrency must be at least 1.
Principals Principal.of(email, name): withRoles, withActive, withPasswordHash Roles are full names, orders:admin; the platform does not add a prefix. A name that is not a role is reported in skippedRoles(); another application’s role refuses the whole sync (403 ROLE_APP_FORBIDDEN). A passwordHash (bcrypt, argon2i, argon2id) is stored only for a user the sync creates; ignored ones come back in passwordHashIgnored().
Processes Process.of(code, name): withBody, withDiagramType, withTags, withDescription Documentation only.
Scheduled jobs ScheduledJob.of(code, name, crons) and with* Crons are six fields, seconds first; a five-field cron is rejected. withClientId scopes the job to one client; platform-wide jobs are anchor-only.
Docs Doc.of(slug, markdown): withTitle Slug [a-z0-9][a-z0-9-]*. Each sync replaces the application’s whole page set (at most 100 pages, 4 MB; 512 KB per page).
OpenAPI set.withOpenapiSpec(Map<String,Object>) One document, the application’s current version.
Push rules set.withPush(PushDefinition) See Outbox.
Method Meaning
withConnectionCode(code) Deliver through one of this application’s connections, by code. Codes are stable across environments; prefer it to an id.
withSharedConnection(true) With withConnectionCode, name a shared (application-less) connection instead. The two namespaces never fall back to one another.
withConnectionId(id) By connection id. Ids differ per environment.
withDispatchPoolCode, withMode(SubscriptionMode) The pool, and IMMEDIATE, NEXT_ON_ERROR or BLOCK_ON_ERROR. A mode you set is applied on create and on update, so it overwrites a console change at the next sync; left out, the stored mode is kept. An unknown value is refused with INVALID_MODE.
withMaxRetries, withTimeoutSeconds, withDataOnly Delivery behaviour.
withClient(client) Route this one row to a client scope; wins over the set’s client.

Connections sync before subscriptions in the same run, so a subscription may name a connection the same sync just created.

Annotations are an alternative to builders, with explicit registration. There is no classpath scanning: you list the classes.

@AsEventType(code = "orders:sales:order:placed", name = "Order Placed")
public record OrderPlaced(String orderId) {}
@AsConnection(code = "billing-hook", name = "Billing Webhook")
final class BillingConnection {}
@AsSubscription(code = "order-placed", name = "Order Placed",
target = "https://billing.example.com/hook",
connectionCode = "billing-hook",
eventTypes = {"orders:sales:order:placed"})
final class OrderPlacedHandler {}
var set = DefinitionScanner.scan("orders",
List.of(OrderPlaced.class, BillingConnection.class, OrderPlacedHandler.class));
client.definitions().sync(set);

The annotations are @AsEventType, @AsConnection, @AsSubscription, @AsDispatchPool and @AsRole (with a permissions array of formatted strings). @AsSubscription.dataOnly defaults to true, unlike a builder-made Subscription, which leaves it to the platform. A third argument to DefinitionScanner.scan(code, classes, defaultClient) gives connections and subscriptions that name no client a default; use it for a single-tenant application only.

client.definitions() is the DefinitionSynchronizer.

Method Does
sync(set), sync(set, options) One application’s set.
syncAll(sets, options) Several sets, in order. Sets are not merged.
syncGrouped(sets), syncGrouped(sets, options) Merges every set that shares an application, then makes one call per (application, client) scope: global first, then each client in first-seen order. Returns a map keyed by application.

Each call runs the categories in dependency order: roles, event types, connections and subscriptions, dispatch pools, principals, processes, scheduled jobs, OpenAPI, docs, push. An empty category is skipped.

SyncOptions.defaults() syncs everything and leaves removeUnlisted false. SyncOptions.removingUnlisted() asks the platform to remove SDK-sourced rows the set no longer lists; rows made in the console are never touched. options.skipping(SyncCategory...) force-skips categories (ROLES, EVENT_TYPES, CONNECTIONS, SUBSCRIPTIONS, DISPATCH_POOLS, PRINCIPALS, PROCESSES, SCHEDULED_JOBS, OPENAPI, DOCS, PUSH), for staging a rollout. Docs and push are declarative full replacements, so removeUnlisted does not apply to them.

Do not use syncAll for sets that share an application and a client scope under removeUnlisted. The second call would remove what the first just created. Use syncGrouped.

SyncResult has one Category per area: Synced (created, updated, deleted, syncedCodes, skippedRoles, passwordHashIgnored), Skipped, or Failed. Connections and subscriptions report Failed for a duplicate code within one scope or an HTTP failure; a failed connection sync skips the same scope’s subscription sync without stopping any other scope or application.

sync, syncAll and syncGrouped throw DefinitionSyncException (a FlowCatalystException carrying SdkError.PartialFailure) if any category failed. The exception carries what did sync, so a deploy step can log the partial outcome instead of treating “no exception” as success:

try {
client.definitions().sync(set, SyncOptions.removingUnlisted());
} catch (DefinitionSyncException e) {
log.error("definition sync had failures: {}", e.getMessage());
if (e.result().connections() instanceof SyncResult.Category.Synced synced) {
log.info("connections DID sync: {} created", synced.created());
}
throw e;
}

e.result() is for sync, e.results() for syncAll, and e.resultsByApplication() for syncGrouped. syncAll and syncGrouped run every set to completion before throwing once. A network failure from a category that does not catch its own errors still propagates immediately.

Scope a set’s connections and subscriptions to one client with .forClient(clientIdOrIdentifier). Use the identifier slug. A single row can override with withClient(...).

var acme = Definitions.DefinitionSet.define("orders").forClient("acme")
.withConnections(List.of(Definitions.Connection.of("hook", "Acme Hook")));
var beta = Definitions.DefinitionSet.define("orders").forClient("beta")
.withConnections(List.of(Definitions.Connection.of("hook", "Beta Hook")));
Map<String, SyncResult> results = client.definitions().syncGrouped(List.of(acme, beta));

A subscription’s target may be a path (/webhooks/orders), resolved at sync time against a base URL, so one definition works in every environment. An absolute target is always sent verbatim. The base comes from, in order: the set’s forClient(client, targetBaseUrl), then the client’s subscriptionTargetBaseUrl(...) builder option. A path with no base anywhere fails that subscription’s sync locally, naming it, rather than being dropped silently; under removeUnlisted a dropped subscription would otherwise be deleted.

var client = FlowCatalystClient.builder()
.baseUrl("https://platform.example.com")
.clientCredentials(id, secret)
.subscriptionTargetBaseUrl("https://api.myapp.com")
.build();
var tenantSet = Definitions.DefinitionSet.define("orders")
.forClient("acme", "https://acme.myapp.com") // this tenant's own host
.withSubscriptions(List.of(Definitions.Subscription.of(
"order-placed", "Order Placed", "/webhooks/orders",
List.of(Definitions.SubscriptionEventType.of("orders:sales:order:placed")))
.withConnectionCode("billing-hook")));