# Purchase number for location

POST https://services.leadconnectorhq.com/phone-system/numbers/location/{locationId}/purchase

Purchase number for location. With `version: v3`, the HTTP 201 body is the standard success envelope (`status`, `data`, `message`, `statusCode`). The v3 purchase fields live under `data`: `number`, `locationId`, `id`, and `underLcAccount` (renamed from under_ghl_account).

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `phonenumbers.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |
| `version` | string | Yes | Send `v3` to use the v3 response contract (AIP). This is the supported version value for these endpoints. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID as string |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/phone-system/numbers/location/{locationId}/purchase": {
      "post": {
        "summary": "Purchase number for location",
        "operationId": "purchaseNumberForLocation",
        "description": "Purchase number for location. With `version: v3`, the HTTP 201 body is the standard success envelope (`status`, `data`, `message`, `statusCode`). The v3 purchase fields live under `data`: `number`, `locationId`, `id`, and `underLcAccount` (renamed from under_ghl_account).",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "API Version",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location ID as string",
            "schema": {
              "type": "string",
              "example": "tDtDnQdgm2LXpyiqYvZ6"
            }
          },
          {
            "name": "version",
            "in": "header",
            "description": "Send `v3` to use the v3 response contract (AIP). This is the supported version value for these endpoints.",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchasePhoneNumberBodyDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope; v3 purchase details are in `data` (slim shape: number, locationId, id, underLcAccount).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseNumberForLocationV3Http201ResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "phonenumbers.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "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",
        "name": "Authorization",
        "in": "header",
        "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",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "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",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "PurchasePhoneNumberBodyDto": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "description": "phoneNumber to purchase",
            "example": "830236932"
          },
          "addressSid": {
            "type": "string",
            "description": "addressSid twilio address id",
            "example": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
          },
          "bundleSid": {
            "type": "string",
            "description": "bundleSid twilio bundle id",
            "example": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
          },
          "countryCode": {
            "type": "string",
            "description": "country for which the phone numbers are being requested",
            "example": "US"
          },
          "numberType": {
            "type": "object",
            "description": "type of phone number to be purchased",
            "example": "local"
          },
          "paymentIntentId": {
            "type": "string",
            "description": "stripe payment intent id",
            "example": "pi_3Oxxxxxxxxxxxxxxxxxxxx"
          },
          "stripeAccountId": {
            "type": "string",
            "description": "stripe account id",
            "example": "acct_1Oxxxxxxxxxxxxxxxx"
          },
          "paymentMethodId": {
            "type": "string",
            "description": "stripe registered payment method id",
            "example": "pm_1Oxxxxxxxxxxxxxxxx"
          },
          "locality": {
            "type": "string",
            "description": "locality of the user in which number is being purchased",
            "example": "Austin"
          },
          "region": {
            "type": "string",
            "description": "region of the user in which number is being purchased",
            "example": "TX"
          },
          "fingerprintId": {
            "type": "string",
            "description": "fingerprintId is request id which is unique for every purchase number request",
            "example": "purchase-req-abc-123"
          },
          "skipLocationKYC": {
            "type": "boolean",
            "description": "Skip location-level KYC verification if agency-level compliance has already been verified",
            "example": false
          }
        },
        "required": [
          "phoneNumber",
          "addressSid",
          "bundleSid",
          "countryCode",
          "numberType",
          "paymentIntentId",
          "stripeAccountId",
          "paymentMethodId",
          "locality",
          "region",
          "fingerprintId",
          "skipLocationKYC"
        ],
        "title": "PurchasePhoneNumberBodyDto"
      },
      "PurchaseNumberForLocationV3Http201ResponseDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "Outcome indicator from the shared success helper.",
            "example": "success",
            "enum": [
              "success"
            ]
          },
          "data": {
            "description": "V3 purchase payload: purchased number, location, Twilio account id, and underLcAccount.",
            "example": {
              "number": "+17745678902",
              "locationId": "tDtDnQdgm2LXpyiqYvZ6",
              "id": "twilio-account-123",
              "underLcAccount": false
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "number": {
                    "type": "string",
                    "description": "E.164 phone number that was purchased (from the request body)",
                    "example": "+17745678902"
                  },
                  "locationId": {
                    "type": "string",
                    "description": "Location that owns the Twilio / numbers account",
                    "example": "tDtDnQdgm2LXpyiqYvZ6"
                  },
                  "id": {
                    "type": "string",
                    "description": "Twilio account document identifier",
                    "example": "twilio-account-123"
                  },
                  "underLcAccount": {
                    "type": "boolean",
                    "description": "Whether the account is managed under LC. Renamed from under_ghl_account in the legacy document.",
                    "example": false
                  }
                },
                "required": [
                  "number",
                  "locationId",
                  "id",
                  "underLcAccount"
                ],
                "title": "PurchaseNumberForLocationV3ResponseDto"
              }
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable success message.",
            "example": "Number purchase successful"
          },
          "statusCode": {
            "type": "number",
            "description": "HTTP status echoed in the response body.",
            "example": 201
          }
        },
        "required": [
          "status",
          "data",
          "message",
          "statusCode"
        ],
        "title": "PurchaseNumberForLocationV3Http201ResponseDto"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/phone-system/numbers/location/<locationId>/purchase' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "phoneNumber": "830236932",
  "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "countryCode": "US",
  "numberType": "local",
  "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
  "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
  "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
  "locality": "Austin",
  "region": "TX",
  "fingerprintId": "purchase-req-abc-123",
  "skipLocationKYC": false
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "phoneNumber": "830236932",
      "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "countryCode": "US",
      "numberType": "local",
      "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
      "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
      "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
      "locality": "Austin",
      "region": "TX",
      "fingerprintId": "purchase-req-abc-123",
      "skipLocationKYC": false
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/phone-system/numbers/location/<locationId>/purchase', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/phone-system/numbers/location/{locationId}/purchase"

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

payload = {
    "phoneNumber": "830236932",
    "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "countryCode": "US",
    "numberType": "local",
    "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
    "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
    "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
    "locality": "Austin",
    "region": "TX",
    "fingerprintId": "purchase-req-abc-123",
    "skipLocationKYC": false
}

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/phone-system/numbers/location/<locationId>/purchase',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "phoneNumber": "830236932",
  "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "countryCode": "US",
  "numberType": "local",
  "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
  "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
  "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
  "locality": "Austin",
  "region": "TX",
  "fingerprintId": "purchase-req-abc-123",
  "skipLocationKYC": false
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/phone-system/numbers/location/<locationId>/purchase")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"phoneNumber\":\"830236932\",\"addressSid\":\"ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"bundleSid\":\"BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\"countryCode\":\"US\",\"numberType\":\"local\",\"paymentIntentId\":\"pi_3Oxxxxxxxxxxxxxxxxxxxx\",\"stripeAccountId\":\"acct_1Oxxxxxxxxxxxxxxxx\",\"paymentMethodId\":\"pm_1Oxxxxxxxxxxxxxxxx\",\"locality\":\"Austin\",\"region\":\"TX\",\"fingerprintId\":\"purchase-req-abc-123\",\"skipLocationKYC\":false}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/phone-system/numbers/location/<locationId>/purchase"
  payload := strings.NewReader(`{
  "phoneNumber": "830236932",
  "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "countryCode": "US",
  "numberType": "local",
  "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
  "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
  "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
  "locality": "Austin",
  "region": "TX",
  "fingerprintId": "purchase-req-abc-123",
  "skipLocationKYC": false
}`)
  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/phone-system/numbers/location/<locationId>/purchase")

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 = '{
  "phoneNumber": "830236932",
  "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "countryCode": "US",
  "numberType": "local",
  "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
  "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
  "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
  "locality": "Austin",
  "region": "TX",
  "fingerprintId": "purchase-req-abc-123",
  "skipLocationKYC": false
}'

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

**PowerShell**

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

$body = '{
  "phoneNumber": "830236932",
  "addressSid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "bundleSid": "BUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "countryCode": "US",
  "numberType": "local",
  "paymentIntentId": "pi_3Oxxxxxxxxxxxxxxxxxxxx",
  "stripeAccountId": "acct_1Oxxxxxxxxxxxxxxxx",
  "paymentMethodId": "pm_1Oxxxxxxxxxxxxxxxx",
  "locality": "Austin",
  "region": "TX",
  "fingerprintId": "purchase-req-abc-123",
  "skipLocationKYC": false
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/phone-system/numbers/location/<locationId>/purchase' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
