Subscribe to event
Endpoint: https://api.youcan.shop/resthooks/subscribe
Method: POST
Required Scopes
edit-rest-hooks
Request Body
Param Name | Param Type | Description | Required |
---|---|---|---|
target_url | string | the URL which you want our API to POST to when this event occurs, mandatory | yes |
event | string | the event name that you want to hold about. supported events:
| yes |
Note
- Your
target_url
must be publicly accessible. Localhost or private network URLs will not work.
Available events
Event | Description |
---|---|
order.create | Triggered when a new order is placed. |
inventory.low | Triggered when product inventory drops below threshold. |
upsell.accept | Triggered when customer accepts an upsell offer. |
Example Request
json
{
"event": "order.create",
"target_url": "https://yourdomain.com/webhook/order-created"
}
Responses
[200] Ok
json
{
"id": "8e6b019b-06de-496d-a96d-c9ee69c0ccf0"
}
[429] Too Many Requests
json
{
"status": 429,
"detail": "This store has reached the max of subscriptions for this event.",
"meta": []
}
Solution: List your current subscriptions and unsubscribe from unused ones.
[401] Unauthorized
json
{
"status": 401,
"detail": "Unauthenticated",
"meta": []
}
Solution: Check your access token is valid and ensure you've allowed the
edit-rest-hooks
scope.
Example Webhook Payload
When you subscribe to order.create
, here's what YouCan will send to your webhook URL:
json
{
"id": "e1f4dd96-7e1c-4cd6-b9c8-9ede62f53eae",
"ref": "025",
"total": 300,
"currency": "USD",
"status": 1,
"payment_status": 2,
"created_at": "2025-06-25T12:18:46+00:00",
"customer": {
"id": "3a0383ad-e894-4e71-8191-e146fefd7ac7",
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890"
},
"variants": [
{
"id": "bd84365e-4a6d-497a-8658-843e65b77da8",
"price": 300,
"quantity": 1,
"variant": {
"sku": "SK7897",
"product": {
"name": "Sample Product",
"slug": "sample-product"
}
}
}
],
"payment": {
"status": -1,
"status_text": "unpaid",
"payload": {
"gateway": "cod"
}
},
"shipping": {
"status": 2,
"status_text": "unfulfilled",
"price": 0,
"is_free": true
}
}
Subscription Limits
- A maximum of 3 webhook subscriptions is allowed per store.
- You can only create one subscription per event type.