Skip to main content
POST
/
webhook-subscriptions
New webhook subscription
using RestSharp;


var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"active\": true,\n  \"url\": \"https://example.com/webhooks\",\n  \"authentication\": {\n    \"kind\": \"basic\",\n    \"username\": \"username\",\n    \"password\": \"password\"\n  }\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions"

payload := strings.NewReader("{\n \"active\": true,\n \"url\": \"https://example.com/webhooks\",\n \"authentication\": {\n \"kind\": \"basic\",\n \"username\": \"username\",\n \"password\": \"password\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"active\": true,\n \"url\": \"https://example.com/webhooks\",\n \"authentication\": {\n \"kind\": \"basic\",\n \"username\": \"username\",\n \"password\": \"password\"\n }\n}")
.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'active' => true,
'url' => 'https://example.com/webhooks',
'authentication' => [
'kind' => 'basic',
'username' => 'username',
'password' => 'password'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests

url = "https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions"

payload = {
"active": True,
"url": "https://example.com/webhooks",
"authentication": {
"kind": "basic",
"username": "username",
"password": "password"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
active: true,
url: 'https://example.com/webhooks',
authentication: {kind: 'basic', username: 'username', password: 'password'}
})
};

fetch('https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
curl --request POST \
--url https://api.sandbox.{id}.gr4vy.app/webhook-subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"active": true,
"url": "https://example.com/webhooks",
"authentication": {
"kind": "basic",
"username": "username",
"password": "password"
}
}
'
{
  "type": "webhook-subscription",
  "id": "8fd77b13-a5e3-43de-bd54-26a8a714ac18",
  "merchant_account_id": "default",
  "active": true,
  "url": "https://example.com/webhooks",
  "authentication": {
    "kind": "basic",
    "username": "username",
    "password": "password"
  },
  "secret": "234567890abcdef1234567890abcdef",
  "rotating": false
}
{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Missing '****' field",
"details": [
{
"location": "body",
"type": "value_error.missing",
"pointer": "/payment_method/number",
"message": "field required"
}
]
}
{
"type": "error",
"code": "not_found",
"status": 404,
"message": "The resource could not be found",
"details": []
}
This endpoint requires the webhook-subscriptions.write scope.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

X-Gr4vy-Merchant-Account-ID
string

The ID of the merchant account to act upon. When not or provided, this value will default to the first merchant account a user has access to. This value can be set to * on some APIs to fetch resources from all merchant accounts.

Maximum string length: 255
Example:

"default"

Body

application/json
active
boolean

Defines if this subscription is currently active or not. When deactivated, webhook events are not sent to the endpoint configured for this subscription.

Example:

true

url
string<uri>

The URL of the endpoint to deliver webhook events to.

Example:

"https://example.com/webhooks"

authentication
Webhook subscription authentication · object | null

Response

Returns the new webhook subscription.

type
enum<string>

webhook-subscription.

Available options:
webhook-subscription
Example:

"webhook-subscription"

id
string

The unique Gr4vy ID for this webhook subscription.

Example:

"8fd77b13-a5e3-43de-bd54-26a8a714ac18"

merchant_account_id
string | null

The unique ID for a merchant account.

Example:

"default"

active
boolean

Defines if this subscription is currently active or not. When deactivated, webhook events are not sent to the endpoint configured for this subscription.

Example:

true

url
string<uri>

The URL of the endpoint to deliver webhook events to.

Example:

"https://example.com/webhooks"

authentication
Webhook subscription authentication · object | null
secret
string | null

The active secret value.

Example:

"234567890abcdef1234567890abcdef"

rotating
boolean

Flag to determine whether the subscription has a secret rotation in progress or not.

Example:

false