> ## Documentation Index
> Fetch the complete documentation index at: https://docs.instapods.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Git Deployment

> Connect repositories and manage git-based deployments.

Connect a Git repository to a pod for automatic or manual deployments. Supports GitHub (with webhooks and commit status checks) and any Git URL via HTTPS.

## Get Git Config

```
GET /api/pods/{name}/git
```

**Response: `200 OK`**

```json theme={null}
{
  "repo_url": "https://github.com/you/repo",
  "branch": "main",
  "auto_deploy": true,
  "build_command": "",
  "last_deployment": {
    "id": "deploy_abc123",
    "status": "success",
    "commit_sha": "a1b2c3d",
    "commit_message": "fix: update error handling",
    "created_at": "2026-02-20T10:30:00Z",
    "finished_at": "2026-02-20T10:30:18Z"
  },
  "created_at": "2026-02-20T09:00:00Z"
}
```

Returns `null` if no repository is connected.

## Connect a Repository

```
POST /api/pods/{name}/git
```

**Request Body:**

```json theme={null}
{
  "repo_url": "https://github.com/you/repo",
  "branch": "main",
  "auth_token": "ghp_optional_for_private_repos",
  "build_command": "",
  "auto_deploy": true
}
```

| Field           | Type    | Required | Description                                     |
| --------------- | ------- | -------- | ----------------------------------------------- |
| `repo_url`      | string  | Yes      | Git repository URL (HTTPS)                      |
| `branch`        | string  | No       | Branch to deploy (default: `main`)              |
| `auth_token`    | string  | No       | Personal access token for private repos         |
| `build_command` | string  | No       | Custom build command (overrides auto-detection) |
| `auto_deploy`   | boolean | No       | Deploy on push (default: `true`)                |

**Response: `201 Created`**

Returns the git config object.

**Errors:**

| Code  | Reason                       |
| ----- | ---------------------------- |
| `400` | Invalid URL, pod not running |
| `409` | Repository already connected |

## Update Settings

```
PUT /api/pods/{name}/git
```

**Request Body:**

```json theme={null}
{
  "branch": "develop",
  "build_command": "npm ci && npm run build",
  "auto_deploy": false
}
```

All fields are optional. Only provided fields are updated.

**Response: `200 OK`**

## Disconnect

```
DELETE /api/pods/{name}/git
```

**Response: `200 OK`**

```json theme={null}
{
  "status": "disconnected"
}
```

## Trigger Deploy

```
POST /api/pods/{name}/git/deploy
```

No request body required. Pulls the latest code from the configured branch and deploys.

**Response: `202 Accepted`**

```json theme={null}
{
  "id": "deploy_xyz789",
  "status": "deploying",
  "created_at": "2026-02-20T11:00:00Z"
}
```

Deployment runs asynchronously. Poll the deployment detail endpoint to check status.

## List Deployments

```
GET /api/pods/{name}/git/deployments
```

| Query Param | Type | Default | Description               |
| ----------- | ---- | ------- | ------------------------- |
| `limit`     | int  | 10      | Max deployments to return |

**Response: `200 OK`**

```json theme={null}
{
  "deployments": [
    {
      "id": "deploy_abc123",
      "status": "success",
      "commit_sha": "a1b2c3d",
      "commit_message": "fix: update error handling",
      "trigger": "push",
      "created_at": "2026-02-20T10:30:00Z",
      "finished_at": "2026-02-20T10:30:18Z"
    }
  ]
}
```

**Deployment statuses:** `deploying`, `success`, `failed`, `rolled_back`

**Trigger types:** `push` (webhook), `manual`, `rollback`

## Get Deployment Detail

```
GET /api/pods/{name}/git/deployments/{id}
```

**Response: `200 OK`**

Returns a single deployment object with a `build_log` field containing the full build output:

```json theme={null}
{
  "id": "deploy_abc123",
  "status": "success",
  "commit_sha": "a1b2c3d",
  "commit_message": "fix: update error handling",
  "trigger": "push",
  "build_log": "Pulling latest code...\nnpm install...\nnpm run build...\nRestarting service...\nDeploy complete.",
  "created_at": "2026-02-20T10:30:00Z",
  "finished_at": "2026-02-20T10:30:18Z"
}
```

## Rollback

```
POST /api/pods/{name}/git/rollback
```

**Request Body:**

```json theme={null}
{
  "deployment_id": "deploy_abc123"
}
```

| Field           | Type   | Required | Description                                            |
| --------------- | ------ | -------- | ------------------------------------------------------ |
| `deployment_id` | string | No       | Target deployment ID (defaults to previous deployment) |

**Response: `202 Accepted`**

Returns a new deployment object with `trigger: "rollback"`.

## Webhooks

These endpoints are public (no auth required). They receive push events from Git providers.

```
POST /api/webhooks/github
POST /api/webhooks/git/{podName}
```

The GitHub webhook is configured automatically when connecting a GitHub repository. For other providers, use the generic webhook URL shown in the dashboard.

Commits containing `[skip deploy]` in the message are ignored.
