# override all entries in a collection in API

**URL:** https://discourse.getcockpit.com/t/override-all-entries-in-a-collection-in-api/973
**Category:** Support
**Created:** [August 15, 2019, 9:38am UTC](https://discourse.getcockpit.com/t/override-all-entries-in-a-collection-in-api/973 "2019-08-15T09:38:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pazini](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pazini/32/404_2.png) [@pazini](https://discourse.getcockpit.com/u/pazini)
#### Post date: [August 15, 2019, 9:38am UTC](https://discourse.getcockpit.com/t/override-all-entries-in-a-collection-in-api/973/1 "2019-08-15T09:38:05Z")

</div>

hello … I need to delete all entries in a collection from time to time and insert new ones. this dynamically without the dashboard. In fact, it will be powered by a Json that I will receive from another system. Has as? Has anyone done?

---

<div class="post-metadata">

### Author: ![pauloamgomes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/pauloamgomes/32/48_2.png) [@pauloamgomes](https://discourse.getcockpit.com/u/pauloamgomes)
#### Post date: [August 16, 2019, 5:50pm UTC](https://discourse.getcockpit.com/t/override-all-entries-in-a-collection-in-api/973/2 "2019-08-16T17:50:22Z")

</div>

You can do in several ways:

1. Command line - create a cli command that empties the collection entries, believe you can do:  
`$app->module('collections')->remove('colectionname', []);`
2. Rest Endpoint - create a REST endpoint that receives the collection name and runs above command (think that option could be dangerous, if doing that ensure you have a custom API key for it)
3. Via a trigger action, let’s imagine that you have a singleton or other collection that when saved you want to flush some other collection, implement the proper trigger using the dropCollection method
