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

# Create Webhook

## Overview

Subscribe to webhook events for your tenant. When events occur, the system will send HTTP POST requests to your specified URL.

## Authorization

* User must be authenticated with a valid Bearer token
* User must have ADMIN role in the tenant

## Webhook Delivery

* Events are delivered via HTTP POST to your URL
* Includes event type and payload
* Retries on failure with exponential backoff
* Delivery status tracked in webhook\_deliveries table

## Security

* Use HTTPS URLs for webhook endpoints
* Verify webhook signatures to ensure authenticity
* Implement idempotency to handle duplicate deliveries

## Example Usage

```bash theme={null}
curl -X POST \
  https://faisalshop.mvp-apps.ae/api/v2/admin/webhooks/123 \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://your-app.com/webhooks",
    "events": ["user.registered", "order.created"]
  }'
```

```javascript theme={null}
await axios.post(
  `/api/v2/admin/webhooks/${tenantId}`,
  {
    url: 'https://your-app.com/webhooks',
    events: ['user.registered', 'order.created']
  },
  {
    headers: {
      Authorization: `Bearer ${token}`
    }
  }
);
```

## Webhook Payload Example

```json theme={null}
{
  "event": "user.registered",
  "tenant_id": 123,
  "timestamp": "2025-11-16T10:30:00Z",
  "data": {
    "user_id": 42,
    "email": "user@example.com",
    "role": "MEMBER"
  }
}
```


## OpenAPI

````yaml POST /api/v2/admin/webhooks/{tenantId}
openapi: 3.1.0
info:
  title: Urban Things API
  description: Multi-tenant e-commerce platform API
  version: 2.0.0
  contact:
    email: info@faisalkc.com
servers:
  - url: https://faisalshop.mvp-apps.ae
    description: Production server
  - url: http://localhost:3000
    description: Development server
security:
  - bearerAuth: []
paths:
  /api/v2/admin/webhooks/{tenantId}:
    post:
      tags:
        - Webhooks
      summary: Create webhook
      parameters:
        - $ref: '#/components/parameters/TenantIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
                - events
              properties:
                url:
                  type: string
                  format: uri
                events:
                  type: array
                  items:
                    type: string
      responses:
        '201':
          description: Webhook created
components:
  parameters:
    TenantIdPath:
      name: tenantId
      in: path
      required: true
      schema:
        type: integer
      description: Tenant ID
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````