> For the complete documentation index, see [llms.txt](https://ivorypay.gitbook.io/ivorypay-on-off-ramp-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ivorypay.gitbook.io/ivorypay-on-off-ramp-documentation/api-reference-webhooks/update.md).

# Update Webhook

Update a webhook's URL or subscribed events.

Updates an existing webhook's URL and/or the events it's subscribed to.

## Endpoint

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

## Authentication

This endpoint requires a business-user JWT (not an API key).

| Header          | Value          |
| --------------- | -------------- |
| `Authorization` | `Bearer <jwt>` |

**Required roles:** `BUSINESS_ADMIN` or `BUSINESS_DEVELOPER`.

## Path parameters

| Parameter | Type   | Description  |
| --------- | ------ | ------------ |
| `id`      | string | Webhook UUID |

## Request body

Both fields are required by the `UpdateWebhookDto` (the URL must be valid and `events` must be a non-empty, unique array).

| Field    | Type      | Required | Description                                                                       |
| -------- | --------- | -------- | --------------------------------------------------------------------------------- |
| `url`    | string    | Yes      | Updated webhook URL (must be a valid URL)                                         |
| `events` | string\[] | Yes      | Updated list of events (replaces existing list; must not be empty, no duplicates) |

## Example request

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X PATCH https://ramp-api.ivorypay.io/api/v1/webhooks/wh-uuid-1 \
  -H "Authorization: Bearer <jwt>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/v2/ivorypay",
    "events": [
      "onramp.success",
      "onramp.failed",
      "offramp.success",
      "offramp.failed",
      "deposit.received",
      "settlement.success",
      "settlement.failed"
    ]
  }'
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const response = await fetch("https://ramp-api.ivorypay.io/api/v1/webhooks/wh-uuid-1", {
  method: "PATCH",
  headers: {
    "Authorization": "Bearer <jwt>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://yourapp.com/webhooks/v2/ivorypay",
    events: [
      "onramp.success",
      "onramp.failed",
      "offramp.success",
      "offramp.failed",
      "deposit.received",
      "settlement.success",
      "settlement.failed",
    ],
  }),
});

const data = await response.json();
console.log(data);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.patch(
    "https://ramp-api.ivorypay.io/api/v1/webhooks/wh-uuid-1",
    headers={
        "Authorization": "Bearer <jwt>",
        "Content-Type": "application/json",
    },
    json={
        "url": "https://yourapp.com/webhooks/v2/ivorypay",
        "events": [
            "onramp.success",
            "onramp.failed",
            "offramp.success",
            "offramp.failed",
            "deposit.received",
            "settlement.success",
            "settlement.failed",
        ],
    },
)

print(response.json())
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := map[string]interface{}{
		"url": "https://yourapp.com/webhooks/v2/ivorypay",
		"events": []string{
			"onramp.success",
			"onramp.failed",
			"offramp.success",
			"offramp.failed",
			"deposit.received",
			"settlement.success",
			"settlement.failed",
		},
	}

	body, _ := json.Marshal(payload)

	req, _ := http.NewRequest("PATCH", "https://ramp-api.ivorypay.io/api/v1/webhooks/wh-uuid-1", bytes.NewBuffer(body))
	req.Header.Set("Authorization", "Bearer <jwt>")
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	respBody, _ := io.ReadAll(resp.Body)
	fmt.Println(string(respBody))
}
```

{% endtab %}
{% endtabs %}

## Example response

```json
{
  "success": true,
  "message": "Webhook was updated successfully",
  "data": {
    "id": "wh-uuid-1",
    "url": "https://yourapp.com/webhooks/v2/ivorypay",
    "environment": "LIVE",
    "events": [
      "onramp.success",
      "onramp.failed",
      "offramp.success",
      "offramp.failed",
      "deposit.received",
      "settlement.success",
      "settlement.failed"
    ]
  }
}
```
