gh event subscription create

gh event subscription create [flags]

Create a subscription to events of the given types on a resource, without listening to it.

Pass the resource URL with --resource and the event types with --event, repeating the flag or separating types with commas:

  • com.github.pull_request.review.submitted.v1: a review was submitted
  • com.github.pull_request.state.changed.v1: the pull request was merged, closed, reopened, marked ready for review, or converted to draft
  • com.github.pull_request.head.changed.v1: the head branch changed, for example after a push
  • com.github.pull_request.merge_conflict.v1: the pull request has a merge conflict
  • com.github.pull_request.check_suite.status.changed.v1: a check suite on the head commit completed, such as a CI workflow

Creating a subscription is idempotent: if an active subscription for the same resource and event types exists, it is returned instead.

Once successful, the command prints the subscription ID to stdout. Use gh event listen --subscription to receive its events. To create a subscription and listen to it in one step, use gh event listen --resource instead.

Options

--event <type>
Event type to subscribe to; repeat or separate with commas for more than one
-q, --jq <expression>
Filter JSON output using a jq expression
--json <fields>
Output JSON with the specified fields
--resource <string>
URL of the resource to subscribe to
-t, --template <string>
Format JSON output using a Go template; see "gh help formatting"

JSON Fields

createdAt, eventTypes, eventsUrl, expiresAt, id, resourceUrl, url

Examples

# Subscribe to reviews and state changes of a pull request
$ gh event subscription create --resource https://github.com/OWNER/REPO/pull/123 --event com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1

See also