Skip to main content
POST
/
webhook-subscriptions
Create 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  \"url\": \"<string>\"\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 \"url\": \"<string>\"\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 \"url\": \"<string>\"\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([
'url' => '<string>'
]),
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 = { "url": "<string>" }
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({url: '<string>'})
};

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 '
{
"url": "<string>"
}
'
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "active": true,
  "url": "<string>",
  "rotating": true,
  "type": "webhook-subscription",
  "merchant_account_id": "default",
  "authentication": {
    "kind": "basic",
    "password": "********",
    "username": "gr4vy"
  },
  "secret": "234567890abcdef1234567890abcdef",
  "creator": {
    "email_address": "jhon.doe@gr4vy.com",
    "id": "07e70d14-a0c0-4ff5-bd4a-509959af0e4d",
    "name": "Jhon Doe"
  }
}
{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Generic error",
"details": []
}
{
"type": "error",
"code": "unauthorized",
"status": 401,
"message": "No valid API authentication found",
"details": []
}
{
"type": "error",
"code": "forbidden",
"status": 403,
"message": "Generic error",
"details": []
}
{
"type": "error",
"code": "not_found",
"status": 404,
"message": "The resource could not be found",
"details": []
}
{
"type": "error",
"code": "method_not_allowed",
"status": 405,
"message": "Method Not Allowed",
"details": []
}
{
"type": "error",
"code": "duplicate_record",
"status": 409,
"message": "Generic error",
"details": [],
"resource_id": "cdc70639-cb9c-4222-a73f-b8ce39f7821b"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
{
"type": "error",
"code": "too_early",
"status": 425,
"message": "Generic error",
"details": []
}
{
"type": "error",
"code": "too_many_requests",
"status": 429,
"message": "Generic error",
"details": []
}
{
"type": "error",
"code": "server_error",
"status": 500,
"message": "Request could not be processed",
"details": []
}
{
"type": "error",
"code": "bad_gateway",
"status": 502,
"message": "Request could not be processed",
"details": []
}
{
"type": "error",
"code": "gateway_timeout",
"status": 504,
"message": "Request could not be processed",
"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 use for this request.

Example:

"default"

Body

application/json
url
string
required

URL to send webhook payloads.

Example:

"https://www.gr4vy.com/webhooks"

active
boolean
default:true

Flag to determine whether this subscription should be sent webhook payloads.

Examples:

true

false

authentication
BasicAuthenticationCreate · object

Optional authentication configuration for webhook requests.

Example:
{
"kind": "basic",
"password": "super-strong-password",
"username": "gr4vy"
}

Response

Successful Response

id
string<uuid>
required

The ID of the webhook subscription

Example:

"ef9496d8-53a5-4aad-8ca2-00eb68334389"

active
boolean
required

Flag to determine whether this subscription should be sent webhook payloads.

Examples:

true

false

url
string
required

URL to send webhook payloads.

Example:

"https://www.gr4vy.com/webhooks"

rotating
boolean
required

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

Examples:

false

true

type
string
default:webhook-subscription

Type of resource for webhook subscriptions.

Allowed value: "webhook-subscription"
Example:

"webhook-subscription"

merchant_account_id
string | null

The merchant account to which this subscription is associated. When null this represents an instance level webhook.

Example:

"default"

authentication
BasicAuthentication · object

Optional authentication configuration for webhook requests.

Example:
{
"kind": "basic",
"password": "********",
"username": "gr4vy"
}
secret
string | null

The active secret value.

Example:

"234567890abcdef1234567890abcdef"

creator
Creator · object | null

The user that created this resource

Example:
{
"email_address": "jhon.doe@gr4vy.com",
"id": "07e70d14-a0c0-4ff5-bd4a-509959af0e4d",
"name": "Jhon Doe"
}