# Send conversion events

Sends conversion events.

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

- Area: Ads / Conversions
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `accountId`, string, required
- `destinationId`, string, required
- `events`, array of object, required: At least 1 item
  - `eventName`, string, required
  - `eventTime`, integer, required
  - `eventId`, string, required
  - `value`, number
  - `currency`, string
  - `user`, object, required
    - `email`, string
    - `phone`, string
    - `firstName`, string
    - `lastName`, string
    - `externalId`, string
    - `ipAddress`, string
    - `userAgent`, string
    - `country`, string
    - `city`, string
    - `state`, string
    - `zip`, string
    - `dob`, string
    - `gender`, string
    - `leadId`, string
    - `clickIds`, object
      - `fbc`, string
      - `fbp`, string
      - `gclid`, string
      - `gbraid`, string
      - `wbraid`, string
      - `li_fat_id`, string
      - `epik`, string
      - `rdt_cid`, string
      - `rdt_uuid`, string
  - `items`, array of object
    - `id`, string
    - `name`, string
    - `price`, number
    - `quantity`, integer
    - `category`, string
  - `sourceUrl`, string (URL)
  - `actionSource`, string: One of `web`, `app`, `offline`, `crm`, `phone_call`, `system_generated`, `business_messaging`
  - `messaging`, object
    - `channel`, string, required: One of `whatsapp`, `messenger`, `instagram_direct`
    - `wabaId`, string
    - `ctwaClid`, string
    - `pageId`, string
    - `instagramBusinessAccountId`, string
    - `pageScopedUserId`, string
    - `instagramScopedUserId`, string
  - `platformData`, object
- `testCode`, string
- `consent`, object
  - `adUserData`, string: One of `GRANTED`, `DENIED`
  - `adPersonalization`, string: One of `GRANTED`, `DENIED`

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/ads/conversions" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "destinationId": "68320031250f5d01a73ce89b",
  "events": [
    {
      "eventName": "Acme",
      "eventTime": 1,
      "eventId": "60c89d0a2e8d4a8ebed77064",
      "user": {
        "email": "alex@example.com",
        "phone": "+14155550123",
        "firstName": "Acme"
      }
    }
  ]
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/conversions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    destinationId: "68320031250f5d01a73ce89b",
    events: [
      {
        eventName: "Acme",
        eventTime: 1,
        eventId: "60c89d0a2e8d4a8ebed77064",
        user: {
          email: "alex@example.com",
          phone: "+14155550123",
          firstName: "Acme"
        }
      }
    ]
  }),
});
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/conversions",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "destinationId": "68320031250f5d01a73ce89b",
        "events": [
            {
                "eventName": "Acme",
                "eventTime": 1,
                "eventId": "60c89d0a2e8d4a8ebed77064",
                "user": {
                    "email": "alex@example.com",
                    "phone": "+14155550123",
                    "firstName": "Acme",
                },
            },
        ],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `platform`, string: One of `metaads`, `googleads`, `linkedinads`, `tiktokads`, `openaiads`, `pinterestads`, `redditads`
- `eventsReceived`, integer
- `eventsFailed`, integer
- `failures`, array of object
  - `eventIndex`, integer
  - `eventId`, string
  - `message`, string
  - `code`, string or integer
  - `platformError`, object
- `traceId`, string
- `testCode`, string: Can be null

```json
{
  "platform": "metaads",
  "eventsReceived": 1,
  "eventsFailed": 1,
  "failures": [
    {
      "eventIndex": 1,
      "eventId": "60c89d0a2e8d4a8ebed77064",
      "message": "Hello from Pozy",
      "code": "string",
      "platformError": {}
    }
  ],
  "traceId": "6aa41aeffa864e6ffa88403d",
  "testCode": "string"
}
```
