# Subscription cancellation webhook

> Receive notifications when subscription cancellation takes effect, associate the contract, and acknowledge receipt.

```yaml
openapi: 3.1.0
x-onerway-docs-version: v2
x-onerway-spec-key: payments/versions/v2/webhooks/subscription-canceled
info:
  title: Subscription cancellation webhook
  version: v2
  description: Receive notifications when subscription cancellation takes effect,
    associate the contract, and acknowledge receipt.
webhooks:
  subscription.canceled:
    post:
      summary: Subscription cancellation webhook
      description: Receive notifications when subscription cancellation takes effect,
        associate the contract, and acknowledge receipt.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                notifyType:
                  type: string
                  description: Notification type, fixed to `SUBSCRIPTION_CANCELED`.
                  x-onerway-signature-participation: included
                transactionId:
                  type: string
                  description: Onerway identifier carried by this cancellation notification.
                    Return the received value unchanged in the acknowledgement
                    body.
                  x-onerway-signature-participation: included
                merchantNo:
                  type: string
                  description: Merchant number assigned by Onerway.
                  x-onerway-signature-participation: included
                responseTime:
                  type: string
                  description: Notification result time in `yyyy-MM-dd HH:mm:ss` format.
                  x-onerway-signature-participation: included
                txnTime:
                  type: string
                  description: Operation time recorded in this notification, in `yyyy-MM-dd
                    HH:mm:ss` format.
                  x-onerway-signature-participation: included
                txnTimeZone:
                  type: string
                  description: Time zone offset for `txnTime`.
                  x-onerway-signature-participation: included
                status:
                  type: string
                  description: Cancellation result, fixed to `S` for a successful cancellation.
                  x-onerway-signature-participation: included
                contractId:
                  type: string
                  description: Canceled subscription contract number. Use it to associate this
                    event with your subscription record.
                  x-onerway-signature-participation: included
                sign:
                  type: string
                  description: Compatibility signature in the notification body, excluded from the
                    signature input. Verify this notification with
                    `x-signature`. Do not fall back to `X-Rh-Signature` or body
                    `sign` when `x-signature` is missing or fails verification.
                  x-onerway-signature-participation: signature-field
                subscriptionExpireDate:
                  type: string
                  description: Subscription expiration date carried in the notification, in
                    `yyyy-MM-dd` format. Do not use this date alone to determine
                    whether cancellation has taken effect; use
                    `subscriptionStatus`.
                  x-onerway-signature-participation: included
                subscriptionStatus:
                  type: string
                  description: Subscription lifecycle status, fixed to `canceled` after
                    cancellation takes effect.
                  x-onerway-signature-participation: included
                dataStatus:
                  type: string
                  description: Contract status reported for the canceled subscription, fixed to
                    `3`.
                  x-onerway-signature-participation: included
                products:
                  type: string
                  description: Subscription products encoded as a JSON string. Product entries
                    contain `name`, `price`, `num`, and `currency`. Use the
                    received string unchanged when calculating the signature; do
                    not parse and reserialize it.
                  x-onerway-signature-participation: included
                scenarios:
                  type: string
                  description: Subscription event, fixed to `SUBSCRIPTION_CANCELED`.
                  x-onerway-signature-participation: included
            examples:
              subscription_canceled:
                summary: Subscription canceled immediately
                value:
                  notifyType: SUBSCRIPTION_CANCELED
                  transactionId: example_subscription_contract
                  merchantNo: replace_with_merchant_no
                  responseTime: 2026-09-29 00:00:03
                  txnTime: 2026-09-29 00:00:03
                  txnTimeZone: +08:00
                  status: S
                  contractId: example_subscription_contract
                  sign: replace_with_signature
                  subscriptionExpireDate: 2099-12-31
                  subscriptionStatus: canceled
                  dataStatus: "3"
                  products: '[{"name": "example_membership", "price": "0.99", "num": "1",
                    "currency": "USD"}]'
                  scenarios: SUBSCRIPTION_CANCELED
                x-onerway-headers:
                  x-signature: v1=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
                  X-Rh-Signature: v1=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
                  x-timestamp: replace_with_delivery_timestamp
      responses:
        "200":
          description: "After receiving and accepting the notification, return HTTP 200
            with `Content-Type: text/plain` and the received `transactionId`
            unchanged in the response body. On automatic retries, the payload
            and signature values remain unchanged; only the unsigned
            `x-timestamp` header is refreshed. Do not use this header as proof
            that a notification has not been replayed."
          content:
            text/plain:
              schema:
                type: string
              examples:
                return_transaction_id:
                  summary: Return transactionId
                  value: example_subscription_contract
      x-onerway-verification:
        scheme: header-sign
        header: x-signature
        version: v1
        algorithm: sha256
        rule: acquiring-sorted-concat-secret
        reference: /payments/versions/v2/get-started/webhook-signatures
      x-onerway-header-fields:
        - name: x-signature
          schema:
            type: string
            description: Signature for verifying this notification. Contains one or more
              comma-separated `v1=<signature>` values.
        - name: x-timestamp
          schema:
            type: string
            description: Notification send time as a Unix timestamp in seconds. Excluded
              from the signature.
      x-onerway-destination:
        description: Notifications are sent to the `notifyUrl` from the original
          transaction request.
```
