This project is a commercetools Connect-hosted event proxy for teams that already run their business logic outside Connect.
It creates and manages a commercetools Subscription (in postDeploy), receives events through the Connect-managed queue/topic delivery pipeline, and forwards each event to an external API (for example, a webhook receiver in Vercel).
Use this connector when:
- your core logic lives in an existing monorepo or API outside commercetools Connect
- you still want commercetools events (
messagesand/orchanges) delivered reliably - you want Connect to host only the thin forwarding layer
The Express event app does not contain domain business logic. Its job is to transform and forward events.
postDeploycreates/updates a commercetools Subscription that points to Connect-managed messaging infrastructure.- commercetools publishes matching events to that destination.
- The Connect event app (
/event) receives the queued message. - The app forwards the payload to
API_ENDPOINTwith HMAC headers. - The app response controls queue acknowledgement and retries.
The proxy performs a single forward attempt per delivery attempt.
- Retryable downstream failures (
429,5xx, transport/network failures) return non-2xx from the app, so Connect/GCP retries. - Non-retryable downstream
4xxresponses are acknowledged to avoid retry storms. - Incoming Pub/Sub HTTP envelopes are accepted up to 1 MB; larger requests return
413.
This keeps retry ownership in the queue layer instead of in-process retry loops.
Each deployment must provide SUBSCRIPTION_SUFFIX.
The connector builds the final subscription key as:
ct-event-proxy-subscription-<SUBSCRIPTION_SUFFIX>
Why: this prevents multiple deployments in the same commercetools project from overwriting each other's subscription.
Example suffixes:
dev-adev-bstagingprod
connect.yaml declares inheritAs.apiClient.scopes: [manage_subscriptions].
Connect creates the runtime API Client and injects its credentials into the
application and deployment hooks. Installers do not create, copy or retain this
client's ID or secret. The management client that installs the Connector needs
manage_api_clients:{projectKey} in addition to its Connect deployment permission.
The generated runtime client only needs:
manage_subscriptions:{projectKey}
Defined in connect.yaml.
Standard configuration:
API_ENDPOINT(required): external webhook/API URL to receive forwarded eventsSUBSCRIPTION_SUFFIX(required): unique suffix per deployment in the same projectSUBSCRIPTION_CONFIG(optional): JSON formessagesandchangesfiltersADDITIONAL_HEADERS(optional): JSON headers appended to outbound webhook request
Secured configuration supplied by the installer:
WEBHOOK_SECRET(required): used for HMAC signature headers on forwarded requests
Connect supplies CTP_API_URL, CTP_AUTH_URL, CTP_PROJECT_KEY,
CTP_CLIENT_ID, CTP_CLIENT_SECRET and CTP_SCOPE. Do not declare or supply
these as installation configuration. The application uses the injected API/auth
URLs, so no region setting is needed.
The receiver must use the same webhook secret as this installation. When changing
the endpoint or event selection, redeploy the existing installation and run its
postDeploy hook. The hook updates the existing Subscription; changing message
types does not require another runtime client.
From event/:
For local execution outside Connect, fill event/.env using the fields in
event/.env.example. Connect supplies the commerce fields in hosted deployments.
nvm install
nvm use
corepack enable
yarn install --frozen-lockfile
yarn build
yarn test
yarn test:smoke
yarn start:devyarn test:smoke builds the application and tests it over real local HTTP
connections with a local webhook receiver and dummy credentials. It checks event
forwarding, HMAC signatures, additional headers, and retry/acknowledgement
responses without contacting commercetools or an external webhook.
postDeploycreates/updates only this deployment's subscription key.preUndeploydeletes only this deployment's subscription key.- If you deploy the connector more than once to the same project, always use different
SUBSCRIPTION_SUFFIXvalues.