> ## Documentation Index
> Fetch the complete documentation index at: https://thehyperstack.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscribe to Webhook

### Description

This endpoint allows you to **register a webhook URL** to receive real-time event notifications from Hyperstack. If a subscription already exists for your organization, it will be updated with the new URL and events.

Currently supported events:

* `credential.issued` — triggered when a credential is successfully published

### Headers

<ParamField header="Authorization" type="string" required="true">
  Bearer YOUR\_API\_TOKEN — obtainable from **Hyperstack Dashboard → Settings → API Access**
</ParamField>

### Body Parameters

<ParamField body="url" type="string" required="true">
  The HTTPS URL that Hyperstack will POST event payloads to. Must begin with `http://` or `https://`.
</ParamField>

<ParamField body="events" type="array[string]" required="true">
  An array of event names to subscribe to. Currently supported values: `["credential.issued"]`.
</ParamField>

### Success Response Fields

<ResponseField name="success" type="boolean">
  Indicates whether the subscription was created or updated.
</ResponseField>

<ResponseField name="message" type="string">
  A confirmation message. Value: `"Webhook updated successfully"`.
</ResponseField>

### Responses

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "success": true,
    "message": "Webhook updated successfully"
  }
  ```

  ```json 400 Bad Request — Missing fields theme={null}
  {
    "success": false,
    "error": "URL and Event(s) are required",
    "error_code": "missing_url_event"
  }
  ```

  ```json 400 Bad Request — Invalid event theme={null}
  {
    "success": false,
    "error": "Invalid Event(s)",
    "error_code": "invalid_event"
  }
  ```

  ```json 400 Bad Request — Invalid URL theme={null}
  {
    "success": false,
    "error": "Invalid URL",
    "error_code": "invalid_url"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "detail": "Invalid token or organization not found"
  }
  ```
</ResponseExample>

```bash theme={null}
curl -X POST "https://api.thehyperstack.com/v1/webhook/subscribe" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/hyperstack",
    "events": ["credential.issued"]
  }'
```
