Create a Webhook
res = po_client.request("post", "/api/webhooks", **{
"action": {
"action": "request",
"data": {
"custom_field": "product.update"
},
"headers": {
"custom_header": "123"
},
"integration_setting_id": 123124,
"method": "post",
"timeout": 5000,
"url": "http://localhost:6544/events"
},
"app_id": 4,
"event": "product.update"
}, use_json=True)
"app_id": 4, # 4 is fine, this informs the API you’re using the Cash Register app
"event": options are:
product.update
product.create
product.delete
customer.create
customer.delete
customer.update
transaction.closed
"action": { "integration_setting_id": 123124, # use any unique value for now - used to identify which webhook belongs to what addon
"action": { "timeout": 5000,
"action": { "url": "http://localhost:6544/events", # this should be your endpoint
"action": { "data": { # skip it if you don't need to receive anything except product ID # - optional
"custom_field": "product.update"
"action": { "headers": { # skip it if you don't need any special headers in the url
"custom_header": "123"
Response:
{ "action": { "action": "request", "data": { "custom_field": "product.update" }, "headers": { "custom_header": "123" }, "integration_setting_id": 123124, "method": "post", "timeout": 5000, "url": "http://localhost:6544/events" }, "app": { "id": 4, "name": "Cash Register" }, "app_id": 4, "event": "product.update", "id": 158 }