Send events from your server
Record custom events from your backend with the website's API token.
Send a custom event from anywhere in your stack with one request:
PUT https://api.blueradar.net/event
It shows up with the website's other custom events.
Your API token
Every website has its own token. Find it under Websites, your website, Settings, API token. Click Create token the first time.
Rotate issues a new one. The old one stops working, so update your servers right away. Keep the token on your server, never in a page.
Fields
Send JSON or a form.
| Field | ||
|---|---|---|
site_id |
Required | The website's site ID |
api_token |
Required | The website's API token |
event |
Required | The event name, see names and values |
value |
Optional | A number, such as an invoice total or a duration in ms |
uid |
Optional | Your own identifier for the event, such as a user ID |
Example
curl -X PUT https://api.blueradar.net/event \
-d site_id="YOUR_SITE_ID" \
-d api_token="YOUR_API_TOKEN" \
-d event="invoice-paid" \
-d value=105
In Laravel:
php
use Illuminate\Support\Facades\Http;
Http::put('https://api.blueradar.net/event', [
'site_id' => config('services.blueradar.site_id'),
'api_token' => config('services.blueradar.api_token'),
'event' => 'invoice-paid',
'value' => $invoice->total,
'uid' => (string) $invoice->user_id,
])->throw();
Responses
200 with ok means the event was recorded. Anything else carries a short reason as text:
| Status | Body | Meaning |
|---|---|---|
| 400 | missing parameters from payload |
site_id, api_token or event is missing |
| 400 | value parameter must be numeric |
value is not a number |
| 400 | invalid event |
The event name is not allowed |
| 401 | invalid api token |
The token is wrong, or was rotated |
| 404 | 404 Not Found |
No website has this site ID |
| 429 | rate limited |
Too many events at once. Wait for Retry-After seconds and send again |
| 503 | try again |
Send again after Retry-After seconds |