# Return a phone app to an earlier revision.

POST https://services.leadconnectorhq.com/ai-builder-api/projects/{projectId}/app-config/revisions/{revision}/restore

Saves a copy of the earlier revision, screens included, as the newest one. Members get it once you publish it with `POST .../app-config/publish`.

## 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 restore. Retrying with the same key returns the same restore instead of a second one. |
| `Version` | string | Yes | The API version. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `projectId` | string | Yes | The app's id. |
| `revision` | integer | Yes | The earlier revision to return to, from the app's revisions. |

## 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/revisions/{revision}/restore": {
      "post": {
        "summary": "Return a phone app to an earlier revision.",
        "operationId": "returnAPhoneAppToAnEarlierRevision",
        "description": "Saves a copy of the earlier revision, screens included, as the newest one. Members get it once you publish it with `POST .../app-config/publish`.",
        "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": "path",
            "name": "revision",
            "required": true,
            "description": "The earlier revision to return to, from the app's revisions.",
            "example": 2,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "description": "A key you choose for this restore. Retrying with the same key returns the same restore instead of a second one.",
            "example": "restore-prj_a7ca4adc-2",
            "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/RestoreMobileCustomizationRevisionRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Restore revision queued for validation and preview publication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppCustomizationRecord"
                }
              }
            }
          },
          "404": {
            "description": "Revision is not owned by this project and authenticated location."
          },
          "409": {
            "description": "Revision is stale or incompatible with the active Mobile Experience Kits."
          }
        },
        "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": {
      "RestoreMobileCustomizationRevisionRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "baseRevision"
        ],
        "properties": {
          "baseRevision": {
            "type": "integer",
            "minimum": 1,
            "description": "The newest revision the caller saw (`revision` in the app's configuration). A save made since then refuses the restore instead of being overwritten.",
            "example": 4
          }
        },
        "title": "RestoreMobileCustomizationRevisionRequest"
      },
      "AppCustomizationRecord": {
        "type": "object",
        "required": [
          "projectId",
          "revision",
          "appliedRevision",
          "publishedRevision",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "projectId": {
            "type": "string",
            "pattern": "^prj_[A-Za-z0-9_-]+$",
            "description": "Stable owner project for this location's shared ClientPortal Experience. It may differ from the web or mobile project in the current route.",
            "example": "prj_a7ca4adc-be67-40ff-ae79-4f5acf56ac67"
          },
          "revision": {
            "type": "integer",
            "minimum": 0,
            "description": "The newest saved revision. A finished run or a restore saves a new one.",
            "example": 4
          },
          "appliedRevision": {
            "type": "integer",
            "minimum": 0,
            "description": "The newest revision that finished applying. Publish a revision once it equals `revision` and `status` is `ready`.",
            "example": 4
          },
          "publishedRevision": {
            "type": "integer",
            "minimum": 0,
            "description": "The revision members get. 0 until the first publish.",
            "example": 3
          },
          "status": {
            "description": "Where the newest revision is: `ready` once it has applied and can be published, `failed` when it could not apply.",
            "type": "string",
            "enum": [
              "idle",
              "queued",
              "applying",
              "ready",
              "failed"
            ],
            "title": "AppCustomizationStatus"
          },
          "previewUrl": {
            "type": "string",
            "format": "uri",
            "description": "Where the latest applied revision can be previewed, when the app has a preview.",
            "example": "https://prj-a7ca4adc-be67-40ff-ae79-4f5acf56ac67-sbx.staging.clientclub.net"
          },
          "lastError": {
            "type": "string",
            "description": "Why the latest revision failed to apply, when `status` is `failed`.",
            "example": "The Schedule screen does not match the route contract."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the app's configuration was first saved.",
            "example": "2026-10-23T10:41:44.873Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the latest revision was saved or changed state.",
            "example": "2026-10-23T11:24:45.263Z"
          }
        },
        "title": "AppCustomizationRecord"
      }
    }
  }
}
```

## Code Examples

**cURL**

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

**Node.js**

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

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

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

payload = {
    "baseRevision": 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/revisions/<revision>/restore',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "baseRevision": 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/revisions/<revision>/restore")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"baseRevision\":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/revisions/<revision>/restore"
  payload := strings.NewReader(`{
  "baseRevision": 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/revisions/<revision>/restore")

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

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

**PowerShell**

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

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

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