Update webhook

PUT Request

curl -X PUT "https://onfleet.com/api/v2/webhooks/TKAfF~o5LH5Rrkqni64vhUOo" \
       -u "<your_api_key>:" -d '{"url": "https://yourwebhook-free.app/webhooks","trigger": 0,"canReceiveConnectionEvents": false,"scopedApiKeyId": null}'
const apiKey = '<your_api_key>';
const webhookId = 'TKAfF~o5LH5Rrkqni64vhUOo';

const response = await fetch(`https://onfleet.com/api/v2/webhooks/${webhookId}`, {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic ' + btoa(apiKey + ':'),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://yourwebhook-free.app/webhooks',
    trigger: 0,
    canReceiveConnectionEvents: false,
    scopedApiKeyId: null,
  }),
});

const data = await response.json();
console.log(data);
import requests

api_key    = '<your_api_key>'
webhook_id = 'TKAfF~o5LH5Rrkqni64vhUOo'

payload = {
    'url': 'https://yourwebhook-free.app/webhooks',
    'trigger': 0,
    'canReceiveConnectionEvents': False,
    'scopedApiKeyId': None,
}

response = requests.put(
    f'https://onfleet.com/api/v2/webhooks/{webhook_id}',
    auth=(api_key, ''),       # Basic auth: key as user, empty password
    json=payload,
)

print(response.json())
<?php

$apiKey    = '<your_api_key>';
$webhookId = 'TKAfF~o5LH5Rrkqni64vhUOo';

$payload = json_encode([
    'url'                       => 'https://yourwebhook-free.app/webhooks',
    'trigger'                   => 0,
    'canReceiveConnectionEvents' => false,
    'scopedApiKeyId'            => null,
]);

$ch = curl_init("https://onfleet.com/api/v2/webhooks/{$webhookId}");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_USERPWD        => $apiKey . ':',
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => $payload,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data);
{
    "id": "TKAfF~o5LH5Rrkqni64vhUOo",
    "count": 0,
    "url": "https://yourwebhook-free.app/webhooks",
    "trigger": 0,
    "isEnabled": true,
    "scopeId": null,
    "canReceiveConnectionEvents": false
}
📘

Scoped API Key ID

This field only matters if the you have an API key that has limited scope. You should always use null when submitting the request payload. Notice scopedApiKeyId in the request, and scopeId in the response, but only scopedApiKeyId is accepted as a request field