> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linquid.io/llms.txt
> Use this file to discover all available pages before exploring further.

# S2S Postback

> Track a conversion via server-to-server postback

## Query Parameters

<ParamField query="lw_cid" type="string" required>
  The click ID from the original redirect
</ParamField>

<ParamField query="amount" type="number">
  Conversion value/amount
</ParamField>

<ParamField query="currency" type="string" default="USD">
  ISO currency code
</ParamField>

<ParamField query="event" type="string" default="conversion">
  Conversion event type
</ParamField>

<ParamField query="orderId" type="string">
  Your unique order/transaction ID
</ParamField>

<ParamField query="payout" type="number">
  Cost/payout amount for ROI tracking
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.linquid.io/api/conversions/postback?lw_cid=abc123xyz789&amount=99.99&currency=USD&event=purchase&orderId=ORD-12345" \
    -H "X-API-Key: lw_your_api_key_here"
  ```

  ```javascript JavaScript theme={null}
  const params = new URLSearchParams({
    lw_cid: 'abc123xyz789',
    amount: '99.99',
    currency: 'USD',
    event: 'purchase',
    orderId: 'ORD-12345',
  });

  const response = await fetch(
    `https://api.linquid.io/api/conversions/postback?${params}`,
    { headers: { 'X-API-Key': 'lw_your_api_key_here' } }
  );
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.linquid.io/api/conversions/postback',
      params={
          'lw_cid': 'abc123xyz789',
          'amount': 99.99,
          'currency': 'USD',
          'event': 'purchase',
          'orderId': 'ORD-12345',
      },
      headers={'X-API-Key': 'lw_your_api_key_here'}
  )
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "conversionId": "conv_def456",
      "clickId": "abc123xyz789",
      "tracked": true
    }
  }
  ```
</ResponseExample>

## Integration Examples

### Shopify Webhook

```javascript theme={null}
// Shopify order webhook handler
app.post('/webhooks/shopify/order', async (req, res) => {
  const order = req.body;

  // Extract click ID from order note attributes or URL params
  const clickId = order.note_attributes?.find(
    attr => attr.name === 'lw_cid'
  )?.value;

  if (clickId) {
    await fetch(
      `https://api.linquid.io/api/conversions/postback?` +
      `lw_cid=${clickId}&amount=${order.total_price}&currency=${order.currency}&orderId=${order.id}`,
      { headers: { 'X-API-Key': process.env.LINQUID_API_KEY } }
    );
  }

  res.sendStatus(200);
});
```

### WordPress/WooCommerce

```php theme={null}
// WooCommerce order completed hook
add_action('woocommerce_thankyou', function($order_id) {
  $order = wc_get_order($order_id);
  $click_id = WC()->session->get('lw_cid');

  if ($click_id) {
    $url = 'https://api.linquid.io/api/conversions/postback?' . http_build_query([
      'lw_cid' => $click_id,
      'amount' => $order->get_total(),
      'currency' => $order->get_currency(),
      'orderId' => $order_id,
    ]);

    wp_remote_get($url, [
      'headers' => ['X-API-Key' => LINQUID_API_KEY]
    ]);
  }
});
```

## Best Practices

<Tip>
  **Store the click ID early** - Capture `lw_cid` from the landing page URL and store it in session/cookie immediately. Pass it through your checkout flow.
</Tip>

<Warning>
  **Idempotency** - Include a unique `orderId` to prevent duplicate conversions if the postback is retried.
</Warning>
