# Stack-agnostic materialization hints for desktop/CLI handoff.

GET https://services.leadconnectorhq.com/ai-builder-api/cli/projects/{projectId}/context

Returns what an agent reads before editing an app's code: its stack, the guide to start from, and the kernel bundle. Opens the app's sandbox.

## 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 | Project identifier. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ai-builder-api/cli/projects/{projectId}/context": {
      "get": {
        "summary": "Stack-agnostic materialization hints for desktop/CLI handoff.",
        "operationId": "stackagnosticMaterializationHintsForDesktopcliHandoff",
        "description": "Returns what an agent reads before editing an app's code: its stack, the guide to start from, and the kernel bundle. Opens the app's sandbox.",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "description": "Project identifier.",
            "schema": {
              "type": "string",
              "pattern": "^prj_[A-Za-z0-9]+$",
              "example": "prj_01HXQ8Z6J9K2"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "The API version.",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved stack manifest and kernel bundle hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CliProjectContext"
                }
              }
            }
          }
        },
        "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": {
      "CliProjectContext": {
        "type": "object",
        "required": [
          "projectId",
          "productTarget",
          "stackTemplate",
          "stackManifestId",
          "kernelBundleHint"
        ],
        "properties": {
          "projectId": {
            "type": "string",
            "description": "The project.",
            "example": "prj_5f0c2a3e"
          },
          "productTarget": {
            "type": "string",
            "description": "What the project builds: `full_stack` (a web portal), `mobile` or `landing_page`.",
            "example": "full_stack"
          },
          "stackTemplate": {
            "type": "string",
            "description": "The kernel the project is built on.",
            "example": "nuxt_clientportal_app_v1"
          },
          "templateId": {
            "type": "string",
            "description": "The starter template the project was created from, when it had one.",
            "example": "learning-community"
          },
          "stackManifestId": {
            "type": "string",
            "description": "The stack manifest the project's sandbox follows.",
            "example": "nuxt_clientportal_app_v1"
          },
          "kernelBundleHint": {
            "type": "string",
            "description": "File name of this stack's kernel bundle.",
            "example": "kernel-nuxt_clientportal_app_v1.tgz"
          }
        },
        "title": "CliProjectContext"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/ai-builder-api/cli/projects/<projectId>/context' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

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

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

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ai-builder-api/cli/projects/<projectId>/context',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/ai-builder-api/cli/projects/<projectId>/context")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ai-builder-api/cli/projects/<projectId>/context"
  req, _ := http.NewRequest("GET", url, nil)
  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/cli/projects/<projectId>/context")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

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

**PowerShell**

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

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ai-builder-api/cli/projects/<projectId>/context' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
