# Manage Webhook Subscriptions

## Overview

This guide outlines the APIs for managing your webhook subscriptions, including retrieving, updating, and deleting subscriptions.

## Retrieve Webhook Subscriptions

### Retrieving All Subscriptions

To get a list of all your active webhook subscriptions, call the GetWebhooks endpoint.

**Request**


```bash
curl --request GET \
  --url https://sandboxapi.peach.finance/api/webhooks \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

**Response**


```json
{
  "status": 0,
  "count": 2,
  "data": [
    {
      "id": "whk_1234567890abcdef",
      "webhookType": "direct",
      "eventTypes": ["loan.created", "payment.succeeded"],
      "webhookDirectDetails": {
        "webhookUrl": "https://your-endpoint.com/webhook"
      },
      "enabled": true,
      "createdAt": "2023-10-18T14:15:22Z",
      "updatedAt": "2023-10-18T14:15:22Z"
    },
    {
      "id": "whk_0987654321fedcba",
      "webhookType": "direct",
      "eventTypes": ["loan.statuschanged", "payment.failed"],
      "webhookDirectDetails": {
        "webhookUrl": "https://your-other-endpoint.com/webhook"
      },
      "enabled": true,
      "createdAt": "2023-10-19T09:30:15Z",
      "updatedAt": "2023-10-19T09:30:15Z"
    }
  ]
}
```

### Retrieve a Specific Subscription

To retrieve the details of a specific webhook subscription, call GetSubscriptionById and replace `{webhookSubscriptionId}` with the unique identifier of the subscription you want to retrieve.

**Request**


```bash
curl --request GET \
  --url https://sandboxapi.peach.finance/api/webhooks/whk_1234567890abcdef \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

**Response**


```json
{
  "status": 0,
  "message": "Webhook subscription retrieved successfully",
  "data": {
    "id": "whk_1234567890abcdef",
    "webhookType": "direct",
    "eventTypes": ["loan.created", "payment.succeeded"],
    "webhookDirectDetails": {
      "webhookUrl": "https://your-endpoint.com/webhook"
    },
    "enabled": true,
    "createdAt": "2023-10-18T14:15:22Z",
    "updatedAt": "2023-10-18T14:15:22Z"
  }
}
```

## Update a Webhook Subscription

To update an existing webhook subscription, call UpdateWebhookSubscription and replace `{webhookSubscriptionId}` with the unique identifier of the subscription you want to update. The following request adds the `loan.statuschanged` event subscription.

**Request**


```bash
curl --request PUT \
  --url https://sandboxapi.peach.finance/api/webhooks/whk_1234567890abcdef \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "eventTypes": ["loan.created", "loan.statuschanged", "payment.succeeded"],
    "webhookDirectDetails": {
      "webhookUrl": "https://your-new-endpoint.com/webhook"
    },
    "enabled": true
  }'
```

**Response**


```json
{
  "status": 0,
  "message": "Webhook subscription updated successfully",
  "data": {
    "id": "whk_1234567890abcdef",
    "webhookType": "direct",
    "eventTypes": ["loan.created", "loan.statuschanged", "payment.succeeded"],
    "webhookDirectDetails": {
      "webhookUrl": "https://your-new-endpoint.com/webhook"
    },
    "enabled": true,
    "createdAt": "2023-10-18T14:15:22Z",
    "updatedAt": "2023-10-20T11:45:30Z"
  }
}
```

## Delete a Webhook Subscription

To remove a webhook subscription, call DeleteWebhookSubscription and replace `{webhookSubscriptionId}` with the unique identifier of the subscription you want to delete.

**Request**


```bash
curl --request DELETE \
  --url https://sandboxapi.peach.finance/api/webhooks/whk_1234567890abcdef \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

**Response**


```json
{
  "status": 0,
  "message": "Webhook subscription deleted successfully"
}
```

## See also

- **[About Webhooks](/developer-tools/webhooks/about-webhooks)** — How webhooks work in Peach, including signing and delivery.
- **[Webhook Events](/developer-tools/webhooks/webhook-events)** — Reference for the event types you can subscribe to.