Webhooks
Mit Webhooks kann man über bestimmte Ereignisse in Propstack benachrichtigt werden, wie z.B. wenn ein Objekt aktualisiert wird.
Wenn ein Event ausgelöst wird, wird die URL unter target_url
mit einem POST
aufgerufen und die Daten des Kontaktes bzw. des Objektes mit übergeben.
Bei client_updated
und property_updated
wird zusätzlich der Parameter changed_attributes
übergeben, damit man auf Aktualisierungen von bestimmten Feldern reagieren kann. Beispielsweise will man in seiner eigenen App eine Aktion ausführen, sobald sich der Preis eines Objektes ändert, und nicht bei jedem Update eines Objektes.
Mögliche Events:
client_created
client_updated
(wird auch beim Löschen gefeuert)property_created
property_updated
(wird auch beim Löschen gefeuert)task_created
task_updated
task_deleted
client_property_created
client_property_updated
client_property_deleted
project_created
project_updated
document_created
document_updated
document_deleted
saved_query_created
saved_query_updated
saved_query_deleted
Hook erstellen
POST
https://api.propstack.de/v1/hooks
Query Parameters
target_url
string
Die URL, die aufgerufen soll, wenn der Hook ausgelöst wird
event
string
Das Ereignis, worauf man hören möchte. Siehe oben für mögliche Werte
Hooks aufrufen
GET
https://api.propstack.de/v1/hooks
Hook löschen
DELETE
https://api.propstack.de/v1/hooks/:id
Verifying Webhooks
Verifying webhooks is crucial to ensure the authenticity of the incoming requests and confirm that the data originates from Propstack. To enhance security, we have implemented HMAC (Hash-based Message Authentication Code) verification. This allows developers to confirm that requests come from a genuine source.
When creating a new webhook in the Web UI, there is a field called "Secret Key". Adding a secret key is optional. If it's not set, then no signature will be sent with the webhook. If you do add a secret key, we use this to generate a signature and pass it as a header called X-Propstack-Signature
.
Here's a simple JavaScript example showcasing how to verify the HMAC signature from your end:
This function generates a hash using the request body and a shared secret, then compares it to the signature provided to validate the request.
Verifying HMAC Signature in PHP (WordPress)
For WordPress developers, verifying the HMAC signature can also be done using PHP as shown below:
This PHP function computes an HMAC hash of the request body using the shared secret and compares it to the incoming signature to ensure authenticity.
Last updated