Skip to main content
POST
/
webhook
cURL
curl --request POST \
  --url https://api.openformat.tech/v1/webhook \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "url": "https://api.example.com/webhook",
  "events": [
    "transaction"
  ]
}
'
import requests

url = "https://api.openformat.tech/v1/webhook"

payload = {
"url": "https://api.example.com/webhook",
"events": ["transaction"]
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://api.example.com/webhook', events: ['transaction']})
};

fetch('https://api.openformat.tech/v1/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openformat.tech/v1/webhook",
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' => 'https://api.example.com/webhook',
'events' => [
'transaction'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);

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

curl_close($curl);

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

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

func main() {

url := "https://api.openformat.tech/v1/webhook"

payload := strings.NewReader("{\n \"url\": \"https://api.example.com/webhook\",\n \"events\": [\n \"transaction\"\n ]\n}")

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

req.Header.Add("X-API-KEY", "<api-key>")
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.openformat.tech/v1/webhook")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://api.example.com/webhook\",\n \"events\": [\n \"transaction\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.openformat.tech/v1/webhook")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://api.example.com/webhook\",\n \"events\": [\n \"transaction\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "webhook": {
    "id": 123,
    "url": "https://api.example.com/webhook",
    "events": [
      "transaction"
    ],
    "disabled": true,
    "disabled_at": "2024-01-23 01:23:45.55338+00",
    "created_at": "2024-01-23 01:23:45.55338+00"
  }
}
{
  "status": "failed",
  "error": "Only HTTPS urls allowed"
}
{
  "status": "failed",
  "error": "Invalid url"
}
{
  "status": "failed",
  "error": "Webhook events not found"
}
{
  "status": "failed",
  "error": "Database operation failed"
}
{
  "status": "success",
  "webhook": {
    "id": 123,
    "url": "https://api.example.com/webhook",
    "events": [
      "transaction"
    ],
    "disabled": true,
    "disabled_at": "2024-01-23 01:23:45.55338+00",
    "created_at": "2024-01-23 01:23:45.55338+00"
  }
}
{
  "status": "failed",
  "error": "Only HTTPS urls allowed"
}
{
  "status": "failed",
  "error": "Invalid url"
}
{
  "status": "failed",
  "error": "Webhook events not found"
}
{
  "status": "failed",
  "error": "Database operation failed"
}

Authorizations

X-API-KEY
string
header
required

Body

application/json
url
string
required

Webhook URL to send the payload, only HTTPS supported

Minimum string length: 1
Example:

"https://api.example.com/webhook"

events
string[]

List of events that will trigger the webhook call, if empty all events will be used

Example:
["transaction"]

Response

Created webhook

status
enum<string>
required

Successful reponse status

Available options:
success
Example:

"success"

webhook
object
required

The webhook data