How to Send a repository_dispatch With the gh CLI
gh api posts a repository_dispatch using the CLI login, so no manual Authorization header is needed.
Use gh api with --method POST against the dispatches endpoint. The CLI supplies the token, and -f/--input set the event_type and client_payload.
Steps
- Authenticate once with
gh auth login(or setGH_TOKEN). - Call
gh apiwith--method POSTon the dispatches path. - Pass
event_typeand nestedclient_payloadfields.
Send the dispatch
Terminal
gh api \
--method POST \
repos/OWNER/REPO/dispatches \
-f event_type=deploy-request \
-f 'client_payload[ref]=main'From another workflow
.github/workflows/ci.yml
steps:
- env:
GH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
run: gh api --method POST repos/OWNER/REPO/dispatches -f event_type=deploy-requestGotchas
- The default
GITHUB_TOKENcannot dispatch across repos; use a scoped PAT or app token. - A successful dispatch returns 204 with no body, so do not parse a response.
Related guides
How to Trigger CI From a Webhook With repository_dispatchTrigger a GitHub Actions workflow from an external system by POSTing a repository_dispatch event to the REST…
How to Send an Outbound Webhook From a WorkflowSend an outbound webhook from a CI workflow with a curl POST, failing the step on a non-2xx response so a dro…