Cloud › Webhooks
Create or update a webhook
PUT https://devapi.dispralabs.com/v1/cloud/projects/:prj/webhooks/:whk
Creates the webhook with the id you choose, or updates it. An empty events list receives every event. Deliveries are signed with the project's webhook secret.
Needs a key with full access.
- Authentication: Secret key (send it as
Authorization: Bearer <key>) - Idempotency: Safe to retry. Send an
Idempotency-Keyheader and repeated calls within 24 hours return the first result.
Parameters
prjstring, required: The project's id. Example:prj_01jdk3m9x2v7c4q8w5n6b1t0rawhkstring, required: The webhook's id. Example:whk_01jdk5j2k4l6z8x0c2v4b6n8mqurlstring, required: Where deliveries go. https only. Example:https://hooks.acme.com/dispraeventsarray, optional: The events to receive (default every event). Example:["deploy.succeeded","deploy.failed"]enabledboolean, optional: False pauses it. Example:true
Returns
- 201: whk and status (created).
- 200: whk and status (updated).
Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | No such object in the key's project (or environment). |
| 400 | invalid_url | The URL is not https, or resolves to a private address. |
Request samples
Dispra Cloud CLI
dcloud api PUT /v1/cloud/projects/prj_01jdk3m9x2v7c4q8w5n6b1t0ra/webhooks/whk_01jdk5j2k4l6z8x0c2v4b6n8mq --data '{"url":"https://hooks.acme.com/dispra","events":["deploy.succeeded","deploy.failed"],"enabled":true}'
cURL
curl -X PUT "https://devapi.dispralabs.com/v1/cloud/projects/prj_01jdk3m9x2v7c4q8w5n6b1t0ra/webhooks/whk_01jdk5j2k4l6z8x0c2v4b6n8mq" \
-H "Authorization: Bearer dsp_live_YOUR_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"url":"https://hooks.acme.com/dispra","events":["deploy.succeeded","deploy.failed"],"enabled":true}'
Node
const res = await fetch("https://devapi.dispralabs.com/v1/cloud/projects/prj_01jdk3m9x2v7c4q8w5n6b1t0ra/webhooks/whk_01jdk5j2k4l6z8x0c2v4b6n8mq", {
method: "PUT",
headers: { Authorization: "Bearer dsp_live_YOUR_KEY", "Idempotency-Key": crypto.randomUUID(), "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://hooks.acme.com/dispra",
"events": ["deploy.succeeded","deploy.failed"],
"enabled": true
}),
});
console.log(await res.json());
Python
import uuid, requests
res = requests.request("PUT", "https://devapi.dispralabs.com/v1/cloud/projects/prj_01jdk3m9x2v7c4q8w5n6b1t0ra/webhooks/whk_01jdk5j2k4l6z8x0c2v4b6n8mq", headers={"Authorization": "Bearer dsp_live_YOUR_KEY", "Idempotency-Key": str(uuid.uuid4())}, json={
"url": "https://hooks.acme.com/dispra",
"events": ["deploy.succeeded","deploy.failed"],
"enabled": True
})
print(res.json())
Go
body := strings.NewReader(`{"url":"https://hooks.acme.com/dispra","events":["deploy.succeeded","deploy.failed"],"enabled":true}`)
req, _ := http.NewRequest("PUT", "https://devapi.dispralabs.com/v1/cloud/projects/prj_01jdk3m9x2v7c4q8w5n6b1t0ra/webhooks/whk_01jdk5j2k4l6z8x0c2v4b6n8mq", body)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
req.Header.Set("Idempotency-Key", uuid.NewString())
res, _ := http.DefaultClient.Do(req)
Responses
201
{}
200
{}
404 not_found
{
"error": {
"code": "not_found",
"message": "No such object in the key's project (or environment).",
"request_id": "req_7f3a9c21d84be056"
}
}
400 invalid_url
{
"error": {
"code": "invalid_url",
"message": "The URL is not https, or resolves to a private address.",
"request_id": "req_7f3a9c21d84be056"
}
}