Subscriptions for Messages and Notifications
Subscriptions allow you to be notified of new messages or changes via a message queue of your choice.
Subscriptions are used to trigger an asynchronous background process in response to an event on commercetools Composable Commerce. Common use cases include sending an order confirmation email, charging a credit card after a delivery has been made, or synchronizing customer accounts to a Customer Relationship Management (CRM) system.
As payload, a Subscription delivers one of the predefined Messages or a notification about a change to a resource.
A maximum of 50 Subscriptions can be created per Project. When you create, update, or delete Subscriptions, it may take upto a minute for the changes to update. For more information, see Eventual Consistency.
This document explains the creation of a Subscription, the payload, and delivery guarantees.
Representations
Subscription
idString | Unique identifier of the Subscription. |
versionInt | Current version of the Subscription. |
keyString | User-defined unique identifier of the Subscription. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
changesArray of ChangeSubscription | Change notifications subscribed to. |
destination | Messaging service to which the messages are to be sent. |
messagesArray of MessageSubscription | Messages subscribed to. |
format | Format in which the payload is delivered. |
status | Status of the Subscription. |
createdAt | Date and time (UTC) the Subscription was initially created. |
createdByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
lastModifiedAt | Date and time (UTC) the Subscription was last modified. |
lastModifiedByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
SubscriptionDraft
Either messages or changes must be set.
keyString | User-defined unique identifier for the Subscription. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
changesArray of ChangeSubscription | Change notifications to be subscribed to. |
destination | Messaging service to which the messages are sent. |
messagesArray of MessageSubscription | Messages to be subscribed to. |
format | Format in which the payload is delivered. When not provided, the PlatformFormat is selected by default. |
{"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"key" : "test-queue"}
SubscriptionPagedQueryResponse
PagedQueryResult with results containing an array of Subscription.
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
countInt | Actual number of results returned. |
totalInt | Total number of results matching the query.
This number is an estimation that is not strongly consistent.
This field is returned by default.
For improved performance, calculating this field can be deactivated by using the query parameter |
resultsArray of Subscription | Subscriptions matching the query. |
{"limit" : 20,"offset" : 0,"count" : 1,"total" : 1,"results" : [ {"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"} ]}
Destination
A Destination contains all information necessary for Composable Commerce to deliver messages to your messaging service. Supported messaging services are differentiated by the type field.
The API supports following messaging services:
SQSDestination
AWS SQS is a pull-queue on AWS.
The queue must be a Standard queue type with a MaximumMessageSize of 256 KB.
We recommend setting authenticationMode to IAM, to avoid unnecessary key management. For IAM authentication, give permissions to user arn:aws:iam::362576667341:user/subscriptions to send messages to the queue before creating the Subscription. Otherwise, a test message will not be sent.
If you prefer to use Credentials for authentication, we recommend creating an IAM user with an accessKey and accessSecret pair specifically for each Subscription.
The IAM user should only have the sqs:SendMessage permission on this queue.
typeString | "SQS" |
accessKeyString | Only present if |
accessSecretString | Only present if |
queueUrlString | URL of the Amazon SQS queue. |
regionString | AWS Region the message queue is located in. |
authenticationMode | Defines the method of authentication for the SQS queue. Default:Credentials |
{"type" : "SQS","queueUrl" : "https://<my-region>.amazonaws.com/<my-aws-account-number>/<my-queue>","accessKey" : "<my-access-key>","accessSecret" : "<my-access-secret>","region" : "<my-region>","authenticationMode" : "Credentials"}
SNSDestination
AWS SNS can be used to push messages to AWS Lambda, HTTP endpoints (webhooks), or fan-out messages to SQS queues.
We recommend setting authenticationMode to IAM, to avoid unnecessary key management. For IAM authentication, give permissions to user arn:aws:iam::362576667341:user/subscriptions to publish to the topic before creating the Subscription. Otherwise, a test message will not be sent.
If you prefer to use Credentials for authentication, we recommend creating an IAM user with an accessKey and accessSecret pair specifically for each Subscription.
The IAM user should only have the sns:Publish permission on this topic.
typeString | "SNS" |
accessKeyString | Only present if |
accessSecretString | Only present if |
topicArnString | Amazon Resource Name (ARN) of the topic. |
authenticationMode | Defines the method of authentication for the SNS topic. Default:Credentials |
{"type" : "SNS","accessKey" : "<my-access-key>","accessSecret" : "<my-access-secret>","topicArn" : "arn:aws:sns:<my-region>:<topic>","authenticationMode" : "Credentials"}
EventBridgeDestination
AWS EventBridge can be used to push events and messages to a serverless event bus that can forward them to AWS SQS, SNS, Lambda, and other AWS services based on forwarding rules. Once the Subscription is created, an equivalent "partner event source" is created in AWS EventBridge. This event source must be associated with an event bus for the Subscription setup to be complete.
typeString | "EventBridge" |
regionString | AWS region that receives the events. |
accountIdString | ID of the AWS account that receives the events. |
{"type" : "EventBridge","accountId" : "<account-id>","region" : "<my-region>"}
AzureServiceBusDestination
Azure Service Bus can be used as a pull-queue with Queues, or to fan-out messages with Topics and Subscriptions.
To set up a Subscription with Azure Service Bus, first create a queue/topic in the Azure Portal with a Shared Access Policy including the Send permission.
typeString | "AzureServiceBus" |
connectionStringString | SharedAccessKey is partially hidden on retrieval for security reasons. |
{"type" : "AzureServiceBus","connectionString" : "<connection-string>"}
To grant access to resources, Azure Service Bus uses the concept of Shared Access Policies. Shared Access Policy is defined on a scope and includes certain permissions. For setting up an Azure Service Bus Subscription on Composable Commerce, you must create a Shared Access Policy on your queue/topic and include the Send permission. When you open the policy in the Azure Portal, you will find that Azure has generated two connection strings for your policy. A connection string has the following format:
Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=<key-name>;SharedAccessKey=<key>;EntityPath=<queue-name>
You can set either of the two connection strings in the connectionString attribute of an Azure Service Bus Destination. Ensure that the path points to your queue/topic.
AzureEventGridDestination
Azure Event Grid can be used to push messages to Azure Functions, HTTP endpoints (webhooks), and several other Azure tools. Event Grid can only be used with the CloudEventsFormat. To set up a Subscription with Azure Event Grid, first create a topic in the Azure Portal. To allow Composable Commerce to push messages to your topic, provide an access key.
typeString | "EventGrid" |
uriString | URI of the topic. |
accessKeyString | Partially hidden on retrieval for security reasons. |
{"type" : "EventGrid","uri" : "<my-uri>","accessKey" : "<my-access-key>"}
GoogleCloudPubSubDestination
Destination for Google Cloud Pub/Sub that can be used
for Pull subscriptions as well as for Push subscriptions.
The topic must give the pubsub.topics.publish permission to the service account subscriptions@commercetools-platform.iam.gserviceaccount.com.
If used with the CloudEventsFormat, the message conforms to the PubSub Protocol Binding of the Structured Content Mode.
typeString | "GoogleCloudPubSub" |
projectIdString | ID of the Google Cloud project that contains the Pub/Sub topic. |
topicString | Name of the topic. |
{"type" : "GoogleCloudPubSub","topic" : "Topic","projectId" : "<project-id>"}
AwsAuthenticationMode
Defines the method of authentication for AWS SQS and SNS Destinations.
CredentialsSubscriptions with
Credentialsauthentication mode are authenticated using anaccessKeyandaccessSecretpair. This is the default authentication mode for backwards compatibility.IAMSubscriptions with
IAMauthentication mode are authenticated using Identity and Access Management (IAM). In this case, the userarn:aws:iam::362576667341:user/subscriptionsrequires permissions to send messages to the queue or publish to the topic. This is the recommended authentication mode, as it doesn't require additional key management.
MessageSubscription
For supported resources and message types, see Message Types. Messages will be delivered even if the Messages Query HTTP API is not enabled.
For MessageSubscriptions, the format of the payload is MessageDeliveryPayload.
resourceTypeId | Unique identifier for the type of resource, for example, |
typesArray of String | Must contain valid message types for the resource. For example, for resource type |
ChangeSubscription
resourceTypeId | Unique identifier for the type of resource, for example, |
MessageSubscriptionResourceTypeId
Resource types supported by MessageSubscriptions:
business-unitMessages related to Business Units.
categoryMessages related to Categories.
customerMessages related to Customers.
inventory-entryMessages related to InventoryEntries.
orderMessages related to Orders.
paymentMessages related to Payments.
productMessages related to Products.
product-selectionMessages related to ProductSelections.
quoteMessages related to Quotes.
quote-requestMessages related to Quote Requests.
reviewMessages related to Reviews.
staged-quoteMessages related to Staged Quotes.
standalone-priceMessages related to StandalonePrices.
storeMessages related to Stores.
ChangeSubscriptionResourceTypeId
Resource types supported by ChangeSubscriptions:
business-unitChanges to Business Units.
cartChanges to Carts.
cart-discountChanges to CartDiscounts.
categoryChanges to Categories.
channelChanges to Channels.
customerChanges to Customers.
customer-email-tokenChanges to CustomerTokens.
customer-groupChanges to CustomerGroups.
customer-password-tokenChanges to CustomerTokens.
discount-codeChanges to DiscountCodes.
extensionChanges to Extensions.
inventory-entryChanges to InventoryEntries.
key-value-documentChanges to CustomObjects.
orderChanges to Orders. Changes to Orders via Order Edits do not trigger a Message. To achieve this, a MessageSubscription to Order Edit Applied Message is necessary.
order-editChanges to OrderEdits.
paymentChanges to Payments.
productChanges to Products.
product-discountChanges to ProductDiscount.
product-priceChanges to EmbeddedPrices.
product-selectionChanges to ProductSelections.
product-typeChanges to ProductTypes.
quoteChanges to Quotes.
quote-requestChanges to Quote Requests.
reviewChanges to Reviews.
shipping-methodChanges to ShippingMethods.
shopping-listChanges to ShoppingLists.
staged-quoteChanges to Staged Quotes.
standalone-priceChanges to StandalonePrices.
stateChanges to States.
storeChanges to Stores.
subscriptionChanges to Subscriptions.
tax-categoryChanges to TaxCategories.
typeChanges to Types.
zoneChanges to Zones.
SubscriptionHealthStatus
The health status of the Subscription that indicates whether messages are being delivered to the Destination.
HealthyDelivers messages as expected.
ConfigurationErrorMessages cannot be delivered with the current configuration. Common causes are deleting the Destination queue, deleting access credentials, or removing the necessary permissions. The configuration can be fixed by re-creating the configuration on the Destination side, or by setting a new configuration with the Change Destination update action. If the configuration is fixed, undelivered messages will be delivered and the
statuswill change to Healthy.ConfigurationErroris automatically turned intoConfigurationErrorDeliveryStoppedafter some time. For more information, see Delivery Guarantees.ConfigurationErrorDeliveryStoppedDoes not deliver messages with the current configuration and the delivery of the messages is no longer attempted. If the configuration is fixed, undelivered messages are not retained and will not be delivered. The
statuswill change to Healthy as soon as new messages can be delivered.TemporaryErrorDoes not deliver messages temporarily due to reasons other than a configuration error. For example, the Destination has a temporary outage.
The health of the delivery infrastructure is independent of the SubscriptionHealthStatus and can be checked on the status page.
DeliveryFormat
The format in which the payload is delivered. Defaults to PlatformFormat.
PlatformFormat
The PlatformFormat uses constructs that are similar to the ones used in the REST API, for example, on the Messages Query HTTP API.
typeString | "Platform" |
CloudEventsFormat BETA
The CloudEventsFormat can be used with any Destination, and the payload is delivered in the JSON Event Format. AzureEventGridDestination offers native support to filter and route CloudEvents.
typeString | "CloudEvents" |
cloudEventsVersionString | "1"Supported versions: "1.0". |
Get Subscription
Get Subscription by ID
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
200Subscription
curl -X GET https://api.{region}.commercetools.com/{projectKey}/subscriptions/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Get Subscription by Key
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
200Subscription
curl -X GET https://api.{region}.commercetools.com/{projectKey}/subscriptions/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Get Health Status of Subscription by ID
This endpoint can be polled by a monitoring or alerting system that checks the health of your Subscriptions. To ease integration with such systems this endpoint does not require Authorization.
regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
200No body is returned.
curl -X GET https://api.{region}.commercetools.com/{projectKey}/subscriptions/{id}/health -i
The HTTP status codes are mapped to the SubscriptionHealthStatus as follows:
200-Healthy400-ConfigurationErrorandConfigurationErrorDeliveryStopped503-TemporaryError
Query Subscriptions
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
/^var[.][a-zA-Z0-9]+$/Any string parameter matching this regular expression | Predicate parameter values. The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
withTotalBoolean | Controls the calculation of the total number of query results. Set to |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/subscriptions -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit" : 20,"offset" : 0,"count" : 1,"total" : 1,"results" : [ {"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"} ]}
Create Subscription
A test message is sent to ensure the correct configuration of the Destination. If the message cannot be delivered, the Subscription will not be created. The payload of the test message is a notification of type ResourceCreated for the resourceTypeId subscription.
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
201Subscription
curl -X POST https://api.{region}.commercetools.com/{projectKey}/subscriptions -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"key" : "test-queue"}DATA
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Update Subscription
Update Subscription by ID
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the Subscription on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actionsArray of SubscriptionUpdateAction | Update actions to be performed on the Subscription. |
200Subscription
curl -X POST https://api.{region}.commercetools.com/{projectKey}/subscriptions/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "setKey","key" : "queue-key"} ]}DATA
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Update Subscription by Key
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the Subscription on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actionsArray of SubscriptionUpdateAction | Update actions to be performed on the Subscription. |
200Subscription
curl -X POST https://api.{region}.commercetools.com/{projectKey}/subscriptions/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "setKey","key" : "queue-key"} ]}DATA
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Update actions
Set Key
actionString | "setKey" |
keyString | Value to set. If empty, any existing value will be removed. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
{"action" : "setKey","key" : "keyString"}
Set Messages
actionString | "setMessages" |
messagesArray of MessageSubscription | Value to set. Can only be unset if |
{"action" : "setMessages","messages" : [ {"resourceTypeId" : "product","types" : [ "ProductCreated" ]} ]}
Set Changes
actionString | "setChanges" |
changesArray of ChangeSubscription | Value to set. Can only be unset if |
{"action" : "setChanges","changes" : [ {"resourceTypeId" : "channel"}, {"resourceTypeId" : "product"}, {"resourceTypeId" : "payment"} ]}
Change Destination
A test message is sent to ensure the correct configuration of the Destination. If the message cannot be delivered, the update will fail. The payload of the test message is a notification of type ResourceCreated for the resourceTypeId subscription. The status will change to Healthy, if it isn't already.
actionString | "changeDestination" |
destination | New value to set. Must not be empty. |
{"action" : "changeDestination","destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","accessKey" : "<my-access-key>","accessSecret" : "<my-access-secret>","region" : "<my-region>","authenticationMode" : "Credentials"}}
Delete Subscription
Delete Subscription by ID
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
200Subscription
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/subscriptions/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Delete Subscription by Key
manage_subscriptions:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
200Subscription
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/subscriptions/key={key}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "8062243c-46fc-40b5-88a4-75e2216aef75","version" : 1,"destination" : {"type" : "SQS","queueUrl" : "<url-to-my-queue>","authenticationMode" : "IAM","region" : "<my-region>"},"messages" : [ {"resourceTypeId" : "product","types" : [ ]} ],"changes" : [ ],"createdAt" : "2017-01-25T14:14:22.417Z","key" : "test-queue","format" : {"type" : "Platform"},"lastModifiedAt" : "2017-01-25T14:14:22.417Z","status" : "Healthy"}
Delivery
The Delivery payload depends on the chosen DeliveryFormat.
Delivery payload for the PlatformFormat
All payloads for the PlatformFormat share these common fields.
projectKeyString |
|
notificationTypeString | Identifies the payload. |
resource | Reference to the resource that triggered the message. |
resourceUserProvidedIdentifiers | User-defined unique identifiers of the resource. |
MessageDeliveryPayload
This payload is sent for a MessageSubscription.
idString | Unique ID of the message. |
versionInt | Last seen version of the resource. |
projectKeyString |
|
notificationTypeString | "Message"Identifies the payload. |
resource | Reference to the resource that triggered the message. |
resourceUserProvidedIdentifiers | User-defined unique identifiers of the resource. |
sequenceNumberInt | Used to ensure all messages of the resource are processed in correct order.
The |
resourceVersionInt | Version of the resource on which the change was performed. |
payloadNotIncluded | If the payload does not fit into the size limit or its format is not accepted by the messaging service, the |
createdAt | Date and time (UTC) the resource was initially created. |
lastModifiedAt | Date and time (UTC) the resource was last modified. |
{"notificationType" : "Message","projectKey" : "<project_key>","id" : "<message_id>","version" : 1,"sequenceNumber" : 2,"resource" : {"typeId" : "customer","id" : "<customer_id>"},"resourceVersion" : 2,"resourceUserProvidedIdentifiers" : { },"type" : "CustomerLastNameSet","lastName" : "Doe","createdAt" : "2022-10-25T13:30:09.760Z","lastModifiedAt" : "2022-10-25T13:30:09.760Z"}
If the payload fits into the size limit of your message queue (the limit is often 256 KB), all additional fields for the specific message are included as well (along with the type field). If the payload did not fit inside the message, it can be retrieved from the Messages Query HTTP API if the feature is enabled.
PayloadNotIncluded
reasonString | Reason the payload is not included. For example, the payload is too large, or its content is not supported by the Subscription destination. |
payloadTypeString | Value of the |
{"reason" : "Payload too large.","payloadType" : "ProductPublished"}
ResourceCreatedDeliveryPayload
This payload is sent for a ChangeSubscription when a resource is created.
versionInt | Last seen version of the resource. |
projectKeyString |
|
notificationTypeString | "ResourceCreated"Identifies the payload. |
resource | Reference to the resource that triggered the message. |
resourceUserProvidedIdentifiers | User-defined unique identifiers of the resource. |
modifiedAt | Date and time (UTC) the resource was last modified. |
{"notificationType" : "ResourceCreated","projectKey" : "<project_key>","resource" : {"typeId" : "product","id" : "<product_id>"},"resourceUserProvidedIdentifiers" : {"key" : "example-product-key","slug" : {"en" : "example-slug"}},"version" : 1,"modifiedAt" : "2022-10-25T13:23:05.384Z"}
ResourceUpdatedDeliveryPayload
This payload is sent for a ChangeSubscription when a resource is updated. This includes updates by a background process, like a change in product availability.
versionInt | Last seen version of the resource. |
projectKeyString |
|
notificationTypeString | "ResourceUpdated"Identifies the payload. |
resource | Reference to the resource that triggered the message. |
resourceUserProvidedIdentifiers | User-defined unique identifiers of the resource. |
oldVersionInt | Version of the resource before the update. |
modifiedAt | Date and time (UTC) the resource was last updated. |
{"notificationType" : "ResourceUpdated","projectKey" : "<project-key>","resource" : {"typeId" : "product","id" : "<product-id>"},"resourceUserProvidedIdentifiers" : {"key" : "example-product-key","slug" : {"en" : "example-product-slug"}},"version" : 3,"oldVersion" : 1,"modifiedAt" : "2022-10-25T13:23:40.577Z"}
ResourceDeletedDeliveryPayload
This payload is sent for a ChangeSubscription when a resource is deleted.
versionInt | Last seen version of the resource. |
projectKeyString |
|
notificationTypeString | "ResourceDeleted"Identifies the payload. |
resource | Reference to the resource that triggered the message. |
resourceUserProvidedIdentifiers | User-defined unique identifiers of the resource. |
modifiedAt | Date and time (UTC) the resource was last deleted. |
dataErasureBoolean |
|
{"notificationType" : "ResourceDeleted","projectKey" : "<project-key>","resource" : {"typeId" : "product","id" : "<product-id>"},"resourceUserProvidedIdentifiers" : {"key" : "example-product-key","slug" : {"en" : "example-product-slug"}},"version" : 3,"modifiedAt" : "2022-10-25T13:23:50.113Z"}
Delivery payload for the CloudEventsFormat
The CloudEventsFormat represents event data in a way that conforms to a common specification. The message payload can be found inside the data field.
idString | Unique identifier of the event. |
specversionString | The version of the CloudEvents specification which the event uses. |
typeString | The |
sourceString | The default REST URI of the ReferenceTypeId that triggered this event, including the project key. |
subjectString | Unique identifier of the resource that triggered the event. |
time | Corresponds to the |
sequenceString | Corresponds to the |
sequencetypeString |
|
datarefString | The URI from which the message can be retrieved if messages are enabled. Only set for MessageSubscriptions. |
data |
{"id" : "81ee6da8-5bc2-471b-9159-89bac735a45d","source" : "/<project_key>/products","specversion" : "1.0","type" : "com.commercetools.product.message.ProductPublished","subject" : "b32d1013-cd25-4cb4-95ab-99c494531d73","time" : "2022-06-17T08:41:58.066Z","dataref" : "/<project-key>/messages/81ee6da8-5bc2-471b-9159-89bac735a45d","sequence" : "2","sequencetype" : "Integer","data" : {"notificationType" : "Message","projectKey" : "<project-key>","id" : "81ee6da8-5bc2-471b-9159-89bac735a45d","version" : 1,"sequenceNumber" : 2,"resource" : {"typeId" : "product","id" : "b32d1013-cd25-4cb4-95ab-99c494531d73"},"resourceVersion" : 2,"resourceUserProvidedIdentifiers" : {"key" : "product-key-1","slug" : {"en" : "product-slug-1"}},"type" : "ProductPublished","productProjection" : {"id" : "b32d1013-cd25-4cb4-95ab-99c494531d73","version" : 2,"productType" : {"typeId" : "product-type","id" : "25ef7088-74dd-4b92-bf3c-705dfa20deaa"},"categories" : [ ],"hasStagedChanges" : false,"published" : true,"key" : "product-key-1","createdAt" : "2022-06-17T08:21:40.279Z","lastModifiedAt" : "2022-06-17T08:41:58.066Z"},"removedImageUrls" : [ ],"scope" : "All","createdAt" : "2022-06-17T08:41:58.066Z","lastModifiedAt" : "2022-06-17T08:41:58.066Z"}}
Delivery guarantees
At-least-once delivery
If Composable Commerce did not get a positive acknowledgment that messages have been accepted by the Destination, it will retry the message delivery. Our Retry Policy depends on the SubscriptionHealthStatus:
TemporaryError- Retry for up to 48 hours, after which messages may be dropped.ConfigurationError- Retry for up to 24 hours (for production Projects) or 1 hour (for development or staging Projects), after which the status changes toConfigurationErrorDeliveryStopped, and messages are dropped.
A side effect of the retry is that the same message may be may be sent several times. An idempotent message processor that doesn't process the same message twice can check whether the message was already processed. For notificationType "Message", use the fields resource.id and sequenceNumber. In other cases, use the field's resource.id and version.
We guarantee that all message payloads we attempt to deliver to a Destination are valid according to their specification. Therefore, the only cases where messages can not be delivered are due to an ongoing incident, or due to a misconfiguration.
You can monitor the health of a Subscription with a tool of your choice. For production-critical queues, we recommend setting up an automatic alert.
No guarantee on order
Messages are not guaranteed to be delivered in their natural order (for example, with ascending sequenceNumber or ascending version). This is especially true in the case of retries.
For notificationType "Message", a message processor can use the fields resource.id and sequenceNumber to process messages in the correct order (for example, if the last processed sequenceNumber was 2, and the current message is 4, the current message can be put back into the queue for processing at a later point in time).
For messages of notificationType other than "Message", the fields resource.id, version and (in case of update) oldVersion can be used. Note that version is not sequential.
No guarantee on delivery time
Messages are not guaranteed to be delivered within a certain time frame. Although most messages are delivered within seconds, delays of several minutes can be caused by a variety of factors, such as scaling infrastructure resources. Therefore we do not recommend using Subscriptions for time-critical use cases where a few minute's delay is seen as an incident.