# Management

## Endpoints

| Method | Path                          | Description           |
| ------ | ----------------------------- | --------------------- |
| POST   | `/webhooks`                   | Create webhook        |
| GET    | `/webhooks`                   | List webhooks         |
| GET    | `/webhooks/:id`               | Get webhook           |
| PATCH  | `/webhooks/:id`               | Update webhook        |
| DELETE | `/webhooks/:id`               | Delete webhook        |
| POST   | `/webhooks/:id/test`          | Send test event       |
| POST   | `/webhooks/:id/rotate-secret` | Rotate signing secret |
| GET    | `/webhooks/:id/deliveries`    | List delivery history |

***

### Create Webhook

```
POST /webhooks
```

**Request Body:**

```json
{
  "url": "https://your-server.com/webhooks",
  "events": ["trade.filled", "trade.closed"],
  "description": "Production webhook"
}
```

**Response:**

```json
{
  "id": "wh_abc123",
  "url": "https://your-server.com/webhooks",
  "events": ["trade.filled", "trade.closed"],
  "secret": "whsec_...",
  "is_active": true,
  "created_at": "2026-02-20T12:00:00Z"
}
```

> ⚠️ The `secret` is only returned on creation. Store it securely for signature verification.

***

### List Webhooks

```
GET /webhooks
```

***

### Update Webhook

```
PATCH /webhooks/:id
```

```json
{
  "events": ["trade.filled", "trade.closed", "copier.started"],
  "is_active": true
}
```

***

### Delete Webhook

```
DELETE /webhooks/:id
```

***

### Test Webhook

```
POST /webhooks/:id/test
```

Sends a test event to your webhook URL.

***

### Rotate Secret

```
POST /webhooks/:id/rotate-secret
```

Generates a new signing secret. The old secret is immediately invalidated.

***

### Delivery History

```
GET /webhooks/:id/deliveries
```

Returns recent delivery attempts with status codes and response times.
