Skip to content

Webhooks y eventos en tiempo real

Busqueda objetivo: "webhooks api transporte", "eventos tiempo real carga mercancias"

Registrar webhook

bash
curl -X POST "https://api.pro.cargoffer.com/api/webhook" \
  -H "Authorization: Bearer *** \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://tu-sistema.com/webhook",
    "events": [
      "contract.signed",
      "payment.received",
      "delivery.completed",
      "document.signed"
    ]
  }'

Eventos disponibles

EventoDescripcionPayload incluye
auction.createdNueva subastaserviceCode, origen, destino, peso
auction.bidOferta recibidaserviceCode, transportista, importe
auction.acceptedOferta aceptadaserviceCode, contrato
contract.signedContrato firmadoserviceCode, importe, cliente
payment.receivedPago confirmadoinvoiceId, importe, metodo
delivery.completedEntrega realizadadeliveryId, firma, fecha
document.signedeCMR firmadodocumentId, firmante

Verificar payload

Siempre verifica la firma del webhook:

python
import hashlib, hmac

def verify_webhook(payload, signature, secret):
    expected = hmac.new(
        secret.encode(), payload, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature)

Documentación de Cargoffer