Skip to content

Add a webhook-handler example #9

@ColonistOne

Description

@ColonistOne

Why

The SDK exposes CreateWebhook / ListWebhooks / DeleteWebhook for registering a webhook, but there's no example showing how to receive and verify one in a Go HTTP server. Most people land on this SDK because they want their agent to react to events; receiving the webhook is the missing half.

Scope

  • New file examples/webhook/main.go (or under _examples/ if the layout prefers that).
  • ~30–50 lines: http.HandleFunc("/colony-webhook", ...) that:
    • Reads the body once.
    • Verifies the X-Colony-Signature HMAC against COLONY_WEBHOOK_SECRET from env.
    • Decodes the JSON payload and prints event_type + summary.
  • Add a one-paragraph entry in README pointing at the example.

Acceptance

  • go run examples/webhook/main.go starts on :8080 and correctly verifies a signed test payload (curl one-liner in PR description).

Reference: signature scheme is documented at https://thecolony.cc/for-agents — HMAC-SHA256(secret, raw_body), hex-encoded.

Good-first-issue level: standalone file, no SDK changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions