Webhooks

Overview

A custom integration in Centelar can notify your system about changes by calling a webhook URL. Each call carries one or more events with the ids of what changed; use the API to fetch the current data.

Webhooks are configured in the custom integration setup in Centelar:

Setting Description
Events Webhook Url The URL Centelar calls
Api Key Sent in the X-CENTELAR-API-Key header of every call, so you can verify it comes from Centelar
Sinc. Pedidos Publish order_changed events
Sinc. Stock Publish product_changed_stock and product_changed events
Sinc. Precios Publish product_changed_price and product_changed events
Sinc. Entregas Publish delivery_changed events

Requests

Centelar calls the webhook URL with a POST request and a JSON array of events in the body:

POST <events webhook url>?connection_id=<connection_id>

connection_id is the id of the integration setup in Centelar, the same one used by the API.

Respond with HTTP status 200 once you have received the events. If the response has a different status, Centelar retries the call up to 3 times, one second apart. A 400 response is not retried. Centelar waits up to 10 seconds for each response, so process the events after responding.

Changes are collected periodically, so several events may arrive in the same call, and the same change may arrive more than once. Use event_id to ignore events you already processed.

<%= json(:webhook_events) %>

Events

Every event has an event_type and an event_id, plus the fields below.

delivery_changed

Sent when a delivery of an order, or any of its items, changes. Only deliveries of orders in the management unit of the integration are included. Requires Sinc. Entregas.

Name Type Description
delivery_id integer Id of the delivery. Fetch it with Get Delivery
order_id integer Id of the order
order_ext_id string Id of the order in the source system, if any

order_changed

Sent when an order in the management unit of the integration changes. Requires Sinc. Pedidos.

Name Type Description
order_id integer Id of the order. Fetch it with Get Order
order_ext_id string Id of the order in the source system, if it has one

product_changed

Sent when a product linked to this integration changes. Requires Sinc. Stock or Sinc. Precios.

Name Type Description
product_id integer Id of the product. Fetch it with Get Product
product_ext_id string Id of the product in your system (its code in Centelar if no id was linked)
active boolean Whether the product is enabled for this integration

product_changed_stock

Sent when the stock of a product linked to this integration changes. Requires Sinc. Stock.

Name Type Description
product_id integer Id of the product
product_ext_id string Id of the product in your system
stock array Available stock by location and channel. Not included when there is no stock

product_changed_price

Sent when the price of a product linked to this integration changes in the integration’s price lists. Requires Sinc. Precios.

Name Type Description
product_id integer Id of the product
product_ext_id string Id of the product in your system
price object active, list_id, amount and currency of the new price