Tugus Docs

HTTP API

Send server-to-server events to Tugus over plain HTTP — no client-side dependency required.

For server-to-server events or custom implementations. No client-side dependency.

  • POST https://collect.tugus.io/collect/{api_key}
  • GET https://app.tugus.io/api/v1/properties/{property}/events

The request body is an envelope: event, user, and identity fields at the top level; all event/commerce fields nested inside data.

Request

curl -X POST https://collect.tugus.io/collect/th_YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "event":     "purchase",
    "event_id":  "purchase_ORD-2024-001",
    "client_id": "optional_if_available",
    "data": {
      "order_id":  "ORD-2024-001",
      "value":     99.80,
      "currency":  "EUR"
    },
    "user": {
      "email":   "kunde@example.com"
    }
  }'

PHP example

$response = Http::post('https://collect.tugus.io/collect/' . $apiKey, [
  'event'    => 'purchase',
  'event_id' => 'purchase_' . $order->id,
  'data'     => [
    'order_id' => (string) $order->id,
    'value'    => (float) $order->total,   // 99.80 — dot decimal, not "99,80"
    'currency' => 'EUR',                    // 3 letters (ISO 4217)
  ],
  'user'     => [
    'email' => $order->email,  // Tugus hashes server-side
  ],
]);

if ($response->successful()) {
  Log::info('Tugus event accepted', ['event_id' => $response->json('event_id')]);
}

For purchase and refund, data.value and data.currency are required. Sending them at the top level (value/currency outside data) yields a 422 — the endpoint reads them only from inside data.

Response

202 Accepted

{
  "ok":       true,
  "event_id": "a3f8b2c1-d4e5-f6a7-b8c9-d0e1f2a3b4c5"
}