Создать вебхук
Подписывает адрес на события. Секрет подписи показывается один раз, в ответе на создание.
POST /webhooks
- Permiso de la clave:
webhooks:write - Clave: clave de prueba o activa
- Idempotency-Key: obligatorio. Idempotencia
Parámetros
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
url |
string | sí | Dirección a la que enviar eventos. Solo https, direcciones internas prohibidas, hasta 500 caracteres. |
events |
array | sí | Lista de eventos, por ejemplo shipment.status_changed, shipment.tracking_updated. Lista completa en la sección «Webhooks». |
Lo que es importante saber
- Секрет
secretвиден только в этом ответе. Сохраните его сразу: повтор запроса с тем жеIdempotency-Keyвернёт вебхук уже без секрета, а потерянный секрет заменяется методом ротации. - Адрес только
https, внутренние адреса (localhost, частные сети) запрещены, перенаправления не выполняются. - Доступные события:
shipment.created,shipment.status_changed,shipment.delivered,shipment.cancelled,shipment.tracking_updated,extra_charge.created,balance.topup. - На аккаунт можно создать не больше 10 вебхуков, иначе 409.
Ejemplo de solicitud
curl -X POST https://api.shippickup.com/v1/webhooks \
-H "Authorization: Bearer $SHIPPICKUP_API_KEY" \
-H "Idempotency-Key: order-10452-label-v1" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/shipto/webhook",
"events": [
"shipment.status_changed",
"shipment.tracking_updated"
]
}'<?php
$body = [
'url' => 'https://example.com/shipto/webhook',
'events' => [
'shipment.status_changed',
'shipment.tracking_updated',
],
];
$ch = curl_init('https://api.shippickup.com/v1/webhooks');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SHIPPICKUP_API_KEY'),
'Idempotency-Key: order-10452-label-v1',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$response = json_decode((string) curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
print_r([$status, $response]);
import os
import requests
body = {
"url": "https://example.com/shipto/webhook",
"events": [
"shipment.status_changed",
"shipment.tracking_updated",
],
}
r = requests.post(
"https://api.shippickup.com/v1/webhooks",
headers={
"Authorization": "Bearer " + os.environ["SHIPPICKUP_API_KEY"],
"Idempotency-Key": "order-10452-label-v1",
},
json=body,
timeout=30,
)
print(r.status_code, r.json())
const body = {
"url": "https://example.com/shipto/webhook",
"events": [
"shipment.status_changed",
"shipment.tracking_updated"
]
};
const res = await fetch("https://api.shippickup.com/v1/webhooks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SHIPPICKUP_API_KEY}`,
"Idempotency-Key": "order-10452-label-v1",
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
console.log(res.status, await res.json());
Ejemplo de respuesta 201
JSON
{
"data": {
"id": 12,
"url": "https://example.com/shipto/webhook",
"events": [
"shipment.status_changed",
"shipment.tracking_updated"
],
"active": true,
"created_at": "2026-12-04T10:15:30+00:00",
"secret": "whsec_<shown once>"
}
}Errores posibles
| HTTP | Código | Descripción |
|---|---|---|
| 422 | validation_failed | Error en los campos de la solicitud. En error.details se indica la razón para cada campo. |
| 422 | idempotency_key_required | No hay encabezado Idempotency-Key o no es válido: debe tener entre 16 y 64 caracteres A-Za-z0-9_-. |
| 422 | idempotency_key_reused | Этот Idempotency-Key уже использован для другого запроса: для нового запроса нужен новый ключ. |
| 403 | insufficient_scope | La clave no tiene el permiso necesario, está indicado en error.details.required_scope. |
| 429 | rate_limited | Se ha excedido el límite de solicitudes de la clave. Intente de nuevo después del tiempo indicado en el encabezado Retry-After. |
| 409 | conflict | La acción no es posible ahora para este pedido (por ejemplo, el pedido ya no se puede cancelar o la recogida ya fue solicitada). El texto de la razón está en error.message. |