# Update ad account

> Rename an ad account or set its spending limit.

Canonical: <https://www.tryadeli.com/docs/api/ads/update-ad-account>

`PATCH https://app.tryadeli.com/api/v1/ads/accounts/{adAccountId}`

Authorization: `Bearer <API key>` — see [Authentication](https://www.tryadeli.com/docs/authentication)

Renames an account or sets its spending limit — Meta's hard stop, counted from
the moment it is set: once the account has spent that much, all its ads stop
delivering. Returns the same shape as the [details endpoint](https://www.tryadeli.com/docs/api/ads/get-ad-account).

**Path parameters**

| Name          | Type     | Required | Description                                     |
| ------------- | -------- | -------- | ----------------------------------------------- |
| `adAccountId` | `string` | Yes      | An ad account id, in Meta's act\_<digits> form. |

**Body**

| Name       | Type             | Required | Description                                   |
| ---------- | ---------------- | -------- | --------------------------------------------- |
| `name`     | `string`         |          | Up to 100 characters.                         |
| `spendCap` | `number \| null` |          | Whole currency units; null removes the limit. |

Payment methods and closing an account have no API; do those in Meta.

## Request examples

**cURL**

```bash
curl --fail-with-body -X PATCH "https://app.tryadeli.com/api/v1/ads/accounts/act_1234567890?accountId=00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer $ADELI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "spendCap": 500
}'
```

**JavaScript**

```javascript
const response = await fetch("https://app.tryadeli.com/api/v1/ads/accounts/act_1234567890?accountId=00000000-0000-0000-0000-000000000000", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.ADELI_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    spendCap: 500,
  }),
});
console.log(await response.json());
```

**Python**

```python
import os

import requests

response = requests.patch(
    "https://app.tryadeli.com/api/v1/ads/accounts/act_1234567890",
    headers={"Authorization": f"Bearer {os.environ['ADELI_API_KEY']}"},
    params={
        "accountId": "00000000-0000-0000-0000-000000000000",
    },
    json={
        "spendCap": 500,
    },
)
print(response.json())
```

## Responses

### 200

```json
{
  "platform": "facebook",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "profileId": "00000000-0000-4000-8000-000000000002",
  "adAccount": {
    "id": "act_1234567890",
    "accountId": "1234567890",
    "name": "Client A — Ads",
    "currency": "USD",
    "timezoneName": "America/New_York",
    "accountStatus": 1,
    "minDailyBudget": 100,
    "businessId": "1122334455",
    "businessName": "Client A"
  },
  "details": {
    "id": "act_1234567890",
    "currency": "USD",
    "accountStatus": 1,
    "disableReason": 0,
    "spendCap": 500,
    "amountSpent": 182.4,
    "hasPaymentMethod": true
  }
}
```

### 400

```json
{
  "error": {
    "code": "invalid_request",
    "message": "Invalid ad account update",
    "details": [
      { "code": "custom", "path": [], "message": "Provide a name or a spendCap" }
    ]
  }
}
```
