Skip to main content
Version: v1 (Current)

Entity Sync Implementation Reference

Use this guide when extending outbound workflow sync. The shared pipeline lives in the platform repository under app/Services/Sync/; it is not a standalone public integration API. Start with Sync architecture for current registrations and execution behavior.

Choose the integration boundary​

Current registered combinations are Eventfinity attendees; Cvent attendees, agenda items, enrollments and speakers; and Google Drive social-stream posts. Choose the builder for the intended entity and operation. A provider's inbound import, webhook or specialized push service can have a different entry point and recovery path from outbound workflow sync.

For an additional entity on an existing provider, inspect that provider's context and transport before reusing them. For a new provider, plan changes to all of the following:

  1. A service/entity builder and its registry entry in AppServiceProvider.
  2. A remote adapter and the provider-specific RemoteServiceInterface container binding.
  3. SyncEntityJob transport selection and service-context construction.
  4. Supported workflow action configuration, validation and scoped integration-token selection.
  5. Source-integration identity, execution records, retry/rate-limit behavior and any replay mechanism.

The existing workflow action has explicit service branches. Registering a builder does not automatically add a workflow UI choice, token type or executable transport.

Implement the builder contract​

Implement App\Services\Sync\Contracts\SyncBuilder. Its 12 methods divide responsibility as follows:

ResponsibilityMethodsImplementation requirement
Entity identity and lookupgetEntityType, getEntityClass, findEntityUse the registry's entity key and enforce the supplied project boundary during lookup.
Operation gatesupportsOperationExplicitly accept supported enum values; recognizing an enum value does not establish provider support.
Request constructionbuildRequestPlanProduce endpoint, method, payload, attachment and skip metadata from the supplied context.
DiscoveryresolveRemoteIdentifier, applyDiscoveryResultsDefine match criteria and zero/multiple-result behavior; return a new plan with discovered identity.
Endpoint and response identitydetermineEndpoint, extractRemoteIdentifierFromResponse, getRemoteIdFieldNameFollow the provider's actual route and response schema. An update need not append an ID to its endpoint.
Local completionpersistRemoteIdentifier, bustEntityCacheSave the supported identity destination and source marker, then invalidate the relevant cache.

Copy exact parameter and return types from the interface in the platform checkout. A partial class with only request construction is not an implementation of this contract.

SyncContext contains the workflow, step, configured operation and SyncContextDTO. The DTO carries the entity, entity type, changes, source event/integration and requested timestamp. Define which change keys your builder accepts and what an empty change set means. The shared DTO does not turn an empty list into a full sync.

Construct a request plan​

This minimal fragment illustrates the DTO constructor for a hypothetical provider; records/upsert and its schema must be replaced by that provider's contract. It is not an additional registered integration.

use App\Services\Sync\DTOs\SyncRequestPlan;
use App\Workflows\Enums\SyncOperation;

$plan = new SyncRequestPlan(
operation: SyncOperation::UPSERT,
endpoint: 'records/upsert',
httpMethod: 'POST',
payload: ['external_reference' => 'example-local-reference'],
remoteFields: ['external_reference'],
);

Add a discovery plan only when the operation requires a missing remote identifier and the builder has a supported lookup strategy. discoveryRequired() treats null and the empty string as missing, but not numeric zero. The job later persists only a truthy resolved ID; choose and validate provider identifiers rather than relying on those different gates.

Set shouldSkip and a meaningful supported skipReason for intentional skips. A skip should not masquerade as a successful remote write. Keep remoteFields aligned with the fields actually sent after filtering and transformation, including attachments and mandatory identity fields.

For files, construct SyncFileAttachment with field, contents, optional filename/headers and provider-specific multipart name. Set sendAsMultipart only when the adapter implements the required envelope. Readonly DTO properties do not freeze a model, retain an open stream across serialization or rewind it for retry. Build and consume attachments through the chosen provider's supported lifecycle.

Implement transport and context​

RemoteServiceInterface declares two methods:

public function search(string $entityType, array $criteria, array $context): array;
public function performSync(SyncRequestPlan $plan, array $context): mixed;

The adapter owns authentication, serialization, request execution and provider-response interpretation. The interface supplies no common response envelope, automatic endpoint suffix or universal retry behavior. Surface rate-limit conditions using App\Services\Sync\Exceptions\RateLimitException with a delay in seconds so the job can release with that delay (at least one second). Terminal builder failures use Workflow\Exceptions\NonRetryableException; classify them deliberately; arbitrary exceptions use the job's retry path.

Current job context construction supplies Eventfinity's required event ID from legacy_event_id or eventfinity_event_id; Cvent's nonempty cvent_event_id and admission_item_id; or Google Drive's token ID and optional token-metadata folder ID. A nonempty member idempotency key is added separately. A new adapter cannot assume these keys include its own configuration.

Credentials remain in the configured integration token/server environment. Enforce workflow/team/project/action scope through the supported entry point. Registry lookup and request-plan construction are not authorization checks. Never include credentials or full attendee payloads in examples or diagnostic logs.

Persist identity and prevent loops​

Define the local destination and provider source marker before sending. For Eventfinity attendees, the remote Event Attendee ID maps to third_party_id; its persistence implementation rejects other destinations. That restriction is provider-specific, not permission to choose arbitrary destinations in another builder.

Discovery should reject ambiguous matches rather than silently selecting an attendee by display name. Reconcile a discovered identity with the intended project and provider entity before changing local data. Follow the source-integration/event conventions so writing a returned identifier does not immediately trigger a sync back to the same provider.

The remote write and local identity save are separate operations. A remote success followed by a local exception leaves an uncertain local state and can be retried. Supply provider-supported upsert, idempotency or reconciliation behavior for that boundary. Manifest cursors alone do not prevent duplicates after a fan-out crash. A member key is passed in context and used by job overlap middleware when present; an adapter still needs to honor the intended remote replay contract. Keyless requests do not acquire that member lock.

Verify the integration​

Use isolated fixtures and a fake provider transport first. Test the actual builder and adapter behavior, then validate a controlled deployment before enabling a large population.

CaseEvidence to retain
Registry and dispatchCorrect service/entity resolves; unsupported combinations and operations fail or skip as designed.
AuthorizationAllowed token/project works; cross-team/project and denied action paths are rejected before a remote request.
MappingReal changed-field keys, nested paths, null/false/zero values and mandatory identity fields produce the expected request.
DiscoveryMissing criteria, no match, unique match, multiple matches and malformed/missing remote IDs have explicit outcomes.
AttachmentsExact multipart names/envelope, missing storage object, failed download and retry stream handling match the provider.
Response and persistenceProvider response identity is parsed; identity/source/cache update correctly; local failure after remote success can be reconciled.
Retry and replayRate limits, transient/terminal errors, duplicate jobs and crash/restart boundaries do not silently create untracked remote effects.
Batch settlementSkips, partial failures, cancellation and mid-flight errors retain accurate invocation and per-entity outcomes.

A fake request proves serialization and local handling within its scope; it does not prove remote authorization, distributed-worker behavior or deployed acceptance. Record those separately.

Troubleshoot a sync extension​

For an unknown builder, check the exact service/entity registry key and application binding. For an unsupported service, check both job transport/context selection and workflow action validation. For skipped work, inspect the recorded reason and the builder's operation/change-data rules before retrying.

For discovery failures, inspect mapping and uniqueness using appropriately redacted diagnostics. For remote success with a failed local record, reconcile provider identity before replay. For a batch that completed with failures, inspect individual sync records rather than treating the next workflow step as proof that every request succeeded.

Use Third-party integration configuration and Admin Workflows for supported setup and operator surfaces. Provider credentials and detailed production recovery stay in configured services and private operator runbooks.