Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Deploy website Git repository

Clones a Git repository into a directory of the website, or pulls it again.

Deploy website Git repository

post

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.

Authorizations
AuthorizationstringRequired

API Token authentication

Path parameters
usernamestringRequiredExample: u123456789
domainstringRequired

Domain name

Example: mydomain.tld
Body
repository_urlstring · min: 1 · max: 255Required

Clone 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.

Example: git@github.com:octocat/my-site.git
branchstring · min: 1 · max: 255Required

Branch to clone and pull

Example: mainPattern: ^[a-zA-Z0-9._-]([a-zA-Z0-9\/._-]{0,253}[a-zA-Z0-9._-])?$
directorystring · max: 100 · nullableOptional

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.

Default: ""Example: my-site
Responses
200

Success response

application/json

Result of cloning or pulling a Git repository into the website

is_successbooleanRequired

Whether the clone or pull, and composer install when it ran, finished without errors

Example: true
outputstringRequired

Log of the deployment steps, and the Git or composer error when is_success is false

Example: Deployment start Repository cloned Deployment end
post/api/hosting/v1/accounts/{username}/websites/{domain}/git/repositories/deploy
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?