Event
To send events to Logsh, make a POST request to the following endpoint:
https://logsh.co/api/event
Request Body
{
"workspace": "logsh",
"event": "user.signup",
"description": "User signed up for the newsletter.",
"icon": "👤",
"notify": false,
"metadata": {
"user_id": "12345",
"plan": "pro"
}
}
| Name | type | Description | Restrictions |
|---|
| workspace | String | Workspace name | Required |
| event | String | Event name | Required |
| description | String | Event description | Required |
| icon | String | Event icon | Optional |
| notify | Boolean | Whether to send a push notification | Optional |
| metadata | key/value | Additional metadata for the event | Optional |
Validation Rules:
| Name | Validators | Example |
|---|
| workspace | Must be a non-empty string. Max length: 35 characters. | logsh |
| event | Must be a non-empty string. Max length: 250 characters. | user.signup |
| description | Must be a non-empty string. Max length: 150 characters. | User signed up for the newsletter. |
| icon | Optional, if provided must be a non-empty string. Must be a valid emoji. | 👤 |
| notify | Optional, if provided must be a boolean. Default: false. | false |
| metadata | Optional, if provided must be an object. key/value | { Â Â "user_id" : "12345", Â Â "plan" : "pro", } |
Notes:
- If the workspace you provide doesn't exist in your Logsh workspaces we will create it for you automatically.
- The workspace aren't case-sensitive for practical purposes, so "Logsh" and "logsh" will be treated the same.
Request Headers
{
"Content-Type" : "application/json",
"Authorization" : "Bearer <YOUR_API_KEY>",
}
| Name | type | value | Restrictions |
|---|
| Content-Type | string | application/json | Required |
| Authorization | string | Bearer <YOUR_API_KEY> | Required |
Response
A successful request will return a 200 OK status with a JSON response:
and a failure will return an appropriate error status code and message.
| Status | Name | Message |
|---|
| 400 | bad_request | Invalid body parameters provided. |
| 401 | unauthorized | Your Bearer Token is missing, invalid or expired. |
| 429 | rate_limit_exceeded | Rate limit was exceeded. |
Example using JavaScript (Fetch API)
JavaScript example
export const sendLogshEvent = async ( data ) => {
const response = await fetch(
'https://logsh.co/api/event',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
// Replace <YOUR_API_KEY> with your actual API Key
'Authorization': 'Bearer <YOUR_API_KEY>',
},
body: JSON.stringify({
// Your workspace name
workspace: data.workspace,
// Event name
event: data.event,
// Event description
description: data.description,
// Event icon (optional)
icon: data.icon,
// Whether to send a push notification (optional)
notify: data.notify,
// Additional metadata for the event (optional)
metadata: data.metadata,
}),
}
)
const result = await response.json();
if( !response.ok ) {
throw new Error(result.message || 'Failed to send event to Logsh');
}
}
Send an event to logsh.co