Connect a Git repository for deploys
Connects a Git repository to a sandbox for deploys. Private repos need an SSH URL; add the returned deployKeyPublic as a deploy key on the git host. A sandbox may have only one connected repository at a time (409 repository_limit). Only available on account-owned (not guest) sandboxes.
Authorizations
Personal API token, sent as Authorization: Bearer <SANDYWP_API_KEY>. Obtain one from the dashboard account menu (API keys), sandywp auth login, or POST /api/account/tokens. A missing or invalid token returns 401 auth_required. Scoped OAuth tokens are limited to the Imports family and GET /api/account/me; see the top-level conventions.
Headers
Selects which of the caller's workspaces to act in, for accounts belonging to more than one (legacy alias: X-SandyWP-Organization). Defaults to the caller's own personal workspace when omitted. Every id in this API (sandboxes, Templates, repositories) is scoped to a single workspace, so this header changes which set of resources is visible.
Path Parameters
The sandbox id.
Body
Required. https:// URL with no embedded credentials for a public repo, or an SSH URL (git@host:owner/repo.git or ssh://git@host/owner/repo.git) for a private one — which grammar is enforced depends on isPrivate.
"https://github.com/you/my-plugin.git"
Required. Where inside wp-content the repository is synced: plugin → wp-content/plugins/<folderName>, theme → wp-content/themes/<folderName>, wp_content → wp-content/<folderName>.
plugin, theme, wp_content Required. A single path segment (no slashes) under the destination — the target folder name.
^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$"my-plugin"
Branch to deploy. Defaults to main.
^[A-Za-z0-9][A-Za-z0-9._/-]{0,200}$Whether the repo is private. When true, a per-repository SSH deploy key is generated. Defaults to false.
Deploy automatically on push, via the returned webhookUrl. Defaults to false.
Response
The connected repository and its webhook URL.
The owner-facing view of a connected Git repository. Strips the webhook secret — the plaintext webhook URL is only ever returned once, at connect time.
One-time-shown URL (carries an opaque token) to configure as the git host's push webhook for autoDeploy.

