For AI agents: the complete documentation index is available at /hclapi/llms.txt, the full documentation bundle is available at /hclapi/llms-full.txt, and this page is available as Markdown at /hclapi/docs/steps/respond.md.

respond

Terminates the pipeline. Sets the status, headers, and body. No step after respond runs once it fires.

Declaration

respond {
  condition = steps.find_user.rows_affected == 0
  status    = 404
  headers = {
    "Cache-Control" = "no-store"
    "X-Trace-ID"    = uuid()
  }
  body = {
    error = "User not found"
  }
}

Attributes

AttributeTypeDefaultDescription
conditionExpressiontrueStep is skipped if false
statusint or Expression200HTTP status code
headersmap or Expression{}Dynamic or static response headers
bodyany or ExpressionnullPayload to serialize

Serialization

  • If Content-Type is absent, hclapi sets application/json and JSON-encodes body.
  • If a custom content type is provided and body is a string or byte slice, the raw payload is written.
  • Header names and values are sanitized to remove carriage-return and newline characters, preventing response-splitting attacks.