# Create a project.

POST https://services.leadconnectorhq.com/ai-builder-api/projects

Creates an app in the sub-account. Then start its first build with `POST .../agent-runs`; a sub-account token sends `externalAgent: true` because its own agent writes the code.

## 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 |
|------|------|----------|-------------|
| `Idempotency-Key` | string | No | Makes the request safe to retry: a repeat with the same key returns the first result. |
| `Version` | string | Yes | The API version. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ai-builder-api/projects": {
      "post": {
        "summary": "Create a project.",
        "operationId": "createAProject",
        "description": "Creates an app in the sub-account. Then start its first build with `POST .../agent-runs`; a sub-account token sends `externalAgent: true` because its own agent writes the code.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Makes the request safe to retry: a repeat with the same key returns the first result.",
            "example": "6d2f0a8e-1b3c-4d5e-8f9a-0b1c2d3e4f5a"
          },
          {
            "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/CreateProjectRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Project created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "429": {
            "description": "In production, the authenticated location already has five non-deleted projects.",
            "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": {
      "CreateProjectRequest": {
        "type": "object",
        "required": [
          "prompt"
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000,
            "example": "Build a mobile and web booking app for a med spa.",
            "description": "What the app should do."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "The app's name, shown to members.",
            "example": "Groundbreak"
          },
          "targetModes": {
            "deprecated": true,
            "description": "Legacy hint retained for compatibility. Use `productTarget` from the landing\ncomposer instead: `full_stack`, `landing_page`, or `mobile`.\n",
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "description": "Legacy internal runtime lane. `mobile` means native mobile/Expo, not responsive web.",
              "enum": [
                "web",
                "mobile"
              ],
              "title": "TargetMode"
            },
            "example": [
              "web"
            ]
          },
          "stackTemplate": {
            "description": "The kernel to build on; leave it out to let the service choose.",
            "type": "string",
            "enum": [
              "react_native_app_kernel_v1",
              "nuxt_clientportal_app_v1",
              "nuxt_clientportal_vibe_v1",
              "auto"
            ],
            "title": "StackTemplate"
          },
          "templateId": {
            "description": "Starter-template id (e.g. `events-v1`) to instantiate the project from.\nWhen set, the first build run scaffolds the kernel and byte-copies the\nfinished starter overlay (`instantiate` mode — no plan/design/codegen).\nOmit to build from the bare prompt.\n",
            "type": "string",
            "example": "events-v1"
          },
          "mobileCreation": {
            "description": "For a mobile app: start from scratch or from the CP Base App.",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "startingPoint"
                ],
                "properties": {
                  "startingPoint": {
                    "type": "string",
                    "enum": [
                      "scratch"
                    ],
                    "description": "Started from scratch.",
                    "example": "scratch"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "startingPoint",
                  "templateId",
                  "templateVersion"
                ],
                "properties": {
                  "startingPoint": {
                    "type": "string",
                    "enum": [
                      "cp_base"
                    ],
                    "description": "Started from the CP Base App.",
                    "example": "cp_base"
                  },
                  "templateId": {
                    "type": "string",
                    "enum": [
                      "cp-base"
                    ],
                    "description": "The template it started from.",
                    "example": "cp-base"
                  },
                  "templateVersion": {
                    "type": "string",
                    "enum": [
                      "1"
                    ],
                    "description": "The template's version.",
                    "example": "1"
                  }
                }
              }
            ],
            "title": "MobileCreation"
          },
          "appMode": {
            "description": "App branding mode. `cp_branded` builds a Client Portal branded app wired to the location's courses/communities/purchases/affiliates. Defaults to `standard`.",
            "type": "string",
            "enum": [
              "standard",
              "cp_branded"
            ],
            "title": "AppMode"
          },
          "productTarget": {
            "description": "Creator-selected landing composer category. `full_stack` means responsive web app plus backend/database; `mobile` means native Expo/React Native app.",
            "type": "string",
            "enum": [
              "full_stack",
              "mobile",
              "landing_page"
            ],
            "title": "ProductTarget"
          },
          "hostingMode": {
            "description": "Where to host the app; `managed` by default.",
            "type": "string",
            "enum": [
              "managed",
              "byo_vercel"
            ],
            "title": "HostingMode"
          },
          "clientRefId": {
            "type": "string",
            "format": "uuid",
            "description": "Your own reference for this create.",
            "example": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
          }
        },
        "title": "CreateProjectRequest"
      },
      "Project": {
        "type": "object",
        "required": [
          "id",
          "name",
          "locationId",
          "companyId",
          "ownerUserId",
          "createdByUserId",
          "visibility",
          "status",
          "stackTemplate",
          "productTarget",
          "targetModes",
          "dataPlaneMode",
          "hostingMode",
          "createdAt",
          "updatedAt",
          "etag"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "prj_01HXQ8Z6J9K2",
            "description": "The project's id."
          },
          "name": {
            "type": "string",
            "example": "Client Booking Portal",
            "description": "The app's name, shown to members."
          },
          "locationId": {
            "type": "string",
            "example": "loc_01HXQ8Z6J9K2",
            "description": "The sub-account the project belongs to."
          },
          "companyId": {
            "type": "string",
            "example": "cmp_01HXQ8Z6J9K2",
            "description": "The agency the sub-account belongs to."
          },
          "ownerUserId": {
            "type": "string",
            "example": "usr_01HXQ8Z6J9K2",
            "description": "The user who owns the project."
          },
          "createdByUserId": {
            "type": "string",
            "example": "usr_01HXQ8Z6J9K2",
            "description": "The user who created the project."
          },
          "visibility": {
            "description": "Who in the sub-account can see the project.",
            "type": "string",
            "enum": [
              "private",
              "shared"
            ],
            "title": "ProjectVisibility"
          },
          "slug": {
            "type": "string",
            "example": "client-booking-portal",
            "description": "URL-safe form of the name."
          },
          "status": {
            "description": "Where the project is in its lifecycle.",
            "type": "string",
            "enum": [
              "draft",
              "queued",
              "planning",
              "building",
              "previewing",
              "deploying",
              "deployed",
              "blocked",
              "archived",
              "deleted"
            ],
            "title": "ProjectStatus"
          },
          "publicationStatus": {
            "description": "Stable publication state, independent from the mutable run/build status. `published` means a successful publish activated at least the managed platform hostname; later draft edits do not change it. Legacy records without this field are interpreted as `draft` unless `productionUrl` is present.",
            "type": "string",
            "enum": [
              "draft",
              "published"
            ],
            "title": "ProjectPublicationStatus"
          },
          "stackTemplate": {
            "description": "The kernel the project is built on.",
            "type": "string",
            "enum": [
              "react_native_app_kernel_v1",
              "nuxt_clientportal_app_v1",
              "nuxt_clientportal_vibe_v1",
              "auto"
            ],
            "title": "StackTemplate"
          },
          "templateId": {
            "description": "Starter-template id (e.g. `events-v1`) the project was instantiated from.\nDrives the scaffold overlay byte-copy and, on the first build run, the\n`instantiate` workflow mode (scaffold + finished overlay, no codegen).\nAbsent for projects built from a bare prompt. Project-scoped — set at\ncreation, never accepted on the run submit body.\n",
            "type": "string",
            "example": "events-v1"
          },
          "mobileCreation": {
            "description": "How a mobile project started: from scratch or from the CP Base App.",
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "startingPoint"
                ],
                "properties": {
                  "startingPoint": {
                    "type": "string",
                    "enum": [
                      "scratch"
                    ],
                    "description": "Started from scratch.",
                    "example": "scratch"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "startingPoint",
                  "templateId",
                  "templateVersion"
                ],
                "properties": {
                  "startingPoint": {
                    "type": "string",
                    "enum": [
                      "cp_base"
                    ],
                    "description": "Started from the CP Base App.",
                    "example": "cp_base"
                  },
                  "templateId": {
                    "type": "string",
                    "enum": [
                      "cp-base"
                    ],
                    "description": "The template it started from.",
                    "example": "cp-base"
                  },
                  "templateVersion": {
                    "type": "string",
                    "enum": [
                      "1"
                    ],
                    "description": "The template's version.",
                    "example": "1"
                  }
                }
              }
            ],
            "title": "MobileCreation"
          },
          "appMode": {
            "description": "App branding mode persisted at project creation. `cp_branded` connects the app to the location's Client Portal modules.",
            "type": "string",
            "enum": [
              "standard",
              "cp_branded"
            ],
            "title": "AppMode"
          },
          "productTarget": {
            "description": "What the project builds.",
            "type": "string",
            "enum": [
              "full_stack",
              "mobile",
              "landing_page"
            ],
            "title": "ProductTarget"
          },
          "targetModes": {
            "description": "Immutable surfaces owned by the project. New projects contain exactly one\nvalue derived by the server from `productTarget`: full-stack and landing-page\nprojects resolve to `web`; native Expo/React Native projects resolve to\n`mobile`. Existing combined Client Portal projects may contain both values.\n",
            "type": "array",
            "items": {
              "type": "string",
              "description": "Legacy internal runtime lane. `mobile` means native mobile/Expo, not responsive web.",
              "enum": [
                "web",
                "mobile"
              ],
              "title": "TargetMode"
            },
            "example": [
              "web"
            ]
          },
          "dataPlaneMode": {
            "description": "Where the app's data lives.",
            "type": "string",
            "enum": [
              "managed_mongo"
            ],
            "title": "DataPlaneMode"
          },
          "hostingMode": {
            "description": "Where the app is hosted.",
            "type": "string",
            "enum": [
              "managed",
              "byo_vercel"
            ],
            "title": "HostingMode"
          },
          "apiContractVersion": {
            "type": "string",
            "example": "2026-04-27",
            "description": "The API contract version the project was created under."
          },
          "latestRunId": {
            "type": "string",
            "example": "run_01HXQ9ABCD12",
            "description": "The project's most recent run."
          },
          "latestDeploymentId": {
            "type": "string",
            "example": "dep_01HXQ8Z6J9K2",
            "description": "The project's most recent deployment."
          },
          "previewUrl": {
            "type": "string",
            "format": "uri",
            "description": "Where to preview the latest build.",
            "example": "https://preview.example.com/my-portal"
          },
          "productionUrl": {
            "type": "string",
            "format": "uri",
            "description": "Where the published app is served.",
            "example": "https://my-portal.example.com"
          },
          "thumbnailUrl": {
            "type": "string",
            "format": "uri",
            "description": "Screenshot of the app's home page, taken after its latest successful build. Absent until\na build has produced one; clients show their own placeholder then.\n",
            "example": "https://storage.googleapis.com/ai-builder-public-experiences-staging/project-thumbnails/5f0c2a3e-8d41-4c4b-9a35-0d1e6b7f2c91.jpg"
          },
          "preferredMode": {
            "type": "string",
            "enum": [
              "auto",
              "plan",
              "build"
            ],
            "description": "The user's last-selected run mode for this project. The composer's\n3-way segmented control rehydrates from this value when the\nproject is opened so the user's preference survives reloads.\nUpdated server-side every time a new run is submitted with an\nexplicit `mode` value (or via `PATCH /projects/{projectId}`).\n",
            "example": "auto"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the project was created.",
            "example": "2026-10-01T08:00:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the project last changed.",
            "example": "2026-10-15T09:41:12.000Z"
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the project was archived, if it was.",
            "example": "2026-10-20T12:00:00.000Z"
          },
          "starred": {
            "type": "boolean",
            "description": "Pinned by its owner so it sorts to the top of their project list. Absent means not starred; there is no per-viewer state — a project is starred for the location, like its name.",
            "example": true
          },
          "hasMobileSources": {
            "type": "boolean",
            "readOnly": true,
            "description": "True when this project's current mobile revision carries generated source (`documents.clientportal.mobile.sources` on its app configuration), so its phone preview must be framed from the project's own sandbox rather than the shared stock host. Read from the authenticated location's revision only. Returned by `GET /api/v1/projects/{projectId}`; list, create and update responses omit it, and an absent value means `false`.",
            "example": false
          },
          "etag": {
            "type": "string",
            "example": "W/\"project-12\"",
            "description": "The project's version tag, for conditional updates."
          }
        },
        "title": "Project"
      },
      "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' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "prompt": "Build a mobile and web booking app for a med spa.",
  "name": "Groundbreak",
  "targetModes": [
    "web"
  ],
  "templateId": "events-v1",
  "mobileCreation": {
    "startingPoint": "cp_base",
    "templateId": "cp-base",
    "templateVersion": "1"
  },
  "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "prompt": "Build a mobile and web booking app for a med spa.",
      "name": "Groundbreak",
      "targetModes": [
        "web"
      ],
      "templateId": "events-v1",
      "mobileCreation": {
        "startingPoint": "cp_base",
        "templateId": "cp-base",
        "templateVersion": "1"
      },
      "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ai-builder-api/projects', 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"

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

payload = {
    "prompt": "Build a mobile and web booking app for a med spa.",
    "name": "Groundbreak",
    "targetModes": [
        "web"
    ],
    "templateId": "events-v1",
    "mobileCreation": {
        "startingPoint": "cp_base",
        "templateId": "cp-base",
        "templateVersion": "1"
    },
    "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
}

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',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "prompt": "Build a mobile and web booking app for a med spa.",
  "name": "Groundbreak",
  "targetModes": [
    "web"
  ],
  "templateId": "events-v1",
  "mobileCreation": {
    "startingPoint": "cp_base",
    "templateId": "cp-base",
    "templateVersion": "1"
  },
  "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/ai-builder-api/projects")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"prompt\":\"Build a mobile and web booking app for a med spa.\",\"name\":\"Groundbreak\",\"targetModes\":[\"web\"],\"templateId\":\"events-v1\",\"mobileCreation\":{\"startingPoint\":\"cp_base\",\"templateId\":\"cp-base\",\"templateVersion\":\"1\"},\"clientRefId\":\"3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ai-builder-api/projects"
  payload := strings.NewReader(`{
  "prompt": "Build a mobile and web booking app for a med spa.",
  "name": "Groundbreak",
  "targetModes": [
    "web"
  ],
  "templateId": "events-v1",
  "mobileCreation": {
    "startingPoint": "cp_base",
    "templateId": "cp-base",
    "templateVersion": "1"
  },
  "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
}`)
  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")

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 = '{
  "prompt": "Build a mobile and web booking app for a med spa.",
  "name": "Groundbreak",
  "targetModes": [
    "web"
  ],
  "templateId": "events-v1",
  "mobileCreation": {
    "startingPoint": "cp_base",
    "templateId": "cp-base",
    "templateVersion": "1"
  },
  "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
}'

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

**PowerShell**

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

$body = '{
  "prompt": "Build a mobile and web booking app for a med spa.",
  "name": "Groundbreak",
  "targetModes": [
    "web"
  ],
  "templateId": "events-v1",
  "mobileCreation": {
    "startingPoint": "cp_base",
    "templateId": "cp-base",
    "templateVersion": "1"
  },
  "clientRefId": "3f6c1d2e-8b4a-4f7e-9c1d-2a3b4c5d6e7f"
}'

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