Set GitHub webhook
Connect an application to a GitHub repository with a personal access token via POST /v2/apps//deploy/webhook, or send @ to remove the webhook.
POST
Set GitHub Webhook
string
required
The API key for your account. You can find this in your account settings.
apps:deploy scope.
This endpoint connects an application to a GitHub repository the classic way: generate a personal access token (ghp_* or the fine-grained github_pat_* format) and Square Cloud returns a unique webhook URL to register on that repository so pushes trigger a deploy. Sending access_token: "@" instead removes the existing webhook and access token from the application.
Configuring or removing a webhook invalidates the cached response from Get Current Deployment. Calls are rate limited to 5 per 60 seconds per user, and on workspace-shared applications the caller needs the admin role or ownership. To review deploy attempts triggered by this webhook, use List Deployments.
A webhook and a GitHub App link can be configured on the same application at the same time: setting up one does not remove the other.
Parameters
string
required
The ID of the application. You can find this in the URL of your application’s dashboard.
string
required
The access token for your GitHub repository. You can find this in your GitHub Tokens Classic
Response
string
Indicates whether the call was successful:
success if it was, error if not.object
The contents of the response.
Common errors
Webhook deliveries
GitHub sends each push to the webhook URL (POST https://api.squarecloud.app/v2/git/webhook/{webhook}). The reply is plain text (text/plain) that says whether a deploy was queued, so the Recent Deliveries list of the webhook on GitHub shows what happened to each push. Only the 429 replies with JSON (KEEP_CALM).
A 200 is sent only after the deploy was stored in the queue:
Nothing was deployed.
Every
202 is answered before the rate limit, so it doesn’t use up the webhook’s limit of 1 push per 15 seconds. A release sent with git push --follow-tags, or a merged pull request whose branch GitHub deletes automatically, no longer holds back the deploy of the branch push that arrives with it. For a tag or a deleted branch, the reply starts with its code, as shown on GitHub in Settings > Webhooks > Recent Deliveries, in the Response tab:
Related
- CLI:
squarecloud app deploy webhook - SDKs:
api.apps.deploys.setWebhook()(JavaScript),client.apps.deploys.set_webhook()(Python),c.Apps.Deploys.SetWebhook()(Go)

