# Delete

{% hint style="danger" %}
You should always make sure that you are calling these events after the rcore\_stats script is initialized.

To make sure, check the Step 1 in the [Integration](/paid-resources/rcore_stats/api/integration.md) guide.
{% endhint %}

## Delete order

{% hint style="warning" %}
When deleting any data using API events, you must make sure to follow a certain order.
{% endhint %}

Reason for this is that some data is dependent on other data.

Achievements are dependent on stat types, and stat types are dependent on categories. If you try to delete a category first and some stat type will depend on it, you will get an SQL error.

Correct order:

1. Delete achievement
2. Delete stat type
3. Delete category

## Delete Events

{% hint style="warning" %}
All events are SERVER SIDE.
{% endhint %}

### Deleting achievements

```lua
-- @param key string - unique key of the achievement
TriggerEvent('rcore_stats:api:deleteAchievement', key)

-- Example to delete the achievement "basket_hoops_1"
TriggerEvent('rcore_stats:api:deleteAchievement', "basket_hoops_1")
```

### Deleting stat types

```lua
-- @param key string - unique key of the stat type
TriggerEvent('rcore_stats:api:deleteStatType', key)

-- Example to delete the stat type "total_basket_hoops"
TriggerEvent('rcore_stats:api:deleteStatType', "total_basket_hoops")
```

### Deleting categories

```lua
-- @param key string - unique key of the category
TriggerEvent('rcore_stats:api:deleteCategory', key)

-- Example to delete the category "minigames"
TriggerEvent('rcore_stats:api:deleteCategory', "minigames")
```


---

# 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://documentation.rcore.cz/paid-resources/rcore_stats/api/delete.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.
