Create webhook

Create webhook

Body parameters

NameTypeDescription
urlstringThe URL that Onfleet should issue a request against as soon as the trigger condition is met. It must be HTTPS and have a valid certificate.
namestringA name for the webhook for identification.
triggernumberThe number corresponding to the trigger condition on which the webhook should fire.
thresholdnumberOptional. For trigger 1, the time threshold in seconds; for trigger 2, the distance threshold in meters.

To create a new webhook, provide a verifiable url and trigger, see sidebar.

curl -X POST "https://onfleet.com/api/v2/webhooks" \
     -u "cd3b3de84cc1ee040bf06512d233719c:" \
     -d '{"url":"https://11ec4a02.ngrok.com/onfleet/taskStart","trigger":0}'
onfleet.webhooks.create(body={"url":"https://11ec4a02.ngrok.com/onfleet/taskStart","trigger":0})
onfleet.webhooks.create({"url":"https://11ec4a02.ngrok.com/onfleet/taskStart","trigger":0});
$onfleet->webhooks->create(["url"=>"https://11ec4a02.ngrok.com/onfleet/taskStart","trigger"=>0])
{
    "id": "9zqMxI79mRcHpXE111nILiPn",
    "count": 0,
    "url": "https://11ec4a02.ngrok.com/onfleet/taskStart",
    "trigger": 0
}
{
  "code": "InvalidContent",
  "message": {
    "error": 1008,
    "message": "The webhook URL provided did not pass our validation test.",
    "request": "0a15bc44-a39b-4040-8b48-a79295642e12"
  }
}

As previously mentioned, you will need to respond to our validation request with the check query parameter value, as a simple string response in order to avoid validation failures. This applies if you're not using the automatic validation from Zapier.