Skip to main content
defineWorkflowBlockDeactivate wires a deactivate handler to a trigger block. The handler runs once when the workflow is disabled or replaced by a new version. Mirror what activate.ts set up: typically, tear down the webhook registration with the upstream service.

Parameters

block
WorkflowBlock
required
The block returned by defineWorkflowBlock in block.ts.
deactivate
function
required
The handler function. Receives a context object with config (typed from the block’s configSchema) and metadata.metadata mirrors what was passed to activate, including the uniqueActivationId needed to identify the registration to tear down:
FieldTypeDescription
workflowIdstringID of the workflow this block belongs to.
workflowVersionIdstringID of the workflow version being deactivated.
workflowBlockIdstringID of this block instance within the workflow.
uniqueActivationIdstringThe same ID that was passed to activate. Use it to look up and tear down the webhook registration you stored during activation.
workflowTitlestringHuman-readable title of the workflow.
workflowUrlstringLink to the workflow in the Attio UI.

Example

deactivate.ts
import {Workflows} from "attio/server"
import block from "./block"

export default Workflows.defineWorkflowBlockDeactivate(block, async ({config, metadata}) => {
  const response = await fetch(`https://api.example.com/webhooks/${metadata.uniqueActivationId}`, {
    method: "DELETE",
  })

  if (!response.ok) {
    // Deregistration failed — report the error
    return {type: "error", errorMessage: `Failed to delete webhook: ${response.statusText}`}
  }

  // Webhook removed successfully
  return {type: "complete"}
})

See also