Skip to content

Subscribe to event

Endpoint: https://api.youcan.shop/resthooks/subscribe

Method: POST

Required Scopes

  • edit-rest-hooks

Request Body

Param NameParam TypeDescriptionRequired
target_urlstringthe URL which you want our API to POST to when this event occurs, mandatoryyes
eventstringthe event name that you want to hold about.
supported events:
  • inventory.low
  • order.create
  • upsell.accept
yes

Note

  • Your target_url must be publicly accessible. Localhost or private network URLs will not work.

Available events

EventDescription
order.createTriggered when a new order is placed.
inventory.lowTriggered when product inventory drops below threshold.
upsell.acceptTriggered 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.