Deploy website Git repository
Clones a Git repository into a directory of the website, or pulls it again.
Clones a Git repository into a directory of the website, or pulls it again. An empty or missing
directory gets a clone of the branch. A directory that already holds this repository and branch is
reset to its last commit and pulled: changes made on the server to files the repository tracks are
discarded, files it does not track stay. A directory that holds other files, including another
repository or another branch of this one, is rejected. composer install runs after the clone or
pull when the repository has a composer.json.
The call waits for the deployment and returns its log. is_success false means Git or composer
failed and the log says why. A second call for the same directory is rejected while the first is
still waiting for the server. If the request times out, the deployment may still finish on the
server; calling again later with the same repository and branch pulls.
Private repositories need an SSH URL and the account's Git SSH key from Generate Git SSH key,
added to the repository as a deploy key.
API Token authentication
u123456789Domain name
mydomain.tldClone URL of the repository on any Git host, SSH or HTTPS. Private repositories need an SSH URL and the account's Git SSH key added to the repository as a deploy key. An HTTP or HTTPS URL with a username or token, or any URL with a password, is rejected.
git@github.com:octocat/my-site.gitBranch to clone and pull
mainPattern: ^[a-zA-Z0-9._-]([a-zA-Z0-9\/._-]{0,253}[a-zA-Z0-9._-])?$Directory under the website document root, exactly as List website Git repositories returns
it for an existing repository. Empty, null or omitted means the document root.
""Example: my-siteSuccess response
Result of cloning or pulling a Git repository into the website
Whether the clone or pull, and composer install when it ran, finished without errors
trueLog of the deployment steps, and the Git or composer error when is_success is false
Deployment start Repository cloned Deployment endUnauthenticated response
Validation error response
Error response
POST /api/hosting/v1/accounts/{username}/websites/{domain}/git/repositories/deploy HTTP/1.1
Host: developers.hostinger.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 93
{
"repository_url": "git@github.com:octocat/my-site.git",
"branch": "main",
"directory": "my-site"
}{
"is_success": true,
"output": "Deployment start\nRepository cloned\nDeployment end\n"
}Last updated
Was this helpful?