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

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

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": "demouser@marsview.ai",
            "endpointUrl": "https://ee24-111-111-111-193.ngrok.io/webhook",
            "subscriptionId": "webhook-1c6q67jckywkiwtu-1643263273650",
        },
        {
            "_id": "6123cvew23402628e0d6bd",
            "event": "process.completion",
            "userId": "demouser@marsview.ai",
            "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": "demouser@marsview.ai",
            "endpointUrl": "<ENDPOINT URL>",
            "subscriptionId": "webhook-1c6q67jckywkiwtu-1643263273650",
        }
}

Response Object

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

Last updated