API Test Keys

Create a Webhook

POST
/v2/accounts/:account_id/webhooks

Click to copy

Use this API endpoint to create a webhook. Know about the

for this API.

Handy Tips

You can create up to 30 webhooks for an account_id.

Is this page helpful?

Curl

change language

change language

1
curl -u <YOUR_KEY_ID>:<YOUR_KEY_SECRET> \
2
-X POST https://api.razorpay.com/v2/accounts/acc_JOGUdtKu3dB03d/webhooks \
3
-H "Content-Type: application/json" \
4
-d '{
5
"url": "https://google.com",
6
"alert_email": "gaurav.kumar@example.com",
7
"secret": "12345",
8
"events": [
9
"payment.authorized",
10
"payment.failed",
11
"payment.captured",
12
"payment.dispute.created",
13
"refund.failed",
14
"refund.created"
15
]
16
}'

Success

1
{
2
"id": "JebiXkKGYwua5L",
3
"created_at": 1654605478,
4
"updated_at": 1654605478,
5
"service": "beta-api-live",
6
"owner_id": "JOGUdtKu3dB03d",
7
"owner_type": "merchant",
8
"context": [],
9
"disabled_at": 0,
10
"url": "https://google.com",
11
"alert_email": "gaurav.kumar@example.com",
12
"secret_exists": true,
13
"entity": "webhook",
14
"active": true,
15
"events": [
16
"payment.authorized",
17
"payment.failed",
18
"payment.captured",
19
"payment.dispute.created",
20
"refund.failed",
21
"refund.created"
22
]
23
}
Path Parameters
account_id

*

string

The unique identifier of the sub-merchant account generated by Razorpay 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

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.

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.

Response Parameters
id
string

The unique identifier of the webhook generated by Razorpay. 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 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.

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.

Create a Webhook

POST
/v2/accounts/:account_id/webhooks

Click to copy

Use this API endpoint to create a webhook. Know about the

for this API.

Handy Tips

You can create up to 30 webhooks for an account_id.

Is this page helpful?

Path Parameters
account_id

*

string

The unique identifier of the sub-merchant account generated by Razorpay 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

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.

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.

Response Parameters
id
string

The unique identifier of the webhook generated by Razorpay. 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 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.

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.

Curl

change language

change language

1
curl -u <YOUR_KEY_ID>:<YOUR_KEY_SECRET> \
2
-X POST https://api.razorpay.com/v2/accounts/acc_JOGUdtKu3dB03d/webhooks \
3
-H "Content-Type: application/json" \
4
-d '{
5
"url": "https://google.com",
6
"alert_email": "gaurav.kumar@example.com",
7
"secret": "12345",
8
"events": [
9
"payment.authorized",
10
"payment.failed",
11
"payment.captured",
12
"payment.dispute.created",
13
"refund.failed",
14
"refund.created"
15
]
16
}'

Success

1
{
2
"id": "JebiXkKGYwua5L",
3
"created_at": 1654605478,
4
"updated_at": 1654605478,
5
"service": "beta-api-live",
6
"owner_id": "JOGUdtKu3dB03d",
7
"owner_type": "merchant",
8
"context": [],
9
"disabled_at": 0,
10
"url": "https://google.com",
11
"alert_email": "gaurav.kumar@example.com",
12
"secret_exists": true,
13
"entity": "webhook",
14
"active": true,
15
"events": [
16
"payment.authorized",
17
"payment.failed",
18
"payment.captured",
19
"payment.dispute.created",
20
"refund.failed",
21
"refund.created"
22
]
23
}