# Build a signed Android APK of a published phone app revision.

POST https://services.leadconnectorhq.com/ai-builder-api/projects/{projectId}/app-config/apk-builds

Idempotent per Idempotency-Key. For a project whose current revision carries generated screens, the build is instead identified by the revision and the generated sources it carries (sha256(locationId:projectId:revision:sourcesSha)): repeating the request for the same revision and sources returns the same build whatever the key, and a failed one is queued again. Such a build is made from the React Native kernel commit the screens were generated against, and must be requested for the current revision. Generated screens reach members only through a new APK; they are never delivered over the air. At most one build may be active per project; sibling projects in the same location may build in parallel. Deleting a project while its build is still queued or building fails that build. A project compiles one signed APK for now: after a successful build the binary is final. A project without generated screens keeps reaching installed apps by publishing a revision; a project with generated screens cannot build another APK yet. Failed builds do not consume the allowance.

## 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 | Yes | A key you choose for this build. Retrying with the same key returns the same build. |
| `Version` | string | Yes | The API version. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectId` | string | Yes | The app's id. |

## 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}/app-config/apk-builds": {
      "post": {
        "summary": "Build a signed Android APK of a published phone app revision.",
        "operationId": "buildASignedAndroidApkOfAPublishedPhoneAppRevision",
        "description": "Idempotent per Idempotency-Key. For a project whose current revision carries generated screens, the build is instead identified by the revision and the generated sources it carries (sha256(locationId:projectId:revision:sourcesSha)): repeating the request for the same revision and sources returns the same build whatever the key, and a failed one is queued again. Such a build is made from the React Native kernel commit the screens were generated against, and must be requested for the current revision. Generated screens reach members only through a new APK; they are never delivered over the air. At most one build may be active per project; sibling projects in the same location may build in parallel. Deleting a project while its build is still queued or building fails that build. A project compiles one signed APK for now: after a successful build the binary is final. A project without generated screens keeps reaching installed apps by publishing a revision; a project with generated screens cannot build another APK yet. Failed builds do not consume the allowance.",
        "parameters": [
          {
            "in": "path",
            "name": "projectId",
            "required": true,
            "description": "The app's id.",
            "example": "prj_a7ca4adc-be67-40ff-ae79-4f5acf56ac67",
            "schema": {
              "type": "string",
              "pattern": "^prj_[A-Za-z0-9_-]+$"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "description": "A key you choose for this build. Retrying with the same key returns the same build.",
            "example": "apk-prj_a7ca4adc-4",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "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/RequestMobileApkBuild"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "APK build queued or the existing idempotent build returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MobileApkBuild"
                }
              }
            }
          },
          "409": {
            "description": "Revision is not published (or, for generated screens, is not the current revision), project has no mobile target, or the project already has its one signed APK (`mobile_apk_build_limit_reached`)."
          }
        },
        "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": {
      "RequestMobileApkBuild": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "revision"
        ],
        "properties": {
          "revision": {
            "type": "integer",
            "minimum": 1,
            "description": "The published revision to build. An app with generated screens builds its current revision.",
            "example": 4
          }
        },
        "title": "RequestMobileApkBuild"
      },
      "MobileApkBuild": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "projectId",
          "revision",
          "appName",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^apk_[a-f0-9]{32}$",
            "description": "The build's id.",
            "example": "apk_3f1c0b9e2d4a6f8e0c1b3d5f7a9e2c4b"
          },
          "projectId": {
            "type": "string",
            "pattern": "^prj_[A-Za-z0-9_-]+$",
            "description": "The app's id.",
            "example": "prj_a7ca4adc-be67-40ff-ae79-4f5acf56ac67"
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "description": "The revision the APK is built from.",
            "example": 4
          },
          "appName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "The app's name on the device.",
            "example": "Run Club"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "building",
              "finished",
              "failed"
            ],
            "description": "Where the build is. Read it again until `finished` or `failed`.",
            "example": "building"
          },
          "artifactUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "description": "Short-lived signed GCS URL for the archived APK. Expo artifact URLs are never exposed.",
            "example": "https://storage.googleapis.com/apk-artifacts/prj_a7ca4adc/apk_3f1c0b9e.apk?X-Goog-Signature=abc"
          },
          "error": {
            "type": "string",
            "description": "Creator-facing summary of why the build failed, safe to render as-is. Raw EAS, npm, or Gradle console output is never returned here; it stays in the build worker log.",
            "example": "The Android build failed. Try again, or contact support if it keeps failing."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the build was requested.",
            "example": "2026-10-23T11:30:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the build last changed state.",
            "example": "2026-10-23T11:34:00.000Z"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the build finished or failed.",
            "example": "2026-10-23T11:42:00.000Z"
          }
        },
        "title": "MobileApkBuild"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/app-config/apk-builds' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "revision": 4
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "revision": 4
  })
};

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

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

payload = {
    "revision": 4
}

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>/app-config/apk-builds',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "revision": 4
}',
]);

$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>/app-config/apk-builds")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"revision\":4}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/ai-builder-api/projects/<projectId>/app-config/apk-builds"
  payload := strings.NewReader(`{
  "revision": 4
}`)
  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>/app-config/apk-builds")

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 = '{
  "revision": 4
}'

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

**PowerShell**

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

$body = '{
  "revision": 4
}'

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