Hooks

Update an existing hook

Update an existing hook with the Go SDK.

PUT/hooks/{hook_id}

Use client.Hooks.Update to change the configuration of an existing webhook.

Call the method

updated, _, _ := client.Hooks.Update(
	"hk_890bdbc4-467f-4670-8424-5667e41daf29",
	blnkgo.UpdateHookRequest{
		Name:       "Pre-transaction validation",
		URL:        "https://api.example.com/validate",
		Type:       blnkgo.HookTypePreTransaction,
		Active:     false,
		Timeout:    30,
		RetryCount: 3,
	},
)
FieldTypeDescription
hookIDstringID of the hook to update.
NamestringDescriptive name for the hook.
URLstringEndpoint URL Blnk calls when the hook runs.
Typeblnkgo.HookTypeblnkgo.HookTypePreTransaction or blnkgo.HookTypePostTransaction.
ActiveboolWhether the hook is enabled.
TimeoutintMaximum time in seconds allowed for the hook to execute.
RetryCountintMaximum number of retry attempts if the hook fails.

Verify the changes

Read updated to confirm the URL, type, and active status. The hook ID stays the same.

Response

{
  "id": "hk_890bdbc4-467f-4670-8424-5667e41daf29",
  "name": "Pre-transaction validation",
  "url": "https://api.example.com/validate",
  "type": "PRE_TRANSACTION",
  "active": false,
  "timeout": 30,
  "retry_count": 3,
  "created_at": "2024-11-26T08:36:36.238244338Z",
  "last_run": "0001-01-01T00:00:00Z",
  "last_success": false
}

Go response (*blnkgo.HookResponse)

FieldTypeDescription
IDstringUnique ID for the hook.
NamestringUpdated name for the hook.
URLstringUpdated endpoint URL.
Typeblnkgo.HookTypePRE_TRANSACTION or POST_TRANSACTION.
ActiveboolWhether the hook is enabled.
TimeoutintMaximum time in seconds allowed for the hook to execute.
RetryCountintMaximum number of retry attempts if the hook fails.
CreatedAtstringDate and time the hook was created.
LastRunstringDate and time the hook last executed.
LastSuccessboolWhether the most recent execution succeeded.