Subscribe to Webhook[beta]
This section shows how to subscribe to the webhook that emits the information of the dags that have completed

Create Subscription

This method is used to subscribe to the the async api task status webhook. This subscription enables users to get the status of the DAG run as soon as it completes its execution. This API can be used to attach the endpointUrl to the webhook so that the completion notification gets pushed to this endpointUrl

Request body

Key
Value
userId
Id of the user under which the subscription should be created
event
Type of event the subscription should be made
endpointUrl
Url to which the webhook notification should be pushed to
curl --location --request POST 'https://api.marsview.ai/cb/v1/profile/webhooks/create_webhook_subscription/<USERID>' \
--header 'Content-Type: application/json' \
--header "Authorization:{{Insert Auth Token With Type}}" \
--data-raw '{
"userId":<USERID>,
"event":"process.completion",
"endpointUrl":<ENDPOINT URL>
}'

Response

{
"status": true,
"data": {
"subscriptionId": "webhook-1c6q67jckywkiwtu-1643263273650"
}
}

Response Object

Key
Description
subscriptionId
Subscription ID generated for the consumer subscribing to the webhook

Sample Webhook Notification

{
"txnId":"txn-xxxxxx-xxxxxx-xxxxx",
"status":{id:2, state:'processed'}
}

Get Subscription

This method is used to get either the entire list of subscriptions of a user or the details of a specific subscription. Both of these details can be fetched using the following API's

Request for getting all subscriptions

curl --location --request GET 'https://api.marsview.ai/cb/v1/profile/webhooks/get_user_webhook_subscription/<USERID>' \
--header 'Content-Type: application/json' \
--header "Authorization:{{Insert Auth Token With Type}}"

Sample Response

{
"status": true,
"data": [
{
"_id": "61f235293923b02628e0d6bd",
"event": "process.completion",
"userId": "[email protected]",
"endpointUrl": "https://ee24-111-111-111-193.ngrok.io/webhook",
"subscriptionId": "webhook-1c6q67jckywkiwtu-1643263273650",
},
{
"_id": "6123cvew23402628e0d6bd",
"event": "process.completion",
"userId": "[email protected]",
"endpointUrl": "https://ee24-111-111-98-193.ngrok.io/webhook",
"subscriptionId": "webhook-1c6q67asdqdwrcsa-1643263273650",
}
]
}

Request for getting specific subscription

curl --location --request GET 'https://api.marsview.ai/cb/v1/profile/webhooks/get_webhook_subscription/<USERID>/<SUBSCRIPTION ID>' \
--header 'Content-Type: application/json' \
--header "Authorization:{{Insert Auth Token With Type}}"

Sample Response

{
"status": true,
"data": {
"_id": "61f235293923b02628e0d6bd",
"event": "process.completion",
"userId": "[email protected]",
"endpointUrl": "<ENDPOINT URL>",
"subscriptionId": "webhook-1c6q67jckywkiwtu-1643263273650",
}
}

Response Object

Key
Description
event
Type of process event
userId
Id of the user under which the subscription is created
subscriptionId
Id of the subscription
endpointUrl
Url to which the webhook notification is pushed

Delete Webhook

The Delete Webhook API can be used to terminate existing subscriptions

Sample request

curl --location --request DELETE 'https://api.marsview.ai/cb/v1/profile/webhooks/delete_webhook_subscription/<USERID>/<SUBSCRIPTION ID>' \
--header 'Content-Type: application/json' \
--header "Authorization:{{Insert Auth Token With Type}}"

Sample response

{
"status": true,
"data": {
"msg": "webhook Deleted successfully",
"subscriptionId": "webhook-1c6q67jckywkiwtu-1643263273650"
}
}

Response Object

Key
Value
msg
Message indicating the status of deletion
subscriptionId
Id of the subscription that has been deleted
Copy link
On this page
Create Subscription
Request body
Response
Response Object
Sample Webhook Notification
Get Subscription
Request for getting all subscriptions
Sample Response
Request for getting specific subscription
Sample Response
Response Object
Delete Webhook
Sample request
Sample response
Response Object