unicodeC / Bond APIs / create webhook
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "events": [
// "account.history.ready",
// "card.created",
// "card.status.active",
// "card.status.closed",
// "card.status.fraud",
// "card.status.inactive",
// "card.status.lost",
// "card.status.reissue",
// "card.status.stolen",
// "card.wallet.add",
// "card.wallet.add_failure",
// "kyb.verification.approved",
// "kyb.verification.error",
// "kyb.verification.initiated",
// "kyb.verification.rejected",
// "kyb.verification.warning",
// "kyc.verification.document_required",
// "kyc.verification.error",
// "kyc.verification.failure",
// "kyc.verification.kba",
// "kyc.verification.success",
// "kyc.verification.timeout",
// "kyc.verification.under_review",
// "transactions"
// ],
// "callback_url": "",
// "description": ""
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"events[0]",L"account.history.ready");
CkJsonObjectW_UpdateString(json,L"events[1]",L"card.created");
CkJsonObjectW_UpdateString(json,L"events[2]",L"card.status.active");
CkJsonObjectW_UpdateString(json,L"events[3]",L"card.status.closed");
CkJsonObjectW_UpdateString(json,L"events[4]",L"card.status.fraud");
CkJsonObjectW_UpdateString(json,L"events[5]",L"card.status.inactive");
CkJsonObjectW_UpdateString(json,L"events[6]",L"card.status.lost");
CkJsonObjectW_UpdateString(json,L"events[7]",L"card.status.reissue");
CkJsonObjectW_UpdateString(json,L"events[8]",L"card.status.stolen");
CkJsonObjectW_UpdateString(json,L"events[9]",L"card.wallet.add");
CkJsonObjectW_UpdateString(json,L"events[10]",L"card.wallet.add_failure");
CkJsonObjectW_UpdateString(json,L"events[11]",L"kyb.verification.approved");
CkJsonObjectW_UpdateString(json,L"events[12]",L"kyb.verification.error");
CkJsonObjectW_UpdateString(json,L"events[13]",L"kyb.verification.initiated");
CkJsonObjectW_UpdateString(json,L"events[14]",L"kyb.verification.rejected");
CkJsonObjectW_UpdateString(json,L"events[15]",L"kyb.verification.warning");
CkJsonObjectW_UpdateString(json,L"events[16]",L"kyc.verification.document_required");
CkJsonObjectW_UpdateString(json,L"events[17]",L"kyc.verification.error");
CkJsonObjectW_UpdateString(json,L"events[18]",L"kyc.verification.failure");
CkJsonObjectW_UpdateString(json,L"events[19]",L"kyc.verification.kba");
CkJsonObjectW_UpdateString(json,L"events[20]",L"kyc.verification.success");
CkJsonObjectW_UpdateString(json,L"events[21]",L"kyc.verification.timeout");
CkJsonObjectW_UpdateString(json,L"events[22]",L"kyc.verification.under_review");
CkJsonObjectW_UpdateString(json,L"events[23]",L"transactions");
CkJsonObjectW_UpdateString(json,L"callback_url",L"");
CkJsonObjectW_UpdateString(json,L"description",L"");
CkHttpW_SetRequestHeader(http,L"Identity",L"{{identity}}");
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization}}");
resp = CkHttpW_PostJson3(http,L"https://{{environment}}.bond.tech/api/v0/webhooks",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Identity: {{identity}}"
-H "Authorization: {{authorization}}"
-d '{
"events": [
"account.history.ready",
"card.created",
"card.status.active",
"card.status.closed",
"card.status.fraud",
"card.status.inactive",
"card.status.lost",
"card.status.reissue",
"card.status.stolen",
"card.wallet.add",
"card.wallet.add_failure",
"kyb.verification.approved",
"kyb.verification.error",
"kyb.verification.initiated",
"kyb.verification.rejected",
"kyb.verification.warning",
"kyc.verification.document_required",
"kyc.verification.error",
"kyc.verification.failure",
"kyc.verification.kba",
"kyc.verification.success",
"kyc.verification.timeout",
"kyc.verification.under_review",
"transactions"
],
"callback_url": "",
"description": ""
}'
https://{{environment}}.bond.tech/api/v0/webhooks
Postman Collection Item JSON
{
"name": "create webhook",
"request": {
"method": "POST",
"header": [
{
"key": "Identity",
"value": "{{identity}}",
"type": "text"
},
{
"key": "Authorization",
"value": "{{authorization}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"events\": [\n \"account.history.ready\",\n \"card.created\",\n \"card.status.active\",\n \"card.status.closed\",\n \"card.status.fraud\",\n \"card.status.inactive\",\n \"card.status.lost\",\n \"card.status.reissue\",\n \"card.status.stolen\",\n \"card.wallet.add\",\n \"card.wallet.add_failure\",\n \"kyb.verification.approved\",\n \"kyb.verification.error\",\n \"kyb.verification.initiated\",\n \"kyb.verification.rejected\",\n \"kyb.verification.warning\",\n \"kyc.verification.document_required\",\n \"kyc.verification.error\",\n \"kyc.verification.failure\",\n \"kyc.verification.kba\",\n \"kyc.verification.success\",\n \"kyc.verification.timeout\",\n \"kyc.verification.under_review\",\n \"transactions\"\n\n ],\n \"callback_url\": \"\",\n \"description\": \"\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/webhooks",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"webhooks"
]
}
},
"response": [
{
"name": "create webhook example",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Identity",
"value": "{{identity}}",
"type": "text"
},
{
"key": "Authorization",
"value": "{{authorization}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"events\": [\n \"kyc.verification.success\",\n \"kyc.verification.failure\",\n \"kyc.verification.error\",\n \"kyc.verification.timeout\",\n \"kyc.verification.kba\"\n ],\n \"callback_url\": \"http://bond.tech\",\n \"description\": \"Event listener NA\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/webhooks",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"webhooks"
]
}
},
"_postman_previewlanguage": "json",
"header": null,
"cookie": [
],
"body": "{\n \"date_created\": \"2020-11-17T11:13:06.568119\",\n \"webhook_id\": \"522e9ec7-b17d-4d92-8270-c2e1741dd6e0\",\n \"callback_url\": \"https://hostname.com/webhook/route\",\n \"description\": \"KYC state changes.\",\n \"events\": [\n \"kyc.verification.success\",\n \"kyc.verification.failure\",\n \"kyc.verification.kba\",\n \"kyc.verification.error\",\n \"kyc.verification.timeout\"\n ],\n \"status\": \"enabled\",\n \"secret\": \"whsec_XqTEJtniwuEhp0A1c1cTJNsmpR/qgOfB\"\n}"
}
]
}