Skip to content
Source
Sign inSign up

Send repository events

Skills, MCP and apps / Apps and webhooks

Send repository events to another service

Your chat bot must post when someone pushes to main, or your deploy service must start when a CI run ends. A webhook does this: on each event that you pick, Source sends a signed POST request to the URL of your service.

4 min read

You need:

  • Admin access to the repository.

The webhooks are in Settings, under Integrations, at Webhooks (/@<owner>/<repo>/settings/webhooks).

1. Add a webhook

On the web:

  1. Open the repository, then Settings, then Webhooks.
  2. Click Add webhook.
  3. In Payload URL, type the URL of your receiver. Under Events, pick the events to send.
  4. Leave Secret empty, then click Add webhook. Source makes a secret.
  5. Copy the secret from the box at the top of the page. It shows only now. Give it to your receiver.

In a terminal, give --event once for each event:

src webhook create --url https://bot.example.com/source --event push --event pull_request

src prints the secret alone on standard output, once. To use your own secret of 8 to 256 characters, pipe it in. Then src does not print it:

src webhook create --url https://bot.example.com/source --event push --secret - < secret.txt

The events, by their name on the web and in src:

On the webEventSent when
PushespushA branch or a tag is created, moved or deleted.
IssuesissuesAn issue is opened, edited, closed, reopened, labeled, unlabeled, assigned or unassigned.
Pull requestspull_requestThe same as issues, and also when a draft is ready for review, when the head gets new commits, and when it is merged.
Commentsissue_commentA comment on an issue or a pull request is created or edited.
Reviewspull_request_reviewA review of a pull request is submitted.
CI runsci_runA CI run starts or ends.

Source refuses a URL that breaks one of these rules:

  • It uses https on port 443.
  • It has no user name or password, and no # part. A query string works, for example ?token=abc.
  • It is not a local, private or internal address.
  • It is not the address of TanStack Source itself.

Note

Source does not follow redirects. A 301 or a 302 answer counts as a failure.

2. Test it with a ping

A new webhook that is on gets a ping at once. To send another one:

  • On the web, click Send ping on the row of the webhook.
  • In a terminal, run src webhook ping <id>. src webhook list shows the id of each webhook.

Your receiver must answer within 10 seconds with a 2xx status. To check the signature of each request, see Webhook events and payloads.

Done

Your service gets a signed POST request for each event that you picked. Later, read and resend the deliveries, or rotate, change or delete the webhook.

What a webhook does not send

A webhook sends only what every reader of the repository can see:

  • An issue or a pull request that screening holds sends nothing. When screening releases it, it sends opened.
  • A private pull request sends nothing until it is public. Comments and reviews on such items send nothing.
  • A hidden workflow never sends ci_run.

Some changes send no event:

  • A deleted comment.
  • A merge done on GitHub, in a repository that is synced with GitHub. It sends no push.
  • A branch that is deleted on the web. It sends no push.

Limits

  • A repository has at most 20 webhooks.
  • One push sends at most 20 push events: branches first, then tags. A push that moves more refs sends no events for the rest.
  • A webhook has at most 1,000 pending deliveries. Past that, a new event gets no delivery for that webhook.

REST and MCP

An agent or a script does the same work over REST or MCP, with the same rules. A path that starts with ... is under /api/v1/repos/{owner}/{repo}.

You want toRESTMCP tool
List or add webhooksGET or POST .../hookslist_repo_webhooks, create_repo_webhook
Change or delete a webhookPATCH or DELETE .../hooks/{id}update_repo_webhook, delete_repo_webhook
Send a pingPOST .../hooks/{id}/pingsping_repo_webhook
Rotate the secretPOST .../hooks/{id}/secretrotate_repo_webhook_secret
List the deliveriesGET .../hooks/{id}/deliverieslist_repo_webhook_deliveries
Send a delivery againPOST .../hooks/{id}/deliveries/{delivery}/attemptsredeliver_repo_webhook

Use the REST API has the request bodies and the answers.