# Allow Attach Rebilling

POST https://services.leadconnectorhq.com/saas/allow-attach-rebilling/{locationId}

Marks a SaaS sub-account as awaiting rebilling attach and optionally stores the rebilling configuration that should be applied when the rebilling config is created. Sets payment_pending on the sub-account. Only allowed when the sub-account is in setup_pending state.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Agency token: OAuth access token or Private Integration Token.** Scopes: `saas/company.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID (Sub-account) to allow attach rebilling for |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/saas/allow-attach-rebilling/{locationId}": {
      "post": {
        "summary": "Allow Attach Rebilling",
        "operationId": "allowAttachRebilling",
        "description": "Marks a SaaS sub-account as awaiting rebilling attach and optionally stores the rebilling configuration that should be applied when the rebilling config is created. Sets payment_pending on the sub-account. Only allowed when the sub-account is in setup_pending state.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location ID (Sub-account) to allow attach rebilling for",
            "schema": {
              "example": "AUKAtFVo0lWezBsBQ3FE",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AllowAttachRebillingDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Allow attach rebilling completed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllowAttachRebillingResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceNotFoundDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity (e.g. sub-account already in saas mode activated, or not in setup_pending state)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Agency-Access": [
              "saas/company.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "AllowAttachRebillingDto": {
        "type": "object",
        "properties": {
          "companyId": {
            "type": "string",
            "description": "Company ID owning the location",
            "example": "5DP4iH6HLkQsiKESj6rh"
          },
          "attachedRebillingConfig": {
            "type": "object",
            "description": "Map of rebilling product code to its config. When provided, this gets stored on the sub-account so it can be applied when the rebilling config is created. Omit to only mark the sub-account as awaiting rebilling attach without any pre-configured products. Possible product keys: `contentAI`, `workflow_premium_actions`, `workflow_ai`, `conversationAI`, `whatsApp`, `reviewsAI`, `EmailVerification`, `funnelAI`, `domainPurchase`, `Phone`, `Email`, `agentStudio`, `askai`, `aiStudio`.",
            "example": {
              "EmailVerification": {
                "enabled": true,
                "markup": 4,
                "price": 0.0025
              },
              "Phone": {
                "enabled": true,
                "markup": 3
              },
              "agentStudio": {
                "enabled": true,
                "markup": 8,
                "price": 0.25
              },
              "contentAI": {
                "enabled": true,
                "markup": 5,
                "price": 0.09
              },
              "domainPurchase": {
                "enabled": true,
                "markup": 3
              }
            },
            "additionalProperties": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "description": "Enable rebilling for this product",
                  "example": true
                },
                "markup": {
                  "type": "number",
                  "description": "Markup multiplier applied on top of the base price, from 1 (1x) to 10 (10x). For domainPurchase the maximum is 3 (3x). Converted internally to a percentage markup (e.g. 2 -> 100%, 3 -> 200%).",
                  "example": 3
                },
                "price": {
                  "type": "number",
                  "description": "Base price per unit (only applicable for usage based products like EmailVerification, agentStudio, contentAI)",
                  "example": 0.0025
                }
              },
              "required": [
                "enabled",
                "markup"
              ],
              "title": "AttachedRebillingProductConfigDto"
            }
          }
        },
        "required": [
          "companyId"
        ],
        "title": "AllowAttachRebillingDto"
      },
      "AllowAttachRebillingResponseDto": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Indicates if the allow attach rebilling operation succeeded",
            "example": true
          },
          "locationId": {
            "type": "string",
            "description": "Location ID the rebilling config was attached to",
            "example": "AUKAtFVo0lWezBsBQ3FE"
          },
          "attachedRebillingConfig": {
            "type": "object",
            "description": "Stored rebilling configuration on the location. Markup is the internal percentage value converted from the request multiplier (e.g. 4 -> 300%, 3 -> 200%).",
            "example": {
              "EmailVerification": {
                "enabled": true,
                "markup": 300,
                "price": 0.0025
              },
              "Phone": {
                "enabled": true,
                "markup": 200
              }
            },
            "additionalProperties": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "description": "Enable rebilling for this product",
                  "example": true
                },
                "markup": {
                  "type": "number",
                  "description": "Markup multiplier applied on top of the base price, from 1 (1x) to 10 (10x). For domainPurchase the maximum is 3 (3x). Converted internally to a percentage markup (e.g. 2 -> 100%, 3 -> 200%).",
                  "example": 3
                },
                "price": {
                  "type": "number",
                  "description": "Base price per unit (only applicable for usage based products like EmailVerification, agentStudio, contentAI)",
                  "example": 0.0025
                }
              },
              "required": [
                "enabled",
                "markup"
              ],
              "title": "AttachedRebillingProductConfigDto"
            }
          }
        },
        "required": [
          "success",
          "locationId",
          "attachedRebillingConfig"
        ],
        "title": "AllowAttachRebillingResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "ResourceNotFoundDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 404,
            "description": "Status code"
          },
          "message": {
            "type": "string",
            "example": [
              "Contact not found",
              "User not found",
              "Group not found",
              "Channel not found"
            ],
            "description": "Error message"
          }
        },
        "title": "ResourceNotFoundDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 500,
            "description": "Status code"
          },
          "message": {
            "type": "string",
            "example": "Internal Server Error",
            "description": "Error message"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/saas/allow-attach-rebilling/<locationId>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "companyId": "5DP4iH6HLkQsiKESj6rh",
  "attachedRebillingConfig": {
    "EmailVerification": {
      "enabled": true,
      "markup": 4,
      "price": 0.0025
    },
    "Phone": {
      "enabled": true,
      "markup": 3
    },
    "agentStudio": {
      "enabled": true,
      "markup": 8,
      "price": 0.25
    },
    "contentAI": {
      "enabled": true,
      "markup": 5,
      "price": 0.09
    },
    "domainPurchase": {
      "enabled": true,
      "markup": 3
    }
  }
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "companyId": "5DP4iH6HLkQsiKESj6rh",
      "attachedRebillingConfig": {
        "EmailVerification": {
          "enabled": true,
          "markup": 4,
          "price": 0.0025
        },
        "Phone": {
          "enabled": true,
          "markup": 3
        },
        "agentStudio": {
          "enabled": true,
          "markup": 8,
          "price": 0.25
        },
        "contentAI": {
          "enabled": true,
          "markup": 5,
          "price": 0.09
        },
        "domainPurchase": {
          "enabled": true,
          "markup": 3
        }
      }
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/saas/allow-attach-rebilling/<locationId>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/saas/allow-attach-rebilling/{locationId}"

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

payload = {
    "companyId": "5DP4iH6HLkQsiKESj6rh",
    "attachedRebillingConfig": {
        "EmailVerification": {
            "enabled": true,
            "markup": 4,
            "price": 0.0025
        },
        "Phone": {
            "enabled": true,
            "markup": 3
        },
        "agentStudio": {
            "enabled": true,
            "markup": 8,
            "price": 0.25
        },
        "contentAI": {
            "enabled": true,
            "markup": 5,
            "price": 0.09
        },
        "domainPurchase": {
            "enabled": true,
            "markup": 3
        }
    }
}

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/saas/allow-attach-rebilling/<locationId>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "companyId": "5DP4iH6HLkQsiKESj6rh",
  "attachedRebillingConfig": {
    "EmailVerification": {
      "enabled": true,
      "markup": 4,
      "price": 0.0025
    },
    "Phone": {
      "enabled": true,
      "markup": 3
    },
    "agentStudio": {
      "enabled": true,
      "markup": 8,
      "price": 0.25
    },
    "contentAI": {
      "enabled": true,
      "markup": 5,
      "price": 0.09
    },
    "domainPurchase": {
      "enabled": true,
      "markup": 3
    }
  }
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/saas/allow-attach-rebilling/<locationId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"companyId\":\"5DP4iH6HLkQsiKESj6rh\",\"attachedRebillingConfig\":{\"EmailVerification\":{\"enabled\":true,\"markup\":4,\"price\":0.0025},\"Phone\":{\"enabled\":true,\"markup\":3},\"agentStudio\":{\"enabled\":true,\"markup\":8,\"price\":0.25},\"contentAI\":{\"enabled\":true,\"markup\":5,\"price\":0.09},\"domainPurchase\":{\"enabled\":true,\"markup\":3}}}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/saas/allow-attach-rebilling/<locationId>"
  payload := strings.NewReader(`{
  "companyId": "5DP4iH6HLkQsiKESj6rh",
  "attachedRebillingConfig": {
    "EmailVerification": {
      "enabled": true,
      "markup": 4,
      "price": 0.0025
    },
    "Phone": {
      "enabled": true,
      "markup": 3
    },
    "agentStudio": {
      "enabled": true,
      "markup": 8,
      "price": 0.25
    },
    "contentAI": {
      "enabled": true,
      "markup": 5,
      "price": 0.09
    },
    "domainPurchase": {
      "enabled": true,
      "markup": 3
    }
  }
}`)
  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/saas/allow-attach-rebilling/<locationId>")

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 = '{
  "companyId": "5DP4iH6HLkQsiKESj6rh",
  "attachedRebillingConfig": {
    "EmailVerification": {
      "enabled": true,
      "markup": 4,
      "price": 0.0025
    },
    "Phone": {
      "enabled": true,
      "markup": 3
    },
    "agentStudio": {
      "enabled": true,
      "markup": 8,
      "price": 0.25
    },
    "contentAI": {
      "enabled": true,
      "markup": 5,
      "price": 0.09
    },
    "domainPurchase": {
      "enabled": true,
      "markup": 3
    }
  }
}'

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

**PowerShell**

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

$body = '{
  "companyId": "5DP4iH6HLkQsiKESj6rh",
  "attachedRebillingConfig": {
    "EmailVerification": {
      "enabled": true,
      "markup": 4,
      "price": 0.0025
    },
    "Phone": {
      "enabled": true,
      "markup": 3
    },
    "agentStudio": {
      "enabled": true,
      "markup": 8,
      "price": 0.25
    },
    "contentAI": {
      "enabled": true,
      "markup": 5,
      "price": 0.09
    },
    "domainPurchase": {
      "enabled": true,
      "markup": 3
    }
  }
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/saas/allow-attach-rebilling/<locationId>' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
