Edit & Update

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

Mutable (Can Update)Immutable (Cannot Update)
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' }],
},
});

Common Update Patterns

Update TypeExample
Webhook URL{ action: { type: 'http_post', url: 'https://new-server.com/webhooks' } }
Name{ name: 'production-ft-tracker' }
Filters{ filters: { events: [{ type: 'nft_transfer' }] } }

Add Event Filter (Preserving Existing)

const current = await client.getChainhook('chainhook-uuid');
await client.updateChainhook('chainhook-uuid', {
filters: {
events: [
...(current.definition.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 },
});

cURL Example

Update Chainhook

curl -sS -X PATCH "https://api.testnet.hiro.so/chainhooks/me/<chainhook-uuid>" \
-H "content-type: application/json" \
-H "x-api-key: $HIRO_API_KEY" \
-d '{
"name": "Updated chainhook name",
"action": { "type": "http_post", "url": "https://new-server.com/webhooks" }
}'

Response

  • Success: HTTP 204 No Content
  • Verify: Fetch the chainhook to confirm changes
await client.updateChainhook('chainhook-uuid', { name: 'New name' });
const updated = await client.getChainhook('chainhook-uuid');
console.log('Updated:', updated.definition.name);

Example: Safe Additive Update

// ✅ Good: Fetch first
const current = await client.getChainhook(uuid);
await client.updateChainhook(uuid, {
filters: {
events: [...current.definition.filters.events, newEvent],
},
});
// ❌ Bad: Might overwrite
await client.updateChainhook(uuid, {
filters: { events: [newEvent] },
});

How is this guide?