BrickControl Webhooks

What are webhooks?

Webhooks are notifications sent by BrickControl to other external softwares, to notify them of any events occurring in BrickControl (for example: invoice X has been saved, customer X has been deleted…).

How do webhooks work?

You just need to subscribe to a BrickControl webhook event. To use this functionality you have to subscribe indicating the name of the event you want to subscribe to (for example customer.save) and the url where you want to receive the notification. As soon as the event you subscribed to is executed (for example that a client is saved), BrickControl will send you a JSON to the url you indicated when you subscribed to that event.

In the url you specified, you must have already prepared your REST web service, enabling it to receive a POST and read the JSON object that is sent yo. Once you receive this, using your own development environment you will be able to do any action you require, such as saving that client in other software.

How do I subscribe to an event?

If you haven’t called any of our API methods yet, please read the following information before doing so:

First steps with the BrickControl API

To subscribe to an event you must call the following API method:

Method: POST

URL: https://brickcontrol.com/api/v5/Hooks/subscribe

Payload:

View format of a JSON to subscribe to an event

Example Payload:

View format of a JSON to subscribe to an event

Note: You must replace the TargetUrl with your own URL, which should properly configured in order to receive these notifications.

How do I unsubscribe from an event?

To unsubscribe to an event you must call the following API method:

Method: DELETE

URL: https://brickcontrol.com/api/v5/Hooks/unsubscribe

Payload:

View format of a JSON to unsubscribe to an event

Example Payload:

View format of a JSON to unsubscribe to an event

How do I see all the events to which I am subscribed to?

To see all the events to which you are subscribed to, you have to call the following API method:

Method: GET

URL: https://brickcontrol.com/api/v5/Hooks/getList

How do I see if I am subscribed to an event?

To see if you are subscribed to an event with a specific code you have to call the following API method:

Method: GET

URL: https://brickcontrol.com/api/v5/Hooks/get?id=1

Where “id” is the code of the event you want to obtain

How can I test if the webhook is sending me the notification correctly?

So that you can test if you have subscribed to a BrickControl event, we have created a series of urls that when you subscribe to the event through that URL sends you an email with the JSON every time that event occurs.

Example URL: https://brickcontrol.com/api/v5/Hooks/Test/Customer?email=tuemail@gmail.com

Example Payload:

View an example of a JSON to subscribe to an event with the test URL

If you subscribe to an event with this payload, every time a client is saved in BrickControl, an email will be sent to “tuemail@gmail.com” (modify that email to yours) with the JSON it is sending to the URL.

This is just for you to test the webhook, when you use it you must have a URL that is able to receive that JSON and process it.

Whhich type of events can I subscribe to?

Customer

Event: customer.save

Event: customer.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/Customer?email=tuemail@gmail.com

Supplier

Event: supplier.save

Event: supplier.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/Supplier?email=tuemail@gmail.com

Worker

Event: employee.save

Event: employee.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/Employee?email=tuemail@gmail.com

Project

Event: project.save

Event: project.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/Project?email=tuemail@gmail.com

Invoice of purchase

Event: purchase-invoice.save

Event: purchase-invoice.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/PurchaseInvoice?email=tuemail@gmail.com

Reception of materials

Event: reception-of-materials.save

Event: reception-of-materials.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/ReceptionOfMaterials?email=tuemail@gmail.com

Part of work

Event: timesheet.save

Event: timesheet.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/TimeSheet?email=tuemail@gmail.com

Sales Invoice

Event: sale-invoice.save

Event: sale-invoice.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/SaleInvoice?email=tuemail@gmail.com

Article

Event: item.save

Event: item.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/Item?email=tuemail@gmail.com

Order

Event: purchase-order.save

Event: purchase-order.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/PurchaseOrder?email=tuemail@gmail.com

Transfer of equipment

Event: material-transfer.save

Event: material-transfer.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/MaterialTransfer?email=tuemail@gmail.com

User

Event: user.save

Event: user.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/User?email=tuemail@gmail.com

Form of payment

Event: payment-method.save

Event: payment-method.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/PaymentMethod?email=tuemail@gmail.com

Unit of measure

Event: measurement-unit.save

Event: measurement-unit.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/MeasurementUnit?email=tuemail@gmail.com

VAT

Event: tax.save

Event: tax.delete

URL test: https://brickcontrol.com/api/v5/Hooks/Test/Tax?email=tuemail@gmail.com

Other events

If you need an event that is not in this list, please request it in our support web site.