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

# Create a Webhook

> Create a webhook using Razorpay Curlec APIs to receive event notifications.

Available in
🇮🇳 India
🇲🇾 Malaysia
🇺🇸 United States

Use this API endpoint to create a webhook. Know about the various error responses for this API.

> [!NOTE]
>
> **Handy Tips**
>
> You can create up to 30 webhooks for an `account_id`.

```bash Curl theme={null}
curl -X POST https://api.razorpay.com/v2/accounts/acc_JOGUdtKu3dB03d/webhooks \
-u <ACCESS_TOKEN> \
-H "Content-Type: application/json" \
-d '{
  "url": "https://google.com",
  "alert_email": "gaurav.kumar@example.com",
  "secret": "12345",
  "events": [
    "payment.authorized",
    "payment.failed",
    "payment.captured",
    "payment.dispute.created",
    "refund.failed",
    "refund.created"
  ]
}'
```

```java Java theme={null}
RazorpayClient razorpay = new RazorpayClient("[ACCESS_TOKEN]");

String accountId = "acc_GP4lfNA0iIMn5B";

JSONObject webhookRequest = new JSONObject();
webhookRequest.put("url","https://google.com");
webhookRequest.put("alert_email","gaurav.kumar@example.com");
webhookRequest.put("secret","12345");

ArrayList<String> events = new ArrayList<String>();
events.add("payment.authorized");
events.add("payment.failed");
events.add("payment.captured");
events.add("payment.dispute.created");
events.add("refund.failed");
events.add("refund.created");

webhookRequest.put("events",events);

Webhook webhook = instance.webhook.create(accountId, webhookRequest);
```

```ruby Ruby theme={null}
require "razorpay"
Razorpay.setup('ACCESS_TOKEN')
accountId = "acc_GP4lfNA0iIMn5B"

Razorpay::Webhook.create({
  "url": "https://google.com",
  "alert_email": "gaurav.kumar@example.com",
  "secret": "12345",
  "events": [
    "payment.authorized",
    "payment.failed",
    "payment.captured",
    "payment.dispute.created",
    "refund.failed",
    "refund.created"
  ]
}, accountId)
```

```csharp .NET theme={null}
RazorpayClient client = new RazorpayClient("[ACCESS_TOKEN]");

String accountId = "acc_ua2tBezhcEBvap";

Dictionary<string, object> webhookRequest = new Dictionary<string, object>();
webhookRequest.Add("url", "https://www.google.com");
webhookRequest.Add("alert_email", "gaurav.kumar@example.com");
List<string> events = new List<string>();
events.Add("refund.created");
events.Add("payment.authorized");
events.Add("payment.failed");
events.Add("payment.captured");
events.Add("payment.dispute.created");
events.Add("refund.failed");
events.Add("refund.created");
webhookRequest.Add("secret", "12345");
webhookRequest.Add("events", events);

Webhook webhook = client.Webhook.Create(webhookRequest, accountId);
```

```json Success theme={null}
{
  "id": "JebiXkKGYwua5L",
  "created_at": 1654605478,
  "updated_at": 1654605478,
  "service": "beta-api-live",
  "owner_id": "JOGUdtKu3dB03d",
  "owner_type": "merchant",
  "context": [],
  "disabled_at": 0,
  "url": "https://google.com",
  "alert_email": "gaurav.kumar@example.com",
  "secret_exists": true,
  "entity": "webhook",
  "active": true,
  "events": [
    "payment.authorized",
    "payment.failed",
    "payment.captured",
    "payment.dispute.created",
    "refund.failed",
    "refund.created"
  ]
}
```

## Path Parameters

**account\_id** `string` *required*

The unique identifier of the sub-merchant account generated by Razorpay Curlec for which a webhook is created. For example, `acc_H3kYHQ635sBwXG`. This id is used to fetch, update and delete a webhook. The webhook is created for this sub-merchant account id.

## Request Parameters

**url** `string` *required*

The URL where you receive the webhook payload when an event is triggered. The maximum length is 255 characters.

**alert\_email** `string`

This is the email address to which notifications must be sent in case of webhook failure.

**secret** `string`

A secret for the webhook endpoint that is used to validate that the webhook is from Razorpay Curlec.

**events** `object` *required*

The required events from the list of Active Events. For example, `payment.authorized`, `payment.captured`, `payment.failed`, `payment.dispute.created`, `refund.failed`, `refund.created` and so on.

## Response Parameters

**id** `string`

The unique identifier of the webhook generated by Razorpay Curlec. For example, `HK890egfiItP3H`.

**created\_at** `integer`

The Unix timestamp at which the webhook has been created.

**updated\_at** `integer`

The Unix timestamp at which the webhook has been updated.

**owner\_id** `string`

The unique identifier generated by Razorpay Curlec for the sub-merchant who will receive the webhooks. For example, in this case, it will be `account_id` passed in the API URL.

**owner\_type** `string`

Indicates the type of owner. For example, in this case, it will be the merchant.

**url** `string`

The URL where you receive the webhook payload when an event is triggered. The maximum length is 255 characters.

**secret** `string`

A secret for the webhook endpoint used to validate that the webhook is from Razorpay Curlec.

**alert\_email** `string`

This is the email address to which notifications must be sent in case of webhook failure.

**secret\_exists** `boolean`

This attribute will be set to `true` if a secret password has been set for the webhook endpoint.

**entity** `string`

Indicates the type of entity. For example, in this case, it will be **webhook**.

**active** `string`

Indicates the status of webhook.

* `true`: Webhook in an activated state.
* `false`: Webhook in a deactivated state.

**events** `object`

The required events from the list of Active Events. For example, `payment.authorized`, `payment.captured`, `payment.failed`, `payment.dispute.created`, `refund.failed`, `refund.created` and so on.
