commercetools Subscriptions API

The Subscriptions API from commercetools — 2 operation(s) for subscriptions.

OpenAPI Specification

commercetools-subscriptions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: commercetools Change History Carts Subscriptions API
  description: The commercetools Change History API provides a queryable audit log of all changes made to resources within a Composable Commerce project. It records mutations applied to resources such as products, orders, customers, discounts, and carts, along with metadata about who made the change and when. The API is hosted on separate regional endpoints from the main HTTP API and supports filtering by resource type, date range, user, and API client. It is useful for compliance workflows, debugging unexpected state changes, and building audit trails for regulated industries.
  version: '1.0'
  contact:
    name: commercetools Support
    url: https://support.commercetools.com
  termsOfService: https://commercetools.com/terms-conditions
servers:
- url: https://history.{region}.commercetools.com
  description: Production Change History Server
  variables:
    region:
      default: us-central1.gcp
      enum:
      - us-central1.gcp
      - us-east-2.aws
      - europe-west1.gcp
      - eu-central-1.aws
      - australia-southeast1.gcp
      description: The deployment region.
security:
- bearerAuth: []
tags:
- name: Subscriptions
paths:
  /{projectKey}/subscriptions:
    get:
      operationId: listSubscriptions
      summary: List subscriptions
      description: Returns a paginated list of all subscriptions configured in the project. Subscriptions define destinations for change notifications and message delivery to external services such as SQS, SNS, Google Pub/Sub, or Azure Service Bus.
      tags:
      - Subscriptions
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/offset'
      - $ref: '#/components/parameters/where'
      responses:
        '200':
          description: A paged list of subscriptions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionPagedQueryResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createSubscription
      summary: Create a subscription
      description: Creates a new subscription that routes messages and change notifications to an external destination. Supported destinations include AWS SQS, SNS, EventBridge, Azure Service Bus, Event Grid, Google Pub/Sub, and Confluent Cloud. A maximum of 50 subscriptions per project is allowed.
      tags:
      - Subscriptions
      parameters:
      - $ref: '#/components/parameters/projectKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionDraft'
      responses:
        '201':
          description: The created subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
        '400':
          $ref: '#/components/responses/BadRequest'
  /{projectKey}/subscriptions/{id}:
    get:
      operationId: getSubscriptionById
      summary: Get a subscription by ID
      description: Retrieves a single subscription by its system-generated ID, including its destination configuration, message type filters, change filters, and delivery format settings.
      tags:
      - Subscriptions
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/id'
      responses:
        '200':
          description: The requested subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: updateSubscriptionById
      summary: Update a subscription by ID
      description: Applies update actions to the subscription with the given ID. Supported actions include changing the destination, setting message types, setting changes, and changing the format.
      tags:
      - Subscriptions
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionUpdate'
      responses:
        '200':
          description: The updated subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
    delete:
      operationId: deleteSubscriptionById
      summary: Delete a subscription by ID
      description: Permanently deletes the subscription with the given ID. The current version must be provided. After deletion, no further messages are routed to the associated destination.
      tags:
      - Subscriptions
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/id'
      - $ref: '#/components/parameters/version'
      responses:
        '200':
          description: The deleted subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
components:
  responses:
    Unauthorized:
      description: The request lacked valid authentication credentials.
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
              message:
                type: string
    BadRequest:
      description: The request was malformed or contained invalid parameters.
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
              message:
                type: string
              errors:
                type: array
                items:
                  type: object
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
              message:
                type: string
  parameters:
    id:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: The system-generated unique identifier of the resource.
    where:
      name: where
      in: query
      required: false
      schema:
        type: string
      description: Query predicate string for filtering results. Uses commercetools predicate syntax (e.g., 'customerEmail = "user@example.com"').
    projectKey:
      name: projectKey
      in: path
      required: true
      schema:
        type: string
      description: The unique key identifying the commercetools project.
    version:
      name: version
      in: query
      required: true
      schema:
        type: integer
        minimum: 1
      description: Current version of the resource for optimistic concurrency control.
    offset:
      name: offset
      in: query
      required: false
      schema:
        type: integer
        minimum: 0
        maximum: 10000
        default: 0
      description: Number of results to skip for pagination. Maximum 10000.
    limit:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 500
        default: 20
      description: Maximum number of results to return. Defaults to 20, maximum 500.
  schemas:
    SubscriptionPagedQueryResponse:
      type: object
      description: Paginated response containing a list of subscriptions.
      required:
      - limit
      - offset
      - count
      - total
      - results
      properties:
        limit:
          type: integer
        offset:
          type: integer
        count:
          type: integer
        total:
          type: integer
        results:
          type: array
          items:
            $ref: '#/components/schemas/Subscription'
    SubscriptionUpdate:
      type: object
      description: Request body for updating a subscription.
      required:
      - version
      - actions
      properties:
        version:
          type: integer
          description: Current version for optimistic concurrency control.
        actions:
          type: array
          items:
            type: object
          description: List of update actions to apply to the subscription.
    Subscription:
      type: object
      description: A subscription routing change notifications and messages to an external message queue destination.
      required:
      - id
      - version
      - destination
      properties:
        id:
          type: string
          description: System-generated unique identifier.
        version:
          type: integer
          description: Current version for optimistic concurrency control.
        key:
          type: string
          description: User-defined unique identifier (2-256 characters).
        destination:
          type: object
          description: The external message queue destination configuration.
        messages:
          type: array
          items:
            type: object
          description: Message type subscriptions filtering which message types to deliver.
        changes:
          type: array
          items:
            type: object
          description: Change subscriptions filtering which resource change events to deliver.
        format:
          type: object
          description: Delivery format configuration (Platform or CloudEvents).
        status:
          type: string
          enum:
          - Healthy
          - ConfigurationError
          - ConfigurationErrorDeliveryStopped
          - TemporaryError
          description: Current health status of the subscription.
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the subscription was created.
        lastModifiedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the subscription was last modified.
    SubscriptionDraft:
      type: object
      description: Request body for creating a new subscription.
      required:
      - destination
      properties:
        key:
          type: string
          description: User-defined unique key (2-256 characters).
        destination:
          type: object
          description: The message queue destination configuration.
        messages:
          type: array
          items:
            type: object
          description: Message type filters for this subscription.
        changes:
          type: array
          items:
            type: object
          description: Change type filters for this subscription.
        format:
          type: object
          description: Delivery format configuration.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: OAuth 2.0 Bearer token obtained from the commercetools authentication service using client credentials flow. Requires the view_audit_log scope.
externalDocs:
  description: commercetools Change History API Documentation
  url: https://docs.commercetools.com/api/history/overview