curl --request POST \
--url https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "projects.created"
}
'import requests
url = "https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events"
payload = { "event": "projects.created" }
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({event: 'projects.created'})
};
fetch('https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events', 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.contractorscloud.com/api/v1/webhooks/{webhookId}/events",
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([
'event' => 'projects.created'
]),
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.contractorscloud.com/api/v1/webhooks/{webhookId}/events"
payload := strings.NewReader("{\n \"event\": \"projects.created\"\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.contractorscloud.com/api/v1/webhooks/{webhookId}/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"projects.created\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events")
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 \"event\": \"projects.created\"\n}"
response = http.request(request)
puts response.read_body{
"id": "b7e4a1c9-3d6f-4b2a-9c8e-5f1d3a7b9c40",
"webhook_id": "a3d8f2e6-1c4b-4a9d-8e3f-2b5a7c9d4f60",
"event": "projects.created",
"created_at": "2025-02-11 09:05:00",
"updated_at": "2025-02-11 09:05:00"
}{
"message": "Unauthenticated."
}{
"message": "The requested resource could not be found."
}{
"message": "This webhook is already listening for this event.",
"errors": {
"event": [
"This webhook is already listening for this event."
]
}
}Create webhook event
Subscribes a webhook to an event. event must be one of the names returned by List subscribable events, and a webhook can only subscribe to the same event once.
curl --request POST \
--url https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "projects.created"
}
'import requests
url = "https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events"
payload = { "event": "projects.created" }
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({event: 'projects.created'})
};
fetch('https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events', 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.contractorscloud.com/api/v1/webhooks/{webhookId}/events",
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([
'event' => 'projects.created'
]),
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.contractorscloud.com/api/v1/webhooks/{webhookId}/events"
payload := strings.NewReader("{\n \"event\": \"projects.created\"\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.contractorscloud.com/api/v1/webhooks/{webhookId}/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"projects.created\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.contractorscloud.com/api/v1/webhooks/{webhookId}/events")
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 \"event\": \"projects.created\"\n}"
response = http.request(request)
puts response.read_body{
"id": "b7e4a1c9-3d6f-4b2a-9c8e-5f1d3a7b9c40",
"webhook_id": "a3d8f2e6-1c4b-4a9d-8e3f-2b5a7c9d4f60",
"event": "projects.created",
"created_at": "2025-02-11 09:05:00",
"updated_at": "2025-02-11 09:05:00"
}{
"message": "Unauthenticated."
}{
"message": "The requested resource could not be found."
}{
"message": "This webhook is already listening for this event.",
"errors": {
"event": [
"This webhook is already listening for this event."
]
}
}Authorizations
Authenticate with an API access token in the Authorization header: Authorization: Bearer <token>. Create a token from the API Access Tokens page in Contractors Cloud, under Integrations.
Path Parameters
The id of the webhook.
Body
The event name to subscribe to. Must be one of the names returned by List subscribable events.
"projects.created"
Response
The created webhook event.
The webhook event's unique identifier.
"b7e4a1c9-3d6f-4b2a-9c8e-5f1d3a7b9c40"
The id of the webhook this subscription belongs to.
"a3d8f2e6-1c4b-4a9d-8e3f-2b5a7c9d4f60"
The subscribed event name. See List subscribable events for the current catalog.
"projects.created"
Timestamp when the subscription was created, formatted as YYYY-MM-DD HH:MM:SS. Null if not recorded.
"2025-02-11 09:05:00"
Timestamp when the subscription was last updated, formatted as YYYY-MM-DD HH:MM:SS. Null if not recorded.
"2025-02-11 09:05:00"