Skip to content

Control plane client

The client gives typed, lower-level access to the platform’s HTTP API. Use it for reads, ad-hoc management and anything the attribute sync in Permissions does not cover. It authenticates with a service account (client_credentials), fetches and caches the token for you, and refreshes it before expiry.

The FlowCatalyst facade resolves FlowCatalyst\Client\FlowCatalystClient from the container, configured from config/flowcatalyst.php (base_url, client_id, client_secret, http.*).

use FlowCatalyst\Facades\FlowCatalyst;
$result = FlowCatalyst::eventTypes()->list();
foreach ($result->items as $eventType) {
echo $eventType->code . ': ' . $eventType->name . PHP_EOL;
}

To act as a signed-in user, build a client with that user’s token (a string or a closure that returns one):

use FlowCatalyst\Client\FlowCatalystClient;
$client = FlowCatalystClient::withUserToken(
token: fn () => $accessToken,
baseUrl: config('flowcatalyst.base_url'),
);

request(string $method, string $endpoint, array $options = []): array sends any call the typed resources do not wrap, and generated() returns the code-generated client that covers the whole OpenAPI surface (used for portal users and field workers).

Accessor Notes
eventTypes() list, get, getByCode, create, update, addSchemaVersion, archive, sync
subscriptions() list, get, create, update, delete, pause, resume, sync
connections() list, get, create, update, delete, pause, activate, sync
dispatchPools() list, get, create, update, delete, archive, suspend, activate, sync
dispatchJobs() batch, create
roles() list, get, getByCode, create, update, grantPermission, revokePermission, delete, sync
permissions() Read the permission catalogue
applications() get, getByCode, listRoles (not deprecated); management methods under admin()
clients() list, get, getByIdentifier, getRaw, getByIdentifierRaw (not deprecated); the rest under admin()
principals() setClientAssociation (not deprecated); the rest under admin()
scheduledJobs() CRUD, pause, resume, archive, fire, instance and log methods, sync
processes() list, get, getByCode, create, update, archive, delete, sync
ingestions(), ingestionSets() See below
platformConfig() See below
emailDomainMappings() getByDomain
auditLogs() list, get
me() getClients, getClient, getClientApplications
fieldWorkers(), fieldDevices(), fieldPolicies(), fieldTokens() Field
definitions() The DefinitionSynchronizer
use FlowCatalyst\DTOs\Requests\{AddSchemaVersionRequest, CreateEventTypeRequest};
$id = FlowCatalyst::eventTypes()->create(new CreateEventTypeRequest(
code: 'order:fulfillment:order:created',
name: 'Order Created',
description: 'Fired when a new order is placed',
));
FlowCatalyst::eventTypes()->addSchemaVersion($id, new AddSchemaVersionRequest(
schema: ['type' => 'object', 'properties' => ['orderId' => ['type' => 'string']]],
version: '1.0',
));

create returns the new id. Schemas are documentation for consumers; the platform does not enforce them at ingest.

use FlowCatalyst\DTOs\EventTypeBinding;
use FlowCatalyst\DTOs\Requests\CreateSubscriptionRequest;
use FlowCatalyst\Enums\DispatchMode;
$subscriptionId = FlowCatalyst::subscriptions()->create(new CreateSubscriptionRequest(
code: 'notify-warehouse',
name: 'Notify Warehouse',
endpoint: 'https://warehouse.example.com/webhook',
eventTypes: [new EventTypeBinding('order:fulfillment:order:created')],
dispatchPoolId: $poolId,
mode: DispatchMode::IMMEDIATE,
timeoutSeconds: 30,
maxRetries: 5,
));
FlowCatalyst::subscriptions()->pause($subscriptionId);
FlowCatalyst::subscriptions()->resume($subscriptionId);

The request also takes description, clientId, connectionId, serviceAccountId and dataOnly. DispatchMode has IMMEDIATE, NEXT_ON_ERROR and BLOCK_ON_ERROR; with BLOCK_ON_ERROR the group is per subscriber and stays blocked until resolved. See Ordering.

use FlowCatalyst\DTOs\Requests\CreateDispatchPoolRequest;
$poolId = FlowCatalyst::dispatchPools()->create(new CreateDispatchPoolRequest(
code: 'warehouse-webhooks',
name: 'Warehouse Webhooks',
rateLimit: 100, // requests per minute
concurrency: 10,
));
FlowCatalyst::dispatchPools()->suspend($poolId);
FlowCatalyst::dispatchPools()->activate($poolId);

See Pools.

$roles = FlowCatalyst::roles()->list();
$role = FlowCatalyst::roles()->get('myapp:admin'); // includes its permissions
$perms = FlowCatalyst::permissions()->list();

To declare roles, prefer the attribute sync.

dispatchJobs()->batch(array $jobs) calls POST /api/dispatch-jobs/batch directly (without the outbox) and returns one DispatchJobResult per job in order (id, status, error, isSuccess()). create($job) returns the job id or throws FlowCatalystException on the item’s error. Both take CreateDispatchJobDto, the same object the outbox uses. Prefer the outbox when the job must commit with a database change. See Dispatch jobs.

User, client and application management lives under admin():

use FlowCatalyst\DTOs\Requests\{CreateApplicationRequest, CreateClientRequest};
FlowCatalyst::admin()->principals()->findByEmail($email);
FlowCatalyst::admin()->principals()->addRole($principalId, 'myapp:editor');
FlowCatalyst::admin()->clients()->create(new CreateClientRequest(identifier: 'acme', name: 'Acme'));
FlowCatalyst::admin()->applications()->create(new CreateApplicationRequest(
code: 'myapp', name: 'My Application', description: 'My application',
));
FlowCatalyst::admin()->applications()->listClients($applicationId);
FlowCatalyst::admin()->router()->inPipelineBatch($messageIds);

Calling the same methods through the old accessors (principals(), clients(), applications(), router()) still works but raises one E_USER_DEPRECATED per method per process. The methods listed as not deprecated in the table above, every sync* method, outbox, dispatch-job creation, auth, request() and the constructor options are unaffected.

admin()->principals() covers createUser, update, activate, deactivate, role and client-access methods, and resetPassword. See Users and roles. setClientAssociation($principalId, $clientId, $mode) changes a user’s scope (anchor only): '*' means anchor, and a client id needs mode CHANGE_CLIENT or TO_PARTNER.

$row = FlowCatalyst::platformConfig()->get('rfp', 'mail', 'from');
$row = FlowCatalyst::platformConfig()->set('rfp', 'mail', 'from', 'a@b.c'); // PLAIN by default
FlowCatalyst::platformConfig()->delete('rfp', 'mail', 'from'); // idempotent
$rows = FlowCatalyst::platformConfig()->list('rfp');

SECRET properties come back from get() and list() as the literal *** for every caller. The only way to read plaintext is the audited reveal call:

$secret = FlowCatalyst::platformConfig()->revealSecret('rfp', 'mail', 'smtp_password');
$secret->value; // plaintext; var_dump, json_encode and toArray() show "***"

Reveal needs platform:admin:config:reveal (platform administrators) or platform:application-service:config:reveal (an application’s service account, confined to its own applications and linked clients). Failures: 403 not authorised, 404 no such property, 400 NOT_A_SECRET, all as FlowCatalystException. Writing *** or an empty value to a SECRET is refused (SECRET_VALUE_MASKED, SECRET_VALUE_REQUIRED); to keep a secret, do not set it.

set, delete and revealSecret take onBehalfOf: (sent as X-On-Behalf-Of, recorded in the audit row, service accounts only, at most 256 printable characters):

FlowCatalyst::platformConfig()->set('rfp', 'mail', 'from', 'a@b.c', onBehalfOf: $user->email);

See Platform config and Configuration and secrets.

use FlowCatalyst\DTOs\Ingestion\{IngestionDefinition, IngestionSource, IngestionSplit, IngestionTarget};
$definition = new IngestionDefinition(
name: 'Orders drop',
source: new IngestionSource(IngestionSource::SFTP, [/* host, directory, credential: ['name' => 'sftp-password'] */]),
split: IngestionSplit::csv(header: true),
target: new IngestionTarget('order', 'https://app.example.com/hook', pool: 'default',
mode: IngestionTarget::MODE_NEXT_ON_ERROR, batchSize: 10),
);
$ing = FlowCatalyst::ingestions()->create('edi', 'acme', 'orders', $definition);
FlowCatalyst::ingestions()->update($ing->id, $definition, expectedVersion: $ing->version);

An ingestion has an INTEGRATION application (by code) and a client (id or identifier). Secrets are referenced by name, never passed as values. Without the promote permission a create or update saves a draft ($ing->save->outcome is DRAFT) rather than failing; someone with promote calls makeVersionLive($id, $version). Other outcomes are SAVED, MADE_LIVE, DRAFT_EXISTS and UNCHANGED. $ing->warnings lists what will not run as meant (for example an SFTP source with neither knownHosts nor acceptAnyHostKey).

failures($id, category: 'rejected', undismissed: true) lists notices, dismissFailure marks one handled, secrets($id) shows which secret names the live definition binds and each runtime’s last fetch (never a value), and ingestionSets()->apply($name, $items, dryRun: true) plans a set apply without writing. See Ingestion and Definitions and sets.

clients()->getRaw($id) and getByIdentifierRaw($identifier) return the platform’s body as it is. get() fills a missing status with ACTIVE. emailDomainMappings()->getByDomain('example.com') throws a 404 FlowCatalystException when the domain is unmapped.

All failures derive from FlowCatalyst\Exceptions\FlowCatalystException, which carries getCode() (the HTTP status) and getContext().

Status Exception
401 AuthenticationException (tokenExpired; credential problems use invalidCredentials, tokenFetchFailed, missingConfiguration)
403, 404 FlowCatalystException
422 ValidationException, with getErrors()
other 4xx, 5xx FlowCatalystException with the platform’s message or error
use FlowCatalyst\Exceptions\{AuthenticationException, FlowCatalystException, ValidationException};
try {
FlowCatalyst::eventTypes()->create($request);
} catch (AuthenticationException $e) {
// bad credentials or expired token
} catch (ValidationException $e) {
$errors = $e->getErrors();
} catch (FlowCatalystException $e) {
$status = $e->getCode();
$context = $e->getContext();
}

Retries: a request is repeatable when its method is GET, HEAD, OPTIONS, PUT or DELETE, or when the SDK marks the POST repeatable (the declarative syncs, and a dispatch-job batch whose every job has an idempotency key). Up to http.retry_attempts attempts are made in all, with a delay of http.retry_delay milliseconds times the attempt number.

  • HTTP 408 and 429, and a connection that was never made (host not resolved, refused, TLS handshake failed), are retried for every request.
  • HTTP 502, 503 and 504, and a transport failure after the request may have been sent (reset, empty reply, timeout), are retried only for a repeatable request. For any other request the client throws FlowCatalyst\Exceptions\OutcomeUnknownException at once and does not send it again: the platform may have applied it. A repeated provisioning is refused with 409 and its one-time secrets are lost, and a repeated create can make a duplicate. Read the state first (after a provisioning, FlowCatalyst::admin()->applications()->getServiceAccount($id)). The exception extends FlowCatalystException, so existing catches still work; getCode() is the gateway’s status, or 0 after a transport failure, whose exception is getPrevious().
  • A DELETE that answers 404 on a retry after an attempt whose outcome was unknown succeeds.
  • Everything else, including 500, is thrown on the first attempt.

Redirects preserve the request method, so a POST is never silently turned into a GET. The platform’s error shapes are in Errors.

FlowCatalystClient builds its own HTTP client internally, so tests substitute the whole client: mock FlowCatalystClient (the SDK’s own tests do this with PHPUnit’s mock builder) and bind it in the container so FlowCatalyst:: calls hit the mock. See Testing for the SDK’s other helpers.