# Set up ad account billing (monthly invoicing)

Sets up ad account billing (monthly invoicing). Works with Google Ads.

```http
POST https://api.pozy.ai/v1/ads/accounts/billing
```

- Area: Ads / Ad Accounts
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `accountId`, string, required: Matches `^[a-fA-F0-9]{24}$`
- `adAccountId`, string, required: Matches `^[0-9]+$`
- `paymentsAccountId`, string, required: Matches `^\d{4}-\d{4}-\d{4}-\d{4}$`
- `spendingLimit`, number
- `budgetName`, string: Default `Pozy account budget`. 1 to 255 characters
- `purchaseOrderNumber`, string: 1 to 64 characters
- `validateOnly`, boolean: Default `false`

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/ads/accounts/billing" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "adAccountId": "666219aad7bab67ace411e4f",
  "paymentsAccountId": "69ee150082c8d470630b2076"
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/accounts/billing", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    adAccountId: "666219aad7bab67ace411e4f",
    paymentsAccountId: "69ee150082c8d470630b2076"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/ads/accounts/billing",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "adAccountId": "666219aad7bab67ace411e4f",
        "paymentsAccountId": "69ee150082c8d470630b2076",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `customerId`, string
- `paymentsAccountId`, string
- `paymentsAccountName`, string: Can be null
- `billingSetupId`, string: Can be null
- `reusedBillingSetup`, boolean
- `accountBudgetProposalId`, string: Can be null
- `validateOnly`, boolean

```json
{
  "customerId": "691909ff82eb5ed7c816716d",
  "paymentsAccountId": "69ee150082c8d470630b2076",
  "paymentsAccountName": "Acme",
  "billingSetupId": "62c3eba932baabf6447d4843",
  "reusedBillingSetup": true,
  "accountBudgetProposalId": "648f921ff3ba1883e4c11173",
  "validateOnly": true
}
```
