# Publish an app to its live site.

POST https://services.leadconnectorhq.com/ai-builder-api/projects/{projectId}/infra/promote-to-production

Publishes the app to its live site: its managed address, and every custom domain attached to it (`changes` kind `domain`) once that domain is `active`. A domain that becomes active later joins the live site without another publish. Check `GET .../publishability` first and send the `sourceRunId` it returns, so the build the creator approved is the one that goes live. Returns a publish job: poll `GET .../infra/publish-jobs/{publishJobId}` until `status` is `succeeded` (`publishedUrl` is the live site) or `failed` (`error` says why). Send the same `idempotencyKey` to retry safely.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `clientportal-ai.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | The API version. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectId` | string | Yes | The project. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ai-builder-api/projects/{projectId}/infra/promote-to-production": {
      "post": {
        "summary": "Publish an app to its live site.",
        "operationId": "publishAnAppToItsLiveSite",
        "description": "Publishes the app to its live site: its managed address, and every custom domain attached to it (`changes` kind `domain`) once that domain is `active`. A domain that becomes active later joins the live site without another publish. Check `GET .../publishability` first and send the `sourceRunId` it returns, so the build the creator approved is the one that goes live. Returns a publish job: poll `GET .../infra/publish-jobs/{publishJobId}` until `status` is `succeeded` (`publishedUrl` is the live site) or `failed` (`error` says why). Send the same `idempotencyKey` to retry safely.",
        "parameters": [
          {
            "in": "path",
            "name": "projectId",
            "required": true,
            "description": "The project.",
            "example": "prj_5f0c2a3e",
            "schema": {
              "type": "string",
              "pattern": "^prj_[A-Za-z0-9_-]+$"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "The API version.",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishProjectRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Publish job accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublishProjectResponse"
                }
              }
            }
          },
          "409": {
            "description": "Domain revision, publish precondition, or idempotency conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "504": {
            "description": "Publish preparation exceeded the bounded end-to-end deadline.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "clientportal-ai.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A sub-account access token: a Marketplace app's OAuth token or a Private Integration Token."
      }
    },
    "schemas": {
      "PublishProjectRequest": {
        "type": "object",
        "properties": {
          "sourceRunId": {
            "type": "string",
            "pattern": "^run_[A-Za-z0-9_-]+$",
            "description": "Exact successful run backing the preview approved by the creator. When provided, publish fails closed instead of selecting a different run that became ready concurrently.",
            "example": "run_7b2c9e41"
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Stable retry key. Domain-aware clients should always provide one; when omitted, source-bound requests receive a deterministic server-generated key while source-less legacy requests remain independent publish attempts.",
            "example": "publish-prj_5f0c2a3e-2026-10-23"
          }
        },
        "title": "PublishProjectRequest"
      },
      "PublishProjectResponse": {
        "type": "object",
        "required": [
          "jobId",
          "hostname",
          "aliases",
          "domainRevision",
          "url",
          "status"
        ],
        "properties": {
          "jobId": {
            "type": "string",
            "description": "The publish job; poll it with `GET .../infra/publish-jobs/{publishJobId}`.",
            "example": "job_3f9a1c2b7d4e5f6a7b8c9d0e"
          },
          "hostname": {
            "type": [
              "string",
              "null"
            ],
            "description": "The managed address the app is published to.",
            "example": "5f0c2a3e.app.clientclub.net"
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The active custom domains the publish also serves.",
            "example": [
              "portal.acmefitness.com"
            ]
          },
          "domainRevision": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "The managed address's revision this publish took.",
            "example": 1
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "The live site's address once the job succeeds.",
            "example": "https://5f0c2a3e.app.clientclub.net"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ],
            "description": "The job's state; `queued` when accepted.",
            "example": "queued"
          }
        },
        "title": "PublishProjectResponse"
      },
      "ApiError": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "requestId"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "example": "about:blank",
            "description": "A URI identifying the kind of error."
          },
          "title": {
            "type": "string",
            "example": "Request validation failed",
            "description": "Short summary of the kind of error."
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599,
            "example": 422,
            "description": "The HTTP status code."
          },
          "detail": {
            "type": "string",
            "example": "One or more fields are invalid.",
            "description": "What went wrong with this request."
          },
          "instance": {
            "type": "string",
            "example": "/api/v1/runs",
            "description": "The request path that failed."
          },
          "code": {
            "type": "string",
            "example": "validation_error",
            "description": "Stable, machine-readable error code."
          },
          "requestId": {
            "type": "string",
            "example": "req_01HXQ8Z6J9K2",
            "description": "The request's id, for support."
          },
          "fieldErrors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "code",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string",
                  "example": "prompt",
                  "description": "The invalid field, as a dotted path."
                },
                "code": {
                  "type": "string",
                  "example": "required",
                  "description": "Machine-readable reason."
                },
                "message": {
                  "type": "string",
                  "example": "Prompt is required.",
                  "description": "Human-readable reason."
                }
              },
              "title": "FieldError"
            },
            "description": "One entry per invalid field, when the request body was invalid.",
            "example": [
              {
                "field": "name",
                "code": "too_long",
                "message": "name must be at most 120 characters"
              }
            ]
          }
        },
        "title": "ApiError"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "sourceRunId": "run_7b2c9e41",
  "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "sourceRunId": "run_7b2c9e41",
      "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/ai-builder-api/projects/{projectId}/infra/promote-to-production"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "sourceRunId": "run_7b2c9e41",
    "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "sourceRunId": "run_7b2c9e41",
  "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"sourceRunId\":\"run_7b2c9e41\",\"idempotencyKey\":\"publish-prj_5f0c2a3e-2026-10-23\"}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production"
  payload := strings.NewReader(`{
  "sourceRunId": "run_7b2c9e41",
  "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "sourceRunId": "run_7b2c9e41",
  "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "sourceRunId": "run_7b2c9e41",
  "idempotencyKey": "publish-prj_5f0c2a3e-2026-10-23"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/infra/promote-to-production' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
