Step 2. Create a New Target
Learn how to configure targets for event streaming.
Now you need to set up a webhook target to start receiving events. A target will serve as a destination in a rule that provides you with the data you desire. This can be done by using the Target endpoint.
Request Payload
curl --location 'https://svc.blockdaemon.com/streaming/v2/targets' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data ' {
"description": "Documentation webhook target",
"max_buffer_count": 100,
"name": "docs webhook target example",
"settings": {
"destination": "http://example.com/webhook",
"method": "POST",
"secret": "your secret here"
},
"type": "webhook"
}'
The request body includes the following parameters:
Fields | Required/Optional | Details |
---|---|---|
description | Optional | A description of your target. |
max_buffer_count | Optional | Maximum number of items allowed in the webhook target's buffer. |
name | Required | The name of your target. Each resource should have a unique name. |
settings | Required | The configuration of a webhook target. |
destination | Required | The destination URL where we can reach this webhook. |
method | Required | The HTTP method for the webhook (in this case, POST ). |
secret | Required | A private webhook secret with a minimum string length of 10 characters. This is used as the challenge token for webhook verification process. |
type | Required | The type of target which currently limited to webhook. |
Response Payload
Below is the successful response.
{
"created_at": "2024-03-06T09:48:06.673414Z",
"current_buffer_count": 0,
"description": "Documentation webhook target",
"id": "8918a2f1-28d6-4e2f-837b-fb49ec09daaf",
"max_buffer_count": 100,
"name": "docs webhook target example",
"settings": {
"destination": "http://example.com/webhook",
"method": "POST",
"secret": "************here"
},
"status": "active",
"type": "webhook",
"updated_at": "2024-03-06T09:48:06.673414Z"
}
It includes the following details:
Fields | Details |
---|---|
id | Unique identifier for your webhook target, necessary for creating rules. You will need this ID to create a rule. |
created_at & updated_at | A timestamp for when the target was created and last updated. |
max_buffer_count | Maximum number of events that will buffer for your target. If your target is slow or temporarily offline, event streaming will buffer messages up to this limit. |
destination | URL to send webhook payloads for processing or notification. |
status | Status of your webhook. It must be "connected" before receiving events. Refer to the Webhook Target Reference. |
Note:
You can use one webhook target for multiple rules by using its
id
.
👋 Need Help?
Contact us through email or our support page for any issues, bugs, or assistance you may need.
Updated about 1 month ago