# Create custom conversion

Creates a custom conversion. Works with Meta Ads.

```http
POST https://api.pozy.ai/v1/accounts/{accountId}/custom-conversions
```

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

## Path parameters

- `accountId` (string, required)

## Request body

Content type: `application/json`

- `adAccountId`, string, required
- `name`, string, required: Up to 255 characters
- `pixelId`, string, required
- `customEventType`, string, required
- `rule`, object, required

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/accounts/696e0b682d0a31188e7a2ba9/custom-conversions" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "adAccountId": "666219aad7bab67ace411e4f",
  "name": "Acme",
  "pixelId": "6c80a7fd978ec8f8bd885bce",
  "customEventType": "string",
  "rule": {}
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/accounts/696e0b682d0a31188e7a2ba9/custom-conversions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    adAccountId: "666219aad7bab67ace411e4f",
    name: "Acme",
    pixelId: "6c80a7fd978ec8f8bd885bce",
    customEventType: "string",
    rule: {}
  }),
});
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/accounts/696e0b682d0a31188e7a2ba9/custom-conversions",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "adAccountId": "666219aad7bab67ace411e4f",
        "name": "Acme",
        "pixelId": "6c80a7fd978ec8f8bd885bce",
        "customEventType": "string",
        "rule": {},
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `adAccountId`, string
- `customConversionId`, string
- `reused`, boolean
- `customConversion`, object
  - `id`, string
  - `name`, string: Can be null
  - `rule`, object: Can be null
  - `customEventType`, string: Can be null
  - `pixelId`, string: Can be null
  - `isArchived`, boolean
  - `defaultConversionValue`, number: Can be null

```json
{
  "adAccountId": "666219aad7bab67ace411e4f",
  "customConversionId": "60a94bb7640210dda1bfd0ad",
  "reused": true,
  "customConversion": {
    "id": "6bfebd43ddc270f6d2c56fc5",
    "name": "Acme",
    "rule": {},
    "customEventType": "string",
    "pixelId": "6c80a7fd978ec8f8bd885bce",
    "isArchived": true,
    "defaultConversionValue": 12.5
  }
}
```
