How to use Chative.IO webhooks get automatical real-time updates?
What is webhooks?
Chative.IO Webhooks keeps you informed with real-time notifications for changes in Chative.IO. Whether it's a new contact or an updated field, you'll receive instant updates, ensuring you never miss important events. Simplify your contact management with Chative.IO Webhook.
Getting started with webhooks
Create a webhook
Use the following steps to create a webhook:
Step 1: Go to Chative.IO app
Step 2: On the sidebar, click to icon Settings
.
Step 3: On the dropdown menu, click to Developer
> Webhooks
.
Step 4: Click on Create Webhook
.
Step 5: Add your webhook endpoint's HTTPS URL in Payload URL.
Step 6: Click Create
.
Webhooks requirements
To ensure your webhook functions properly, it must meet the following requirements:
- The webhook must be configured with HTTPS (TLS).
- Your server should respond with an HTTP 200 status code.
- The server should handle unexpected event types without returning an error.
How do webhooks work?
Chative.IO's webhooks functionality ensures that you receive timely notifications when events occur in your app:
- The server sends a data to each active webhook through an HTTP POST request.
- The request sent by Chative.IO will be encoded as UTF-8.
- The content type of the request will be specified as application/json.
Securing webhooks
Chative provide method for confirming the security of your webhook server.
The verify token of each POST request should be included in the request body. This ensures that Chative.IO is the source of the incoming webhooks.
Verify token
- The verify token, which is an optional secret key, can be specified when creating your webhook.
- It is recommended to use a verify token to secure your webhook endpoints, preventing unauthorized actions and protecting your server from potential risks.
The Structure of Webhook Data Object
The data from a webhook request typically follows the structure of the object below:
- _id: The unique identifier of the webhook payload.
- event: The event for which the webhook is sent.
- createdAt: The UNIX Timestamp indicating the date and time the payload was created.
- deliveryAttempts: The number of times the payload has been sent.
- firstSentAt: The UNIX Timestamp indicating the date and time the payload was first sent.
- items: This field contains information about the action associated with the webhook payload. For contact-related webhook, this field will provide the contact object.
Example: When you receive a webhook indicating an update to a contact, the 'items' field in the webhook payload will contain the following information:
- _id: The unique identifier of the contact.
- object: The type of object, which in this case is a contact.
- createdAt: The UNIX Timestamp when the webhook payload was created.
- data: Provides information about the specific field of the contact that has been updated.
- infoWebhook: Includes an object containing the 'verifyToken' property. Refer to Securing webhooks to learn more.
Retries
If Chative.IO does not receive a 200 status code as a response from your webhook, it will automatically attempt to resend the request. Chative.IO will retry the request up to five times, with a pause of 5 seconds between each retry.
The webhook will continue to be retried until one of the following conditions is met:
- The webhook responds with a 200 status code, indicating a successful response.
- The maximum number of retry attempts (5) is reached.
Deactivation
If the webhook fails to succeed after five attempts, it will be considered a failure and will no longer be retried. As a result, the webhook will be deactivated.
Here are the reasons for webhook deactivation:
- The webhook was deactivated because Chative.IO couldn't reach the specified webhook endpoint.
- The webhook was deactivated because the organization's plan was downgraded from a business plan.
Reactivation
To reactivate a webhook, you can manually perform the following steps within the Chative app:
Step 1: Access the Chative.IO app.
Step 2: On the sidebar, click on the Settings
.
Step 3: From the dropdown menu, navigate to Developer
and select Webhooks
.
Step 4: Choose the deactivated webhook you want to reactivate.
Step 5: Click on the three-dot icon next to the webhook and select the Activate
option.