> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Conversions API

Send server-side conversion events to an OpenAI pixel through OpenAI's Conversions API.

`POST /v1/events` relays server-side events to OpenAI's Conversions API, alongside what the pixel sees on your site.

## Before you start

The account needs a pixel, which also provisions the Conversions API key ([Create the pixel](/platforms/openai-ads/tracking-tag#create-the-pixel)).

`destinationId` is the pixel wire id, from `GET /v1/ads/conversions/destinations` ([List conversion destinations](/conversions/list-ad-conversion-destinations)).

## Send a conversion event

Zernio hashes email identifiers with SHA-256 and sends money in minor units. Send plaintext and whole currency values.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: sent } = await zernio.conversions.sendEvents({
  body: {
    profileId: '66a1f0c2a4b9d3e8f1a2b3c4',
    destinations: [{ accountId: '66b2e19d8c3f5a7e9d0b1c2d', destinationId: '4Kx9TqLm2VbN7wRz1PsYcD' }],
    events: [{
      eventName: 'Purchase',
      eventTime: 1798804800,
      eventId: 'order_12345',
      sourceUrl: 'https://shop.example.com/checkout/confirmation',
      value: 25.99,
      currency: 'USD',
      user: { email: 'customer@example.com' }
    }]
  }
});

console.log(sent.destinations);
```
</Tab>
<Tab value="Python">
```python
sent = client.conversions.send_events(
    profile_id="66a1f0c2a4b9d3e8f1a2b3c4",
    destinations=[{"accountId": "66b2e19d8c3f5a7e9d0b1c2d", "destinationId": "4Kx9TqLm2VbN7wRz1PsYcD"}],
    events=[{
        "eventName": "Purchase",
        "eventTime": 1798804800,
        "eventId": "order_12345",
        "sourceUrl": "https://shop.example.com/checkout/confirmation",
        "value": 25.99,
        "currency": "USD",
        "user": {"email": "customer@example.com"},
    }],
)

print(sent["destinations"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST "https://zernio.com/api/v1/events" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profileId": "66a1f0c2a4b9d3e8f1a2b3c4",
    "destinations": [{ "accountId": "66b2e19d8c3f5a7e9d0b1c2d", "destinationId": "4Kx9TqLm2VbN7wRz1PsYcD" }],
    "events": [{
      "eventName": "Purchase",
      "eventTime": 1798804800,
      "eventId": "order_12345",
      "sourceUrl": "https://shop.example.com/checkout/confirmation",
      "value": 25.99,
      "currency": "USD",
      "user": { "email": "customer@example.com" }
    }]
  }'
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "eventsReceived": 1,
  "stored": true,
  "testCode": null,
  "destinations": [
    { "accountId": "66b2e19d8c3f5a7e9d0b1c2d", "destinationId": "4Kx9TqLm2VbN7wRz1PsYcD", "platform": "openaiads", "eventsSent": 1, "eventsFailed": 0, "failures": [] }
  ],
  "queuedDestinations": 0
}
```

## Event names

`Purchase`, `Lead`, `AddToCart`, `ViewContent`, `InitiateCheckout`, `CompleteRegistration`, `Subscribe`, `StartTrial` and `Schedule` map 1 to 1 onto OpenAI's own event types.

So `Purchase` arrives as `order_created`, `Lead` as `lead_created` and `AddToCart` as `items_added`. Any other name is sent as a custom event with the name preserved.

## How it behaves

- Larger submissions are split into chunks of 1,000 events.
- Each chunk is all-or-nothing: one malformed event fails its chunk.
- `eventsFailed` plus `failures[]` name the events that did not land.
- Conversions API events appear in the pixel's [stats](/platforms/openai-ads/tracking-tag#check-the-pixel-fires) next to pixel events.

## If it fails

| Error | Cause | Fix |
|-------|-------|-----|
| `422` with code `tracking_tag_required` | Conversions sent before any pixel exists | [Create the pixel](/platforms/openai-ads/tracking-tag#create-the-pixel) first. |
| `eventsFailed` above 0 | A malformed event failed its chunk of up to 1,000 | Fix the events `failures[]` names and resend that chunk. |

## Related

- [Send events](/conversions/send-events): every field of the request.
- [List conversion destinations](/conversions/list-ad-conversion-destinations): pixel ids and conversion events.
- [OpenAI pixel](/platforms/openai-ads/tracking-tag): create the pixel and its events.
- [Create a campaign](/platforms/openai-ads/create-ads#choose-the-conversion-event): optimize for a conversion event.