Hooks

Register new hooks

Register a new hook with the Java SDK.

POST/hooks

Use blnk.hooks().create for this operation.

Call the method

ApiResponse<JsonNode> response = blnk.hooks().create(
    CreateHookData.create()
        .name("Validate payment")
        .url("https://api.example.com/validate")
        .type(HookType.PRE_TRANSACTION)
        .active(true)
        .timeout(30)
        .retryCount(3));
FieldTypeDescription
nameStringDescriptive name for the hook.
urlStringEndpoint URL Blnk calls when the hook runs.
typeStringPRE_TRANSACTION or POST_TRANSACTION.
activebooleanWhether the hook is enabled.
timeoutNumberMaximum time in seconds allowed for the hook to execute.
retry_countNumberMaximum number of retry attempts if the hook fails.

Save the hook ID

Use response.data().get("id").asText() to view, update, or delete the hook later.

Response

{
  "id": "hk_890bdbc4-467f-4670-8424-5667e41daf29",
  "name": "Pre-transaction validation",
  "url": "https://api.example.com/validate",
  "type": "PRE_TRANSACTION",
  "active": true,
  "timeout": 30,
  "retry_count": 3,
  "created_at": "2024-11-26T08:36:36.238244338Z",
  "last_run": "0001-01-01T00:00:00Z",
  "last_success": false
}
FieldTypeDescription
idStringUnique ID for the hook. Use it to view, update, or delete the hook.
created_atStringDate and time the hook was created.
last_runStringDate and time the hook last executed.
last_successbooleanWhether the most recent execution succeeded.