How to create webhooks
Fine grained control for the information you want to receive from the blockchain.
You can create rules or trigger conditions for every webhook. You can create rules through the Tangocrypto Dashboard or the API. Every rule is composed of a
field
, a value
and an operator
. All the conditions have to be met for the webhook to be triggered. Rules are optional; depending on the number of rules and their parameters, the webhook will be triggered or not.POST https://cardano-testnet.tangocrypto.com
/{app_id}/v1/nft/collections/{collection_id}/tokens
Body parameters:
Type
: Webhook type, it can bepayment
|block
|transaction
|epoch
|delegation
|asset
|nft_api
name
: Webhook namenetwork
:mainnet
|testnet
description
: Webhook descriptioncallback_url
: The URL where your server is listening. We send a POST to this URL with the webhook event.address
: Destination address. This field is used only in the payment webhook and it's mandatory in payment webhooks.rules
: Every rule is composed of a field, a value and an operator. All the conditions have to be met for the webhook to be triggered. Rules are optional; depending on the number of rules and their parameters, the webhook will be triggered or not.rules
: Every rule is composed of a field, a value and an operator. All the conditions have to be met for the webhook to be triggered. Rules are optional; depending on the number of rules and their parameters, the webhook will be triggered or not.- field: Depends on the type of webhook it can be
policy_id
,asset_name
,fingerprint
,ammount
, etc. operator
: A comparison operator is used to compare thevalue
against thefield
.- value: The
value
value depends on the type of webhook.
Allowed values for
field
, value
and operator
:field | value | operators |
---|---|---|
policy_id | The policy id identifies Cardano assets. This id is unique and attached permanently to the asset, and several assets can have the same policy id. | = |
asset_name | Asset name in UTF-8. | = |
fingerprint | = | |
value | Amount of Ada in the payment. | =, >,<, >=, <= |
quantity | Quantity of certain native asset. | =, >,<, >=, <= |
Rules examples
[
{field: "policy_id", value: "a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235", operator: "="},
{field: "asset_name", value: "Husky", operator: "="}
{field: "fingerprint", value: "asset123213123123xxxxx", operator: "="}
{field: "value", value: "1", operator: "="}
{field: "amount", value: "1", operator: "="}
]
Request examples
With ADA
With native asset
By policy ID
No rules
Trigger the webhook when the address receives more than 5 Ada:
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "payment",
"name": "Payment webhook",
"network": "testnet",
"description": "Notify on payment with more than 5 Ada",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"address": "addr_test1qqqv50804vhe30n25awp6f8mhy9z3rrysva2mj4c9geaqyjr5gtdwq4yajng57kje93tt3fkc5k8cvvem7vl8yql2mcsxcstnx",
"rules": [
{
"field": "amount",
"operator": ">",
"value": "5"
}
]
}'
Trigger the webhook when the address receives more than 5 RBERRY tokens:
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "payment",
"name": "Payment webhook",
"network": "testnet",
"description": "Notify on payment with more than 5 RBERRY",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"address": "addr_test1qqqv50804vhe30n25awp6f8mhy9z3rrysva2mj4c9geaqyjr5gtdwq4yajng57kje93tt3fkc5k8cvvem7vl8yql2mcsxcstnx",
"rules": [
{
"field": "asset_name",
"operator": "=",
"value": "RBERRY"
},
{
"field": "quantity",
"operator": ">",
"value": "5"
}
]
}'
Trigger the webhook when the address receives more than 5 tokens with the specified
policy_id
:curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "payment",
"name": "Payment webhook",
"network": "testnet",
"description": "Notify on payment with more than 5 CHOCK, MINT, RBERRY, SBERRY and VANIL",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"address": "addr_test1qqqv50804vhe30n25awp6f8mhy9z3rrysva2mj4c9geaqyjr5gtdwq4yajng57kje93tt3fkc5k8cvvem7vl8yql2mcsxcstnx",
"rules": [
{
"field": "policy_id",
"operator": "=",
"value": "57fca08abbaddee36da742a839f7d83a7e1d2419f1507fcbf3916522"
},
{
"field": "quantity",
"operator": ">",
"value": "5"
}
]
}'
Trigger the webhook when the address receives a payment (any amount of Ada):
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "payment",
"name": "Payment webhook",
"network": "testnet",
"description": "Notify payments on the specified address",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"address": "addr_test1qqqv50804vhe30n25awp6f8mhy9z3rrysva2mj4c9geaqyjr5gtdwq4yajng57kje93tt3fkc5k8cvvem7vl8yql2mcsxcstnx"
}'
The payment webhooks requires the
address
field with the output address. Allowed values for
field
and value
:field | value | operators |
---|---|---|
tx_count | Amount of transactions in a block. | =, >,<, >=, <= |
out_sum | Block total output sum in Lovelace. | =, >,<, >=, <= |
fees | Block total fees in Lovelace. | =, >,<, >=, <= |
block_no | Block number. | =, >,<, >=, <= |
pool.ticker | Pool ticker. | = |
pool.pool_id | Pool ID. | = |
size | Transaction size. | =, >,<, >=, <= |
Rules examples
[
{field: "tx_count", value: 10, operator: ">"},
{field: "out_sum", value: 100000, operator: ">"},
{field: "pool.ticker", value: "TANGO", operator: "="},
{field: "pool.pool_id", value: "pool1weu4vlg9t8knma7t2j5y3w2k3vzdr9mtnynd2jhfalwn76nwh48", operator: "="},
{field: "fees", value: 5000000, operator: "<"},
{field: "block_no", value: 24345, operator: ">"},
{field: "size", value: 36864, operator: ">"}, // block max size = 73728
]
We recommend using the
pool.pool_id
to get notified when a pool produces a block because the ticker symbol comes from off-chain data, and it might be the case that is not properly configured.Transactions
Total Output
Pool Ticker
Blocks with 3 or more transactions
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "block",
"name": "Block webhook",
"network": "testnet",
"description": "Notify on blocks with 3 or more transactions",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "tx_count",
"operator": ">=",
"value": "3"
}
]
}'
Blocks with more than 10 Million Ada:
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "block",
"name": "Block webhook",
"network": "testnet",
"description": "Notify on blocks with more than 10M Ada ",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "out_sum",
"operator": ">=",
"value": "5000000"
}
]
}'
Pool ticker
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "block",
"name": "Block webhook",
"network": "testnet",
"description": "Notify when the pool TANGO creates a block",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "pool.ticker",
"operator": "=",
"value": "TANGO"
}
]
}'
Allowed values for
field
and value
:field | value | operators |
---|---|---|
out_sum | Transaction total output sum in Lovelace. | =, >,<, >=, <= |
fee | Transaction total fees in Lovelace (1 Ada is 1000000 Lovelace) | =, >,<, >=, <= |
smart_contract_count | Smart contracts count in the transaction. | =, >,<, >=, <= |
Rules examples
[
{field: "out_sum", value: 100000000, operator: ">"},
{field: "fee", value: 5000000, operator: "<"},
]
Total Output
Fee
Transactions with more than 10 Million Ada (Whale alert):
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "transaction",
"name": "Transaction webhook",
"network": "testnet",
"description": "Transactions with more than 10M Ada ",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "out_sum",
"operator": ">=",
"value": "10000000000000"
}
]
}'
Transactions with more than 1 Ada in total fees:
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "transaction",
"name": "Transaction webhook",
"network": "testnet",
"description": "Blocks with 3 or more transactions",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "fee",
"operator": ">=",
"value": "1000000"
}
]
}'
Allowed values for
field
and value
:field | value | operator |
---|---|---|
no | Epoch number | =, >,<, >=, <= |
Rules examples
[
{field: "epoch_no", value: 380, operator: "="}
]
Every Epoch
Epoch Number
To get notified at the begining of every epoch don't use rules.
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "epoch",
"name": "Epoch webhook",
"network": "testnet",
"description": "Notify on every epoch",
"callback_url": "https://webhook.site/2bb93279-a979-4233-9a08-3b330c417f1e",
}'
Get notified on certain epoch.
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "epoch",
"name": "Epoch webhook",
"network": "testnet",
"description": "Notify on a given epoch",
"callback_url": "https://webhook.site/2bb93279-a979-4233-9a08-3b330c417f1e",
"rules": [
{
"field": "epoch_no",
"operator": "=",
"value": "182"
}
]
}'
Allowed values for
field
and value
:field | value | operator |
---|---|---|
pool.pool_id | Pool ID | = |
pool.ticker | Pool ticker | = |
Rules examples
[
{field: "pool.pool_id", value: "pool133h6zcgqalxr6f0lvz6h2lajsyhmzjw4eae62n098tx6g47ypgk", operator: "="}
]
Or
[
{field: "pool.ticker": value: "TANGO", operator: "="}
]
In this case, you can set either
pool_id
or ticker
but not both at the same time. Examples
With Pool ID
With Ticker
Trigger the webhook when the address receives more than 5 RBERRY tokens:
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "delegation",
"name": "Delegation webhook",
"network": "testnet",
"description": "Notify when TANGO pool receives a new delegation",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "pool.pool_id",
"operator": "=",
"value": "pool133h6zcgqalxr6f0lvz6h2lajsyhizjw4eae62n098tx6g47ypgk"
}
]
}'
Trigger the webhook when the address receives more than 5 Ada:
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "delegation",
"name": "Delegation webhook",
"network": "testnet",
"description": "Notify when TANGO pool receives a new delegation",
"callback_url": "https://webhook.site/74e4201b-d651-4971-8b74-ebd6b10fd967",
"rules": [
{
"field": "pool.ticker",
"operator": "=",
"value": "TANGO"
}
]
}'
The Asset Activity webhook allows you to track all the tokens with the labels 721 (NFT) and 20 (FT). This provides your app with real-time state changes when an asset is minted/burned on the blockchain or is transferred between addresses.
Allowed values for
field
and value
:field | value | operators |
---|---|---|
nft_minted | boolean | =, != |
ft_minted | boolean | =, != |
policy_id | The policy id identifies Cardano assets. This id is unique and attached permanently to the asset, and several assets can have the same policy id. | = |
asset_name | Asset name in UTF-8. | = |
fingerprint | = | |
quantity | Quantity of certain native asset. | =, >,<, >=, <= |
Examples
[
{field: "nft_minted", value: true, operator: "="},
{field: "ft_minted", value: true, operator: "="},
{field: "policy_id", value: "23b38042ebbe12754d51b29216474a159fe045183e6a31763fd2014b", operator: "="}, // to hex
{field: "asset_name", value: "Husky", operator: "="}
{field: "fingerprint", value: "asset1ysac0ajdvfaldejkw5nt77yj0uwtq8aman3l2n", operator: "="},
{field: "quantity", value: 1, operator: "="}
]
By Policy ID
All NFTs
All
Receive notifications when an asset with certain policy id is minted:
curl --location --request POST 'https://cardano-testnet/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "asset",
"name": "webhook nft",
"network": "testnet",
"description": "testing nft webhooks",
"callback_url": "https://webhook.site/0ee2d926-6e76-4658-8f3b-e2a427ef3d1d",
"rules": [
{
"field": "nft_minted",
"operator": "=",
"value": true
},
{
"field": "policy_id",
"operator": "=",
"value": "23b38042ebbe12754d51b29216474a159fe045183e6a31763fd2014b"
}
]
}'
Receive notifications when any NFT is minted:
curl --location --request POST 'https://cardano-testnet/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "asset",
"name": "webhook nft",
"network": "testnet",
"description": "testing nft webhooks",
"callback_url": "https://webhook.site/0ee2d926-6e76-4658-8f3b-e2a427ef3d1d",
"rules": [
{
"field": "nft_minted",
"operator": "=",
"value": true
}
]
}'
All the transactions with assets
curl --location --request POST 'https://cardano-testnet/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "asset",
"name": "webhook nft",
"network": "testnet",
"description": "testing nft webhooks",
"callback_url": "https://webhook.site/0ee2d926-6e76-4658-8f3b-e2a427ef3d1d"
}'
This webhook is part of the NFT API, once it's enabled you'll receive an event when the NFT sale is completed and the NFT is on the buyer's wallet.
Request example
Sale completed
Trigger the webhook when the sale is completed
curl --location --request POST 'https://cardano-testnet.tangocrypto.com/<app-id>/v1/webhooks' \
--header 'content-type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data-raw '{
"type": "nft_api",
"name": "Sale completed",
"network": "testnet",
"description": "Triggers when a sale is competed and the NFT is in the buyer's wallet",
"callback_url": "https://webhook.site/90edfa13-4d03-4252-8d51-176cdd259554"
}'
Last modified 9mo ago