# Log

Logs are the core of LogSnag. They are used to track events in your application. These events could be anything from user actions to server events, such as a database running out of space or a server crash.

![](https://3433721525-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSA9iVSKSpOR2WuHHgrGA%2Fuploads%2Fu9K0j4UGQMLAXRObSInI%2Fbase.png?alt=media\&token=7b51154a-525e-4d16-831b-d76bdf245e06)

## Publish an event to LogSnag.

<mark style="color:green;">`POST`</mark> `https://api.logsnag.com/v1/log`

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<TOKEN>  |

#### Request Body

| Name                                      | Type      | Description              |
| ----------------------------------------- | --------- | ------------------------ |
| project<mark style="color:red;">\*</mark> | String    | Project name             |
| channel<mark style="color:red;">\*</mark> | String    | Channel name             |
| event<mark style="color:red;">\*</mark>   | String    | Event name               |
| description                               | String    | Event description        |
| icon                                      | Emoji     | Single Emoji ✨           |
| notify                                    | Boolean   | Send push notification   |
| tags                                      | key/value | Event tags               |
| parser                                    | String    | "markdown" or "text"     |
| user\_id                                  | String    | User ID                  |
| timestamp                                 | Number    | unix timestamp (seconds) |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Important:** Fields ending with an \* are required in your request!
{% endhint %}

### Icon

You may add an emoji icon to your logs to make identifying the type of event easier. For example, you could add an `💰` icon to a log that tracks a payment event. Optionally, you may use emoji shortcodes instead of the actual emoji character. For example, you could also use `:moneybag:`

### Tags

Tags are key-value pairs that can add additional information to a log. For example, you could add a "plan" tag with a " premium " value to a log that tracks a payment event.

Note that tag keys may only contain lowercase alphabet characters and are optionally separated with `-` dashes. For example, `plan` and `plan-type` are valid tag keys, but `Plan` and `plan_type` are not. Values may be any string, boolean, or number.&#x20;

### Markdown

You may set the parser parameter to `markdown` to parse the description as markdown. This is useful for making your log descriptions more readable and adding links to external resources.

<table><thead><tr><th width="154">Style</th><th width="278">Syntax</th><th>Output</th></tr></thead><tbody><tr><td>Bold</td><td>**bold**</td><td><strong>bold</strong></td></tr><tr><td>Italic</td><td>*italic*</td><td><em>italic</em></td></tr><tr><td>Link</td><td>[link](https://logsnag.com)</td><td><a href="https://logsnag.com">link</a></td></tr><tr><td>Inline Code</td><td>`code`</td><td><code>code</code></td></tr><tr><td>Code Block</td><td>```code```</td><td><code>code</code></td></tr></tbody></table>

### Historical Data

You may add historical logs to LogSnag by adding a `timestamp` parameter to your logs. The timestamp parameter should be a unix timestamp in seconds. Remember that you will not receive a push notification for historical logs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.logsnag.com/api-reference/log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
