Create a Deployment
Use the /v1330/deployments endpoint to trigger a new deployment pipeline for a specified repository. This endpoint is part of the v1330 release, which introduces asynchronous processing and webhook event streaming.
POST
/api/v1330/repositories/:id/deployments
v1330
âšī¸ V1330 Note
Starting with v1330, deployments are processed asynchronously. The API will return a deployment_id immediately. You should listen for the deployment.completed webhook or poll the status endpoint to determine when the build finishes.
Parameters
| Parameter | Type | Description |
|---|---|---|
| environmentREQUIRED | string | The name of the environment to deploy to (e.g., production, staging). |
| refREQUIRED | string | The Git reference to deploy. Can be a branch name, tag, or commit SHA. |
| strategy | object | Deployment strategy configuration. Defaults to rolling. |
| wait_for_hooks | boolean | If true, the deployment will wait for all pre-deploy webhooks to respond with 200 OK before proceeding. |
Request Body
JSON
đ Copy
{
"environment": "production",
"ref": "main",
"strategy": {
"type": "rolling",
"min_sustained_health": 0.9
},
"wait_for_hooks": true
}
Response
A successful request returns a 202 Accepted status with the deployment object.
JSON (202 Accepted)
đ Copy
{
"id": "dep_7x8k9m2n",
"repository_id": "repo_1330_alpha",
"status": "pending",
"environment": "production",
"ref": "main",
"created_at": "2023-10-27T14:30:00Z",
"updated_at": "2023-10-27T14:30:00Z",
"url": "https://api.git.dev/v1330/deployments/dep_7x8k9m2n"
}
cURL Example
Bash
đ Copy
# Create a deployment to production
curl -X POST https://api.git.dev/v1330/repositories/1330/deployments \
-H "Authorization: Bearer $GIT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"environment": "production",
"ref": "main"
}'
Error Handling
If the repository does not exist or you lack permissions, the API will return a 404 Not Found or 403 Forbidden respectively.