# Events

You can use the API to get or set event information.

## The Event Model

| Key           | Type   | Description                                                                                        |
| ------------- | ------ | -------------------------------------------------------------------------------------------------- |
| id            | String | The unique identifier for the event which is given by Tiledesk.                                    |
| name          | String | The event name. You can find the standard Tiledesk events [here](/apis/webhooks.md#webhook-events) |
| project\_user | Object | The user who creates the event.                                                                    |
| attributes    | Object | The custom attributes which are set for the event.                                                 |
| createdAt     | String | The time (ISO-8601 date string) when the event was created.                                        |
| updatedAt     | String | The time (ISO-8601 date string) when the event was updated.                                        |
| createdBy     | String | The unique identifier of the row creator                                                           |
| id\_project   | String | The unique identifier of the project                                                               |

## Get all events

<mark style="color:blue;">`GET`</mark> `https://api.tiledesk.com/v3/:project_id/events`

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| project\_id | string | the Project Id is a unique code assigned to your project when you create it in Tiledesk. |

#### Query Parameters

| Name      | Type   | Description                                                                                                          |
| --------- | ------ | -------------------------------------------------------------------------------------------------------------------- |
| sortField | string | what field to sort the results by.                                                                                   |
| direction | string | <p>sort direction: 1 or -1. Return the results in ascending or descending order.</p><p><em>defaults to desc</em></p> |
| page      | number | what page of results to fetch. defaults to first page.                                                               |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | authorization token. Basic Auth or JWT |

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

```
{
   ...
}
```

{% endtab %}
{% endtabs %}

## Get a event by id

<mark style="color:blue;">`GET`</mark> `https://api.tiledesk.com/v3/:project_id/events/:id`

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| id          | string | the event identifier                                                                     |
| project\_id | string | The project\_id is a unique code assigned to your project when you create it in Tiledesk |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | authorization token. Basic Auth or JWT |
| Content-Type  | string | use "application/json" value           |

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

```
{  
        ..
}
```

{% endtab %}
{% endtabs %}

## Fire a new custom event and save it

<mark style="color:green;">`POST`</mark> `https://api.tiledesk.com/v3/:project_id/events`

With this endpoint you can fire a custom event. You event name should be

`event.emit.EVENT_NAME`

to correctly identify your custom event. You can find the standard Tiledesk events here

#### Path Parameters

| Name        | Type   | Description                                                                              |
| ----------- | ------ | ---------------------------------------------------------------------------------------- |
| project\_id | string | The project\_id is a unique code assigned to your project when you create it in Tiledesk |

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | authorization token. Basic Auth or JWT |
| Content-Type  | string | use "application/json" value           |

#### Request Body

| Name       | Type   | Description                 |
| ---------- | ------ | --------------------------- |
| name       | string | the event name              |
| attributes | object | The event custom attributes |

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

```
{  
        ..
}
```

{% endtab %}
{% endtabs %}


---

# 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://developer.tiledesk.com/apis/rest-api/events.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.
