mcid-cli webhooks
Create inbound webhooks from a schema file, manage reader roles, list submissions and send signed test payloads from the terminal.
The CLI covers the whole inbound webhook lifecycle for admins: creation from a schema file with the signing secret stored locally, updates and rotation, submission inspection and export, and signed test sends against your own deployment.
Create, update, rotate
mcid-cli webhook create ./schema.json \
--name "Contact form" --roles 123456789012345678 \
--accept-origin https://portal.example.com --profile prod
mcid-cli webhook list --profile prod
mcid-cli webhook get contact-form --profile prod
mcid-cli webhook roles set contact-form --roles 987654321098765432 --profile prod
mcid-cli webhook rotate-secret contact-form --profile prodcreate stores the signing secret encrypted on the profile so webhook send can sign
later without anyone pasting secrets around. The secret is printed in plain text only
with --reveal.
Link accounts from submissions
A webhook can record an account a member holds elsewhere, such as their GitHub username (linking accounts). Name the payload field that holds the member id and the one that holds the username; pass all three flags together:
mcid-cli webhook create ./schema.json --name "GitHub link" --roles 123456789012345678 \
--identity-provider github \
--identity-member-field profile.discordId \
--identity-handle-field profile.github --profile prod
mcid-cli webhook update github-link --identity-provider github \
--identity-member-field profile.discordId --identity-handle-field profile.github --profile prod
mcid-cli webhook update github-link --clear-identity --profile prodSubmissions
mcid-cli webhook submissions contact-form --since 24h --profile prod
mcid-cli webhook submissions export contact-form --file subs.csv --profile prod
mcid-cli webhook submission contact-form <submission-id> --profile prod
mcid-cli webhook docs contact-form --profile prodsubmissions export is a real nested command, so webhook submissions export X
exports webhook X instead of looking for a webhook named "export". Exports are written
with owner-only file permissions and refuse to overwrite an existing --file without
--force.
Test your webhook from the terminal
This is the quickest way to find out that a form works before you write any signing code.
- Create the webhook from your schema and keep the secret on this machine:
mcid-cli webhook create ./schema.json --name "Contact form" --project portal --profile prod. - Check the schema is accepted:
mcid-cli schema preview ./schema.json --profile prod. - Send a generated payload:
mcid-cli webhook send contact-form --example --profile prod. - Watch it arrive:
mcid-cli webhook watch contact-form --profile prodin a second terminal. - Copy the signing into your own code with
mcid-cli webhook send contact-form --example --print-curl.
watch prints a compact row per new submission, and --json streams one JSON object
per line for jq. Stop it with Ctrl+C.
Send signed test payloads
# A payload generated from the webhook's schema (steps[].fields aware)
mcid-cli webhook send contact-form --example --print-curl --profile prod
# Your own payload
mcid-cli webhook send contact-form --data ./payload.json \
--api-key pk_xxxxxxxx.your-secret-here --profile prodWhat send does for you:
- Builds
--examplepayloads from the schema with the same builder the API uses, nesting each step under itskey, following conditions, and picking the first enum option value (the{ value, label }object would be rejected). - Validates your
--datapayload against the schema locally first, with the same validator the API runs. Missing required fields, wrong enum values and unknown steps fail before anything is signed or sent. - Signs
timestamp.rawBodywith HMAC-SHA256 using the locally stored secret. --print-curlprints the command with<MCID_API_KEY>as a placeholder unless you pass--reveal. The printed signature stays a placeholder: signatures expire after five minutes and work once, so a pre-signed curl would be dead on arrival.
Note
Exit code 2 with a body in the output means the ingest endpoint rejected the submission (bad signature, replayed timestamp, schema violation). The rejection reason is in the JSON that follows.
Source: apps/cli/src/commands/webhook.ts.