# 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: original
x-onerway-spec-key: payments/webhooks/subscription-canceled
info:
  title: Subscription cancellation webhook
  version: original
  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: Body signature, excluded from the signature input. Follow [Request
                    signing](/payments/get-started/request-signing#webhook-signature-verification)
                    and use the `X-Rh-Signature` header to verify the
                    notification.
                  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-Rh-Signature: v1=replace_with_signature
      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."
          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-Rh-Signature
        version: v1
        algorithm: sha256
        rule: acquiring-sorted-concat-secret
        reference: /payments/get-started/request-signing
      x-onerway-header-fields:
        - name: X-Rh-Signature
          schema:
            type: string
            description: Signature for verifying this notification. Contains one or more
              comma-separated `v1=<signature>` values.
        - name: x-signature
          schema:
            type: string
            description: Additional signature header with the same format and signing rules
              as `X-Rh-Signature`.
      x-onerway-destination:
        description: Notifications are sent to the `notifyUrl` from the original
          transaction request.
```
