Deployments API

See API Authentication before starting with the API calls below.


You can start any Squash deployment by using the API calls described in this page. We will list below each API call in detail as well as some API request samples.

Start a Deployment

URL format: https://api.squash.io/a/deployment/start/?repo=<repository_name>&branch_name=<branch>&expire=<expire_time>

HTTP Method: GET
Success Response Code: 200
Success Response Body: JSON data

Supported fields:

  • branch_name: The  branch name (non-escaped) as represented in Github/Gitlab/Bitbucket.
  • repo: The repository name as represented in Github/Gitlab/Bitbucket.
  • expire (optional): This is the expiration time used by Squash’s auto-shutdown policies. Available choices:
    • 30m, 1h, 2h, 3h, 4h, 5h, 6h, 8h, 10h, 12h, 16h, 1d, 2d, 3d, 4d, 5d, 15d, 30d, 45d, 60d
    • If this field is not provided Squash will use the default expire time defined in the repository settings page.
  • app_name (optional): This is only needed when using repositories with multiple applications. For such cases you can specify the exact application name in this field as defined in the Squash YAML file.
  • expiration_type (optional): If this field is not provided Squash will use the Auto Shutdown policy defined in the repository settings page. Available choices:
    • idle: Squash will apply the Inactivity based policy. For example, if you provide the value “4h” for the “expire” field then Squash will automatically shut it down when the deployment is inactive for a 4 hour period.
    • datetime: Squash will apply the Date & Time policy. For example, if you specify the value “4h” for the “expire” field then Squash will automatically shut down the deployment after 4 hours from the time the deployment is commissioned, regardless of activity in the deployment.

Request Sample:

$ curl -i -H 'Squash-Key: your-squash-api-key' \
'https://api.squash.io/a/deployment/start/?repo=MyRepoName&branch_name=my-feature-branch&expire=1h'

Stop a Deployment

URL format: https://api.squash.io/a/deployment/stop/?repo=<repository_name>&branch_name=<branch>

HTTP Method: GET
Success Response Code: 200
Success Response Body: JSON data

Supported fields:

  • branch_name: The  branch name (non-escaped) as represented in Github/Gitlab/Bitbucket.
  • repo: The repository name as represented in Github/Gitlab/Bitbucket.
  • app_name (optional): This is only needed when using repositories with multiple applications. For such cases you can specify the exact application name in this field as defined in the Squash YAML file.
  • include_dependencies: This will automatically shutdown any dependencies included in a dependency chain, if defined for a specific deployment. See deployment dependencies for more information.

Request Sample:

$ curl -i -H 'Squash-Key: your-squash-api-key' \
'https://api.squash.io/a/deployment/stop/?repo=MyRepoName&branch_name=my-feature-branch'

Restart a Deployment

URL format: https://api.squash.io/a/deployment/restart/?repo=<repository_name>&branch_name=<branch>

HTTP Method: GET
Success Response Code: 200
Success Response Body: JSON data

Supported fields:

  • branch_name: The  branch name (non-escaped) as represented in Github/Gitlab/Bitbucket.
  • repo: The repository name as represented in Github/Gitlab/Bitbucket.
  • app_name (optional): This is only needed when using repositories with multiple applications. For such cases you can specify the exact application name in this field as defined in the Squash YAML file.
  • include_dependencies: This will automatically shutdown any dependencies included in a dependency chain, if defined for a specific deployment. See deployment dependencies for more information.
  • with_cache: By default Squash will restart deployments without the Deployment Cache. If any value is provided for this field the cache will be used if available.
  • with_storage: if any value is provided, the restart is performed with Persistent storage (if available).

Sample Request:

$ curl -i -H 'Squash-Key: your-squash-api-key' \
'https://api.squash.io/a/deployment/restart/?repo=MyRepoName&branch_name=my-feature-branch'

Response Sample

{"status": "ready",
 "ssh_port": "6512",
 "ssh_ip": "18.118.123.123",
 "deployment_url": "https://cart-v2-a3fg1.squash.io",
 "execution_id": "0f0d8890-ad2f-4c38-8457-b166c36bffe3",
 "msg": "deployment is starting up"
}
  • status has the following options: “pending”, “ready” and “error”
    • pending: the deployment has started successfully and is in progress
    • ready: the deployment start up process is ready and you can now connect to the server through SSH.
    • error: an error message and error code are included within the msg field
  • ssh_port: only available when status is ready
  • ssh_ip: only available when status is ready
  • deployment_url: This is the Squash URL of this deployment that you can use for testing
  • execution_id: This is a long unique identifier that represents an specific deployment run.
  • msg: Squash will display status or error messages in this field

How to SSH to a deployment VM

Once you receive an API response with status ready you can then assemble an SSH connection as follows. Always use the username test-instance when connecting to a deployment VM:

$ ssh -p <ssh_port> test-instance@<ssh_ip>

Example:

$ ssh -p 6512 test-instance@18.123.23.123

More details on the Squash deployment environment.