Skip to main content
POST
/
webhooks
Create a webhook subscription
curl --request POST \
  --url https://api-dev.narrative.io/webhooks \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "type": "webhook_subscription_app",
  "app_id": "32b83061-e41b-4789-8d62-f1d4f1faf07e",
  "url": "https://example.com/123",
  "name": "some_webhook"
}
'
import requests

url = "https://api-dev.narrative.io/webhooks"

payload = {
"type": "webhook_subscription_app",
"app_id": "32b83061-e41b-4789-8d62-f1d4f1faf07e",
"url": "https://example.com/123",
"name": "some_webhook"
}
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({
type: 'webhook_subscription_app',
app_id: '32b83061-e41b-4789-8d62-f1d4f1faf07e',
url: 'https://example.com/123',
name: 'some_webhook'
})
};

fetch('https://api-dev.narrative.io/webhooks', 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-dev.narrative.io/webhooks",
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([
'type' => 'webhook_subscription_app',
'app_id' => '32b83061-e41b-4789-8d62-f1d4f1faf07e',
'url' => 'https://example.com/123',
'name' => 'some_webhook'
]),
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;
}
package main

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

func main() {

url := "https://api-dev.narrative.io/webhooks"

payload := strings.NewReader("{\n \"type\": \"webhook_subscription_app\",\n \"app_id\": \"32b83061-e41b-4789-8d62-f1d4f1faf07e\",\n \"url\": \"https://example.com/123\",\n \"name\": \"some_webhook\"\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-dev.narrative.io/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"webhook_subscription_app\",\n \"app_id\": \"32b83061-e41b-4789-8d62-f1d4f1faf07e\",\n \"url\": \"https://example.com/123\",\n \"name\": \"some_webhook\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api-dev.narrative.io/webhooks")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"webhook_subscription_app\",\n \"app_id\": \"32b83061-e41b-4789-8d62-f1d4f1faf07e\",\n \"url\": \"https://example.com/123\",\n \"name\": \"some_webhook\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "secret": "8b6dba8c-9a8b-4a3a-8469-9dc7a33c3e17",
  "status": "active",
  "companyId": 42,
  "jobIds": [
    "d35a12c1-7a2f-46b9-8d60-9e0a2a84c205",
    "9a3cf334-4c6d-4d3f-a7d6-22b6e6f2ac1b"
  ],
  "jobStates": [
    "pending",
    "running",
    "completed"
  ],
  "jobTypes": [
    "forecast",
    "materialized-view"
  ],
  "url": "https://webhooks.mycompany.com/events",
  "createdAt": "2025-04-29T16:12:45.123456",
  "updatedAt": "2025-04-29T16:12:45.123456"
}

Authorizations

Authorization
string
header
required

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

Body

application/json
type
enum<string>
required
Available options:
webhook_subscription_app
app_id
string<uuid>
required
url
string<uri>
required
name
string

Response

200 - application/json

Created

id
string<uuid>
required
secret
string<uuid>
required
status
enum<string>
required
Available options:
active,
archived
companyId
string
required
url
string<uri>
required
createdAt
string<date-time>
required
updatedAt
string<date-time>
required
jobIds
enum<string>[]
Available options:
costs,
datasets_calculate_column_stats,
datasets_delete_table,
datasets_deliver_data,
datasets_sample,
datasets_suggest_mappings,
delete-snowflake-table,
forecast,
materialize-view,
models_deliver_model,
model_training_run,
nql-forecast,
upload-stats
jobStates
enum<string>[]
Available options:
pending,
running,
completed,
pending_cancellation,
cancelled,
failed
jobTypes
string[]