Create Hook
POST
/hooks
Create a new webhook.
Roles
Users with the following roles may access this endoint:
Admin
Dispatcher
Breaking Changes
No breaking changes.
Request
- Sample Request
- Sample Response
POST /hooks/
Authorization: Bearer {your-auth-token}
Content-Type: application/json
x-tenant-id: {your-tenant-id}
{
"events": [
"Customer"
],
"secret": "VGhlIGxhenkgYnJvd24gZG9n",
"url": "https://test.url"
}
Access-Control-Allow-Headers: Authorization, Accept, X-TENANT-ID, Content-Type
Access-Control-Allow-Methods: GET,POST
Access-Control-Allow-Origin: *
Allow: GET,POST
Content-Length: 169
Content-Type: application/json
Date: Sat, 20 Aug 2022 01:45:12 GMT
Server: WSGIServer/0.2 CPython/3.9.5
X-API-VERSION: 2019/02/08
X-REQUEST-ID: 0ebe3eb6-2e6a-4a21-b8a2-4db9bf9a67d4
{
"deleted_at": null,
"events": [
"Customer"
],
"id": 2,
"last_http_fail": null,
"last_http_success": null,
"secret": "VGhlIGxhenkgYnJvd24gZG9n",
"url": "https://test.url"
}
Path Parameters
No path parameters.
Query Parameters
No query parameters.
Request Headers
Refer to StandardRequestHeadersModel for more details.
authorization
String, Required
Authorization header (bearer with access token). See the Authentication Guide to get started.
- Matches ^bearer [a-z0-9-_=]+.[a-z0-9-_=]+.?[a-z0-9-_.+/=]*$
- No longer than 256 characters.
- At least 1 characters long.
Content-Type
String, Optional
Default Value: application/json
One of the following MIME types:
- "application/json" Refer to the JSON Spec.
x-api-version
String, Optional
Request identifier.
- At least 1 and no more than 64 characters.
- Must be a valid API version string (2019/02/08, 2021/04/07, 2021/05/07, 2021/08/02, 2021/11/04, 2023/04/19).
x-tenant-id
Integer, Required
Tenant identifier. Contact CRO Software for more info if you don't already have this id. See list tenant ids for info on listing the tenants you have access to.
Request Body
Refer to CreateWebhookModel for more details.
events
Array[hook_event], Required
hook_event
String
Hook event.
- Must be a valid hook event (one of: Ping, Customer, CustomerLocation, Job, Truck).
secret
String, Optional
Response body HMAC signing key.
- Matches ^\s[a-zA-Z0-9\/+=]{11,270}\s$
- Base64 encoded string.
url
String, Required
Callback URL.
- URL conforming to RFC 1738.
Response
Response Headers
Refer to StandardResponseHeadersModel for more details.
Content-Type
String, Optional
Default Value: application/json
One of the following MIME types:
- "application/json" Refer to the JSON Spec.
x-api-version
String
Request identifier.
- At least 1 and no more than 64 characters.
- Must be a valid API version string (2019/02/08, 2021/04/07, 2021/05/07, 2021/08/02, 2021/11/04, 2023/04/19).
x-request-id
String
Request identifier.
- Valid UUID.
Response Body
Refer to WebhookModel for more details.
deleted_at
String
Denial date.
- Date in an ISO 8601 compatible format.
events
Array[hook_event]
hook_event
String
Hook event.
- Must be a valid hook event (one of: Ping, Customer, CustomerLocation, Job, Truck).
id
Integer
Resource identifier.
last_http_fail
String
Last time of url webhook execution failure.
- Date in an ISO 8601 compatible format.
last_http_success
String
Last time of url webhook execution success.
- Date in an ISO 8601 compatible format.
secret
String, Conditional
Response body HMAC signing key.
- Matches ^\s[a-zA-Z0-9\/+=]{11,270}\s$
- Base64 encoded string.
url
String
Callback URL.
- URL conforming to RFC 1738.
Code Samples
- cURL
- Python
- CSharp 2.0
curl --request POST --include \
--header "Authorization: Bearer {your-auth-token}" \
--header "Content-Type: application/json" \
--header "x-tenant-id: {your-tenant-id}" \
--data '{"events": ["Customer"], "secret": "VGhlIGxhenkgYnJvd24gZG9n", "url": "https://test.url"}' \
127.0.0.1:8003/hooks
import requests, json
body = '''
{
"events": [
"Customer"
],
"secret": "VGhlIGxhenkgYnJvd24gZG9n",
"url": "https://test.url"
}
'''
response = requests.post(
'http://localhost:8003/hooks',
headers={
'Authorization': 'Bearer {your-auth-token}',
'Content-Type': 'application/json',
'x-tenant-id': '{your-tenant-id}'
},
params={
},
data=body
)
results = json.loads(response.text)
print(results)
using System;
using System.Net;
using System.Collections.Specialized;
namespace CROSoftware
{
public class DemoClient
{
static public void Main ()
{
WebClient client = new WebClient();
// URL
String url = "/hooks";
// Headers
client.Headers.Add("Authorization", "Bearer {your-auth-token}");
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("x-tenant-id", "{your-tenant-id}");
// Body
String body = "{\"events\": [\"Customer\"], \"secret\": \"VGhlIGxhenkgYnJvd24gZG9n\", \"url\": \"https://test.url\"}";
String json = client.UploadString(url, "post", body);
Console.WriteLine(json);
}
}
}