---
title: "Called when subscription changed or renewed"
method: POST
path: "/your-webhook-url/"
tags: ["Webhook calls"]
---

# Called when subscription changed or renewed

`POST /your-webhook-url/`

We recommend that you verify all calls from us to your webhook endpoints. We sign each request with the `Hook-HMAC` header. The value is a HMAC digest derived from the body of the request and a secret key only known by the API and you. We also supply the type of event in the `Hook-Event` header.

Here is a sample implementation in Python. This process is very similar to the one Shopify uses so more information can possibly be gleaned from their [documentation](https://shopify.dev/tutorials/manage-webhooks#verify-webhook).
```
import base64
import hmac
import hashlib

WEBHOOK_SECRET = "Your webhook secret".encode()
WEBHOOK_DIGEST_TYPE = 'sha512'

def verify(hmac_header, digest_method, secret, message):
   digestmod = getattr(hashlib, digest_method)
   signed = base64.b64encode(
       hmac.new(secret, message, digestmod).digest(),
   ).strip()
   return hmac.compare_digest(signed, hmac_header)

# your view function
def handle_webhook(request):
   # The signature
   digest = request.META.get('HTTP_HOOK_HMAC').encode()
   # The name of the webhook event
   event = request.META.get('HTTP_HOOK_EVENT').encode()

   body = request.body
   if verify(digest, WEBHOOK_DIGEST_TYPE, WEBHOOK_SECRET, body):
       payload = json.loads(body)
       # ... the rest of your code here```

## Request body

- object
  - `customer` Customer
    - `first_name` string, required
    - `last_name` string, required
    - `email` string, required
    - `phone` string
    - `customer_reference` string, required
    - `id` integer
    - `payment_method` PaymentMethod[]
      - `verified` boolean
      - `canceled` boolean
      - `valid_until` string, date-time
      - `display_info` string
  - `subscriptions` SubscriptionNoBillingLog[]
    - `id` integer
    - `trial_end` string, date-time
    - `start_date` string, date-time
    - `ended_at` string, date-time
    - `active_until` string, date-time
    - `reference` string
    - `description` string
    - `is_on_trial` boolean
    - `active` boolean
    - `cancelled` boolean
    - `cancel_date` string, date-time
    - `meta` string, json
    - `token` string
    - `customer` Customer
      - `first_name` string, required
      - `last_name` string, required
      - `email` string, required
      - `phone` string
      - `customer_reference` string, required
      - `id` integer
      - `payment_method` PaymentMethod[]
        - `verified` boolean
        - `canceled` boolean
        - `valid_until` string, date-time
        - `display_info` string

## Response `200`

Successful operation

---

[API](https://skmtc.dev/askell/apis/a-skell-api.md) · [All operations](https://skmtc.dev/askell/apis/a-skell-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/askell/a-skell-api/revisions/9234f937fa26/schema)
