Create webhook definition
curl --request POST \
--url https://prod01.oms.fabric.inc/api/v2/webhook/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"target": "http://www.test.com",
"protocol": "HTTP",
"source": "OMS",
"events": "[ORDER_CREATED]",
"tenantId": "<string>",
"targetApiKey": "adfasdWdsaQFSsdf",
"apiVersion": "<string>",
"format": "application/json",
"callbackUrl": "<string>",
"createdDate": "2023-11-07T05:31:56Z",
"updatedDate": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://prod01.oms.fabric.inc/api/v2/webhook/"
payload = {
"target": "http://www.test.com",
"protocol": "HTTP",
"source": "OMS",
"events": "[ORDER_CREATED]",
"tenantId": "<string>",
"targetApiKey": "adfasdWdsaQFSsdf",
"apiVersion": "<string>",
"format": "application/json",
"callbackUrl": "<string>",
"createdDate": "2023-11-07T05:31:56Z",
"updatedDate": "2023-11-07T05:31:56Z"
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
target: 'http://www.test.com',
protocol: 'HTTP',
source: 'OMS',
events: '[ORDER_CREATED]',
tenantId: '<string>',
targetApiKey: 'adfasdWdsaQFSsdf',
apiVersion: '<string>',
format: 'application/json',
callbackUrl: '<string>',
createdDate: '2023-11-07T05:31:56Z',
updatedDate: '2023-11-07T05:31:56Z'
})
};
fetch('https://prod01.oms.fabric.inc/api/v2/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://prod01.oms.fabric.inc/api/v2/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([
'target' => 'http://www.test.com',
'protocol' => 'HTTP',
'source' => 'OMS',
'events' => '[ORDER_CREATED]',
'tenantId' => '<string>',
'targetApiKey' => 'adfasdWdsaQFSsdf',
'apiVersion' => '<string>',
'format' => 'application/json',
'callbackUrl' => '<string>',
'createdDate' => '2023-11-07T05:31:56Z',
'updatedDate' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$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://prod01.oms.fabric.inc/api/v2/webhook/"
payload := strings.NewReader("{\n \"target\": \"http://www.test.com\",\n \"protocol\": \"HTTP\",\n \"source\": \"OMS\",\n \"events\": \"[ORDER_CREATED]\",\n \"tenantId\": \"<string>\",\n \"targetApiKey\": \"adfasdWdsaQFSsdf\",\n \"apiVersion\": \"<string>\",\n \"format\": \"application/json\",\n \"callbackUrl\": \"<string>\",\n \"createdDate\": \"2023-11-07T05:31:56Z\",\n \"updatedDate\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://prod01.oms.fabric.inc/api/v2/webhook/")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"target\": \"http://www.test.com\",\n \"protocol\": \"HTTP\",\n \"source\": \"OMS\",\n \"events\": \"[ORDER_CREATED]\",\n \"tenantId\": \"<string>\",\n \"targetApiKey\": \"adfasdWdsaQFSsdf\",\n \"apiVersion\": \"<string>\",\n \"format\": \"application/json\",\n \"callbackUrl\": \"<string>\",\n \"createdDate\": \"2023-11-07T05:31:56Z\",\n \"updatedDate\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://prod01.oms.fabric.inc/api/v2/webhook/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"target\": \"http://www.test.com\",\n \"protocol\": \"HTTP\",\n \"source\": \"OMS\",\n \"events\": \"[ORDER_CREATED]\",\n \"tenantId\": \"<string>\",\n \"targetApiKey\": \"adfasdWdsaQFSsdf\",\n \"apiVersion\": \"<string>\",\n \"format\": \"application/json\",\n \"callbackUrl\": \"<string>\",\n \"createdDate\": \"2023-11-07T05:31:56Z\",\n \"updatedDate\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"target": "http://www.test.com",
"protocol": "HTTP",
"source": "OMS",
"events": "[ORDER_CREATED]",
"requestType": "POST",
"webhookId": "<string>",
"tenantId": "<string>",
"targetApiKey": "adfasdWdsaQFSsdf",
"apiVersion": "<string>",
"format": "application/json",
"callbackUrl": "<string>",
"createdDate": "2023-11-07T05:31:56Z",
"updatedDate": "2023-11-07T05:31:56Z"
}{
"message": "Webhook Definition with target, tenantId, protocol, source, apiVersion already exists!"
}{
"message": "Internal Server Error"
}Webhook
Create webhook definition
Creates webhook definition with the given target, events, request type, and other values as passed in the request body.
POST
/
webhook
/
Create webhook definition
curl --request POST \
--url https://prod01.oms.fabric.inc/api/v2/webhook/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"target": "http://www.test.com",
"protocol": "HTTP",
"source": "OMS",
"events": "[ORDER_CREATED]",
"tenantId": "<string>",
"targetApiKey": "adfasdWdsaQFSsdf",
"apiVersion": "<string>",
"format": "application/json",
"callbackUrl": "<string>",
"createdDate": "2023-11-07T05:31:56Z",
"updatedDate": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://prod01.oms.fabric.inc/api/v2/webhook/"
payload = {
"target": "http://www.test.com",
"protocol": "HTTP",
"source": "OMS",
"events": "[ORDER_CREATED]",
"tenantId": "<string>",
"targetApiKey": "adfasdWdsaQFSsdf",
"apiVersion": "<string>",
"format": "application/json",
"callbackUrl": "<string>",
"createdDate": "2023-11-07T05:31:56Z",
"updatedDate": "2023-11-07T05:31:56Z"
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
target: 'http://www.test.com',
protocol: 'HTTP',
source: 'OMS',
events: '[ORDER_CREATED]',
tenantId: '<string>',
targetApiKey: 'adfasdWdsaQFSsdf',
apiVersion: '<string>',
format: 'application/json',
callbackUrl: '<string>',
createdDate: '2023-11-07T05:31:56Z',
updatedDate: '2023-11-07T05:31:56Z'
})
};
fetch('https://prod01.oms.fabric.inc/api/v2/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://prod01.oms.fabric.inc/api/v2/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([
'target' => 'http://www.test.com',
'protocol' => 'HTTP',
'source' => 'OMS',
'events' => '[ORDER_CREATED]',
'tenantId' => '<string>',
'targetApiKey' => 'adfasdWdsaQFSsdf',
'apiVersion' => '<string>',
'format' => 'application/json',
'callbackUrl' => '<string>',
'createdDate' => '2023-11-07T05:31:56Z',
'updatedDate' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$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://prod01.oms.fabric.inc/api/v2/webhook/"
payload := strings.NewReader("{\n \"target\": \"http://www.test.com\",\n \"protocol\": \"HTTP\",\n \"source\": \"OMS\",\n \"events\": \"[ORDER_CREATED]\",\n \"tenantId\": \"<string>\",\n \"targetApiKey\": \"adfasdWdsaQFSsdf\",\n \"apiVersion\": \"<string>\",\n \"format\": \"application/json\",\n \"callbackUrl\": \"<string>\",\n \"createdDate\": \"2023-11-07T05:31:56Z\",\n \"updatedDate\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://prod01.oms.fabric.inc/api/v2/webhook/")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"target\": \"http://www.test.com\",\n \"protocol\": \"HTTP\",\n \"source\": \"OMS\",\n \"events\": \"[ORDER_CREATED]\",\n \"tenantId\": \"<string>\",\n \"targetApiKey\": \"adfasdWdsaQFSsdf\",\n \"apiVersion\": \"<string>\",\n \"format\": \"application/json\",\n \"callbackUrl\": \"<string>\",\n \"createdDate\": \"2023-11-07T05:31:56Z\",\n \"updatedDate\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://prod01.oms.fabric.inc/api/v2/webhook/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"target\": \"http://www.test.com\",\n \"protocol\": \"HTTP\",\n \"source\": \"OMS\",\n \"events\": \"[ORDER_CREATED]\",\n \"tenantId\": \"<string>\",\n \"targetApiKey\": \"adfasdWdsaQFSsdf\",\n \"apiVersion\": \"<string>\",\n \"format\": \"application/json\",\n \"callbackUrl\": \"<string>\",\n \"createdDate\": \"2023-11-07T05:31:56Z\",\n \"updatedDate\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"target": "http://www.test.com",
"protocol": "HTTP",
"source": "OMS",
"events": "[ORDER_CREATED]",
"requestType": "POST",
"webhookId": "<string>",
"tenantId": "<string>",
"targetApiKey": "adfasdWdsaQFSsdf",
"apiVersion": "<string>",
"format": "application/json",
"callbackUrl": "<string>",
"createdDate": "2023-11-07T05:31:56Z",
"updatedDate": "2023-11-07T05:31:56Z"
}{
"message": "Webhook Definition with target, tenantId, protocol, source, apiVersion already exists!"
}{
"message": "Internal Server Error"
}The following endpoint is deprecated.
Authorizations
Headers
The x-site-context header is a JSON object that contains information about the source you wish to pull from. The mandatory account is the 24 character identifier found in Copilot. The channel (Sales channel ID), stage (environment name), and date attributes can be used to further narrow the scope of your data source.
Example:
"{\"date\": \"2023-01-01T00:00:00.000Z\", \"channel\": 12, \"account\": \"1234abcd5678efgh9ijklmno\",\"stage\":\"production\"}"
Body
application/json
Request model for Webhook Definition
Response
Returns Webhook Definition that is successfully created
Request model for Updating Webhook Definition
Was this page helpful?
