Create a webhook
curl --request POST \
--url https://api.stackone.com/v2/webhooks \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"webhook_url": "https://example.com/stackone/webhooks",
"events": [
"account.created",
"account.updated",
"account.deleted"
],
"label": "Production",
"provider_events": {}
}
'import requests
url = "https://api.stackone.com/v2/webhooks"
payload = {
"webhook_url": "https://example.com/stackone/webhooks",
"events": ["account.created", "account.updated", "account.deleted"],
"label": "Production",
"provider_events": {}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
webhook_url: 'https://example.com/stackone/webhooks',
events: ['account.created', 'account.updated', 'account.deleted'],
label: 'Production',
provider_events: {}
})
};
fetch('https://api.stackone.com/v2/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.stackone.com/v2/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([
'webhook_url' => 'https://example.com/stackone/webhooks',
'events' => [
'account.created',
'account.updated',
'account.deleted'
],
'label' => 'Production',
'provider_events' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.stackone.com/v2/webhooks"
payload := strings.NewReader("{\n \"webhook_url\": \"https://example.com/stackone/webhooks\",\n \"events\": [\n \"account.created\",\n \"account.updated\",\n \"account.deleted\"\n ],\n \"label\": \"Production\",\n \"provider_events\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.stackone.com/v2/webhooks")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"webhook_url\": \"https://example.com/stackone/webhooks\",\n \"events\": [\n \"account.created\",\n \"account.updated\",\n \"account.deleted\"\n ],\n \"label\": \"Production\",\n \"provider_events\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stackone.com/v2/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"webhook_url\": \"https://example.com/stackone/webhooks\",\n \"events\": [\n \"account.created\",\n \"account.updated\",\n \"account.deleted\"\n ],\n \"label\": \"Production\",\n \"provider_events\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"label": "<string>",
"webhook_url": "<string>",
"events": [
"<string>"
],
"status": "active",
"status_reasons": [
{
"timestamp": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>"
}
],
"provider_events": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"signing_secret": "<string>"
}{
"statusCode": 400,
"message": "Bad Request",
"timestamp": "2023-05-30T00:00:00.000Z",
"data": {
"statusCode": 400,
"message": "Bad Request",
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
},
"provider_errors": [
{
"status": 400,
"url": "https://api.provider.com/v1/resource",
"raw": {
"message": "Invalid input parameters"
},
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
}
]
}{
"statusCode": 401,
"message": "Unauthorized",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 403,
"message": "Forbidden resource",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 404,
"message": "Not Found",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 408,
"message": "Request timed out",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 409,
"message": "Conflict",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 422,
"message": "Unprocessable Entity",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 429,
"message": "Too many requests",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 500,
"message": "Internal server error",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 501,
"message": "Not Implemented",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 502,
"message": "Bad Gateway",
"timestamp": "2023-05-30T00:00:00.000Z"
}Create a webhook
Registers a webhook endpoint in the project and returns it with the signing secret used to verify payload signatures. The webhook receives the events listed in events. Connector events are subscribed separately: add the webhook id to webhook_ids in the event_config of a connector profile.
POST
/
v2
/
webhooks
Create a webhook
curl --request POST \
--url https://api.stackone.com/v2/webhooks \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"webhook_url": "https://example.com/stackone/webhooks",
"events": [
"account.created",
"account.updated",
"account.deleted"
],
"label": "Production",
"provider_events": {}
}
'import requests
url = "https://api.stackone.com/v2/webhooks"
payload = {
"webhook_url": "https://example.com/stackone/webhooks",
"events": ["account.created", "account.updated", "account.deleted"],
"label": "Production",
"provider_events": {}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
webhook_url: 'https://example.com/stackone/webhooks',
events: ['account.created', 'account.updated', 'account.deleted'],
label: 'Production',
provider_events: {}
})
};
fetch('https://api.stackone.com/v2/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.stackone.com/v2/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([
'webhook_url' => 'https://example.com/stackone/webhooks',
'events' => [
'account.created',
'account.updated',
'account.deleted'
],
'label' => 'Production',
'provider_events' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.stackone.com/v2/webhooks"
payload := strings.NewReader("{\n \"webhook_url\": \"https://example.com/stackone/webhooks\",\n \"events\": [\n \"account.created\",\n \"account.updated\",\n \"account.deleted\"\n ],\n \"label\": \"Production\",\n \"provider_events\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.stackone.com/v2/webhooks")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"webhook_url\": \"https://example.com/stackone/webhooks\",\n \"events\": [\n \"account.created\",\n \"account.updated\",\n \"account.deleted\"\n ],\n \"label\": \"Production\",\n \"provider_events\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stackone.com/v2/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"webhook_url\": \"https://example.com/stackone/webhooks\",\n \"events\": [\n \"account.created\",\n \"account.updated\",\n \"account.deleted\"\n ],\n \"label\": \"Production\",\n \"provider_events\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"label": "<string>",
"webhook_url": "<string>",
"events": [
"<string>"
],
"status": "active",
"status_reasons": [
{
"timestamp": "2023-11-07T05:31:56Z",
"code": "<string>",
"description": "<string>"
}
],
"provider_events": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"signing_secret": "<string>"
}{
"statusCode": 400,
"message": "Bad Request",
"timestamp": "2023-05-30T00:00:00.000Z",
"data": {
"statusCode": 400,
"message": "Bad Request",
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
},
"provider_errors": [
{
"status": 400,
"url": "https://api.provider.com/v1/resource",
"raw": {
"message": "Invalid input parameters"
},
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
}
]
}{
"statusCode": 401,
"message": "Unauthorized",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 403,
"message": "Forbidden resource",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 404,
"message": "Not Found",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 408,
"message": "Request timed out",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 409,
"message": "Conflict",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 422,
"message": "Unprocessable Entity",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 429,
"message": "Too many requests",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 500,
"message": "Internal server error",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 501,
"message": "Not Implemented",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 502,
"message": "Bad Gateway",
"timestamp": "2023-05-30T00:00:00.000Z"
}Authorizations
Query Parameters
Body
application/json
The events the webhook is subscribed to. Send an empty list for a webhook that only receives connector events routed to it from a connector profile.
A unified webhook event type.
Available options:
account.created, account.updated, account.deleted, hris_employees.created, hris_employees.updated, hris_employees.deleted, hris_employments.created, hris_employments.updated, hris_employments.deleted, hris_time_off.created, hris_time_off.updated, hris_time_off.deleted, hris_tasks.created, hris_tasks.updated, hris_tasks.deleted, hris_shifts.created, hris_shifts.updated, hris_shifts.deleted, ats_assessments.created, ats_background_checks.created, ats_candidates.created, ats_candidates.updated, ats_candidates.deleted, ats_applications.created, ats_applications.updated, ats_applications.deleted, ats_interviews.created, ats_interviews.updated, ats_interviews.deleted, ats_jobs.created, ats_jobs.updated, ats_jobs.deleted, ats_job_postings.created, ats_job_postings.updated, ats_job_postings.deleted, ats_users.created, ats_users.updated, ats_users.deleted, ats_lists.created, ats_lists.updated, ats_lists.deleted, crm_contacts.created, crm_contacts.updated, crm_contacts.deleted, crm_accounts.created, crm_accounts.updated, crm_accounts.deleted, lms_completions.created, lms_completions.updated, lms_completions.deleted, lms_content.created, lms_content.updated, lms_content.deleted, lms_assignments.created, lms_assignments.updated, lms_assignments.deleted, lms_courses.created, lms_courses.updated, lms_courses.deleted, lms_users.created, lms_users.updated, lms_users.deleted, documents_files.created, documents_files.updated, documents_files.deleted, documents_folders.created, documents_folders.updated, documents_folders.deleted, documents_drives.created, documents_drives.updated, documents_drives.deleted, screening_results.created, screening_results.updated, screening_results.deleted Example:
[
"account.created",
"account.updated",
"account.deleted"
]
Response
The webhook was created.
Was this page helpful?