Edit chainhooks

Modify existing chainhooks using the SDK

Modify existing chainhooks including filters, actions, and options. The Platform UI doesn't support editing - use the SDK instead.

The Platform UI does not currently support editing chainhooks. You must use the SDK or API to make updates.

updateChainhook

Mutable vs Immutable fields

MutableImmutable
namechain
filtersnetwork
action
options

Basic Update Example

import { ChainhooksClient, CHAINHOOKS_BASE_URL } from '@hirosystems/chainhooks-client';
const client = new ChainhooksClient({
baseUrl: CHAINHOOKS_BASE_URL.testnet,
apiKey: process.env.HIRO_API_KEY!,
});
await client.updateChainhook('chainhook-uuid', {
name: 'Updated chainhook name',
filters: {
events: [{ type: 'ft_transfer', asset_identifier: 'SP...ABC.token::usdc' }],
},
});

Add event filter (while preserving existing events)

In order to add a new event filter to an existing chainhook, you can fetch the current definition, modify it, and then update it.

// ✅ Good: Fetch first
const current = await client.getChainhook(uuid);
await client.updateChainhook('chainhook-uuid', {
filters: {
events: [
...(current.definition.filters.events ?? []),
{ type: 'contract_call', contract_identifier: 'SP...XYZ.counter' },
],
},
});
// ❌ Bad: Will overwrite any existing events
await client.updateChainhook(uuid, {
filters: { events: { type: 'contract_call', contract_identifier: 'SP...XYZ.counter' } },
});

Update Multiple Fields

await client.updateChainhook('chainhook-uuid', {
name: 'Updated name',
filters: { events: [{ type: 'stx_transfer', sender: 'SP...SENDER' }] },
action: { type: 'http_post', url: 'https://new-url.com/webhooks' },
options: { decode_clarity_values: true },
});
const updated = await client.getChainhook('chainhook-uuid');
console.log('Updated:', updated.definition.name);

How is this guide?