Subscriptions

With Krayon Digital API, you can create different subscriptions in your system based on various events, such as transactions, deposits, compliance, and elections.

Krayon offers different channels to notify the client, such as Webhooks, emails, slack channels, and Telegram channels.

Create A Subscription

Request:

import axios from 'axios';

const options = {
  method: 'POST',
  url: 'https:/api.aqua.test.krayondigital.com/main/api/v1/subscriptions',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    'Authorization': "Bearer YOUR-API-TOKEN"
  },
  data: {
  "type": "transactions",
  "notification_channels": [
    {
      "channel_type": "webhook",
      "address": "https://eo3y4clrcxypoxe.m.pipedream.net"
    }
    ]
  }
};

axios
  .request(options)
  .then(function (response) {
    console.log(response.data);
  })
  .catch(function (error) {
    console.error(error);
  });
import requests

url = "https:/api.aqua.test.krayondigital.com/main/api/v1/subscriptions"

payload = {
  "type": "transactions",
  "notification_channels": [
    {
      "channel_type": "webhook",
      "address": "https://eo3y4clrcxypoxe.m.pipedream.net"
    }
  ]
}

headers = {
    "accept": "application/json",
    "content-type": "application/json",
 		"Authorization": "Bearer YOUR-API-TOKEN"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
  • In this request, we are requesting notifications on transactions through a webhook.

Response:

{
    "data": {
        "id": "302beabd51be44d482565b48bd6836e4",
        "organization": "org_aAgoWL5DjwSvQSf0",
        "type": "transactions",
        "notification_channels": [
            {
                "channel_type": "webhook",
                "address": "https://eo3y4clrcxypoxe.m.pipedream.net"
            }
        ]
    }
}

Examples of Webhooks data:

Transfers

{
    "amount": "2.679000000000000000000",
    "block_time_stamp": "2024-03-31T09:36:00Z",
    "blockchain": "tron_shasta",
    "chain_id": 1461562,
    "decimals": 6,
    "from_address": "TBSmvEVv7zZSCthwbhjYQXTgvNVwjxG3mQ",
    "hash": "b65df1a1b7a701a3b1c96f7e9fb2177cfb5d41476683d9cb4debc71b88be1f1f",
    "id": "c5d7ec4be86b416c8241c8afed821493",
    "logo_uri": "https://static.tronscan.org/production/upload/logo/TEkxiTehnzSmSe2XqrBj4w32RUN966rdz81.png",
    "name": "USD Coin",
    "native_amount": "0",
    "native_price": "0.122520964148135790",
    "status": "TRANSACTION_SUCCESS",
    "symbol": "USDC",
    "to_address": "TRzjB6ZsdniBZg4AXdLXTTw43owftL9pX7",
    "token_price": "1.000260862331133800",
    "transaction_fee": "5.823480000000000000",
    "transaction_fee_usd": "0.713498384297385810",
    "transaction_id": "7ccb8ccd3ad14a1a9ee041c822e9d6f9",
    "wallet": "bfcd9d46c271405ea3ec64df2d256e09"
}

Transfer object:

FieldFormatDescription
deposit_idstringID of the deposit.
block_time_stampstringThe Transfer timestamp.
blockchainstringThe blockchain.
chain_idnumberThe blockchain chain id.
decimalsnumberNumber of decimals for the token.
from_addressstringThe transfer sender.
hashstringThe transfer hash.
idstringThe Transfer UUID. See more details here Deposit Object.
logo_uristringThe Token's logo.
namestringThe Token's name.
native_amountstringThe amount in native form with all decimals.
native_pricestringThe native price of the Token used to pay the Transfer.
statusstringThe transfer status. See more details here Transfer Object
symbolstringThe Token's symbol.
to_addressstringThe transfer receiver.
token_pricestringThe Token's price in USD.
transaction_feestringThe fee in native form.
transaction_fee_usdstringThe fee in USD price.
transaction_idstringThe transaction UUID.
walletstringThe wallet UUID. See more details here Wallet Object

Deposits

{
    "id": "08ca7622ebdb4ae68001733a733c4eab",
    "status": "SUCCESS",
    "amount": "700",
    "currency": "INR",
    "payment_method": "UPI",
    "payment_type": "DEPOSIT",
    "description": "This is a deposit description",
    "customer_vpa": "simulator@upi",
    "payment_fee": "42.00",
    "net_amount": "658.00"
}

Notification object:

FieldFormatDescription
idstringID of the deposit.
** This is not the reference ID; this is Krayon's internal deposit object ID.
statusstringStatus of the deposit. See more details hereDeposit Object.
amountstringThe amount that the end user paid.
** This is not the amount that the deposit object has been created with.
currencystringThe currency of the deposit.
payment_methodstringThe payment method of the deposit. e.g UPI, UPI_SAP, PAYTM, CRYPTO
payment_typestringThe payment type, e.g., DEPOSIT, WITHDRAWAL.
descriptionstringThe description of the deposit.
customer_vpastringThe customer VPA of the deposit. Only in PAYTM. See more details here India.
payment_feestringThe deposit fee. e.g., amount * fee%
net_amountstringThe net amount of the deposit. e.g., amount * (1-fee%)

What’s Next

Learn how to validate the integrity of the payload sent with the webhooks