logsh.co

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"
  }
}
NametypeDescriptionRestrictions
workspaceStringWorkspace nameRequired
eventStringEvent nameRequired
descriptionStringEvent descriptionRequired
iconStringEvent iconOptional
notifyBooleanWhether to send a push notificationOptional
metadatakey/valueAdditional metadata for the eventOptional

Validation Rules:

NameValidatorsExample
workspaceMust be a non-empty string.
Max length: 35 characters.
logsh
eventMust be a non-empty string.
Max length: 250 characters.
user.signup
descriptionMust be a non-empty string.
Max length: 150 characters.
User signed up for the newsletter.
iconOptional, if provided must be a non-empty string.
Must be a valid emoji.
👤
notifyOptional, if provided must be a boolean.
Default: false.
false
metadataOptional, 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>",
 
}
NametypevalueRestrictions
Content-Typestringapplication/jsonRequired
AuthorizationstringBearer <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.

StatusNameMessage
400bad_requestInvalid body parameters provided.
401unauthorizedYour Bearer Token is missing, invalid or expired.
429rate_limit_exceededRate 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