Code Samples #
Copy
curl --request POST \
--url 'https://api.taskflow.example.com/v2/webhooks' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://example.com",
"events": [
"job.done"
]
}'
const response = await fetch('https://api.taskflow.example.com/v2/webhooks', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"url": "https://example.com",
"events": [
"job.done"
]
})
});
const data = await response.json();
console.log(data);
import requests
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"url": "https://example.com",
"events": [
"job.done"
]
}
response = requests.post("https://api.taskflow.example.com/v2/webhooks", headers=headers, json=payload)
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.taskflow.example.com/v2/webhooks',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_TOKEN',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => '{
"url": "https://example.com",
"events": [
"job.done"
]
}',
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
using System.Net.Http;
using System.Text;
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.taskflow.example.com/v2/webhooks");
request.Headers.Add("Authorization", "Bearer YOUR_TOKEN");
request.Content = new StringContent(@"{
""url"": ""https://example.com"",
""events"": [
""job.done""
]
}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.taskflow.example.com/v2/webhooks"))
.header("Authorization", "Bearer YOUR_TOKEN")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"url": "https://example.com",
"events": [
"job.done"
]
}
"""))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Response #
Copy
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"url": "https://example.com",
"events": [
"string"
]
}
Request Body #
Content type: application/json — required
| Field | Type | Required | Description |
|---|---|---|---|
url | string (uri) | Required | |
events | array of string | Required |
Example request
Copy
{
"url": "https://example.com",
"events": [
"job.done"
]
}
Responses #
201 — Subscribed #
| Field | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | Optional | |
url | string (uri) | Optional | |
events | array of string | Optional |
Example 201 response
Copy
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"url": "https://example.com",
"events": [
"string"
]
}