# Update collection and singleton via api

**URL:** <https://discourse.getcockpit.com/t/update-collection-and-singleton-via-api/404>\
**Category:** Support\
**Created:** [November 15, 2018, 3:43pm UTC](https://discourse.getcockpit.com/t/update-collection-and-singleton-via-api/404 "2018-11-15T15:43:02Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [November 19, 2018, 2:02pm UTC](https://discourse.getcockpit.com/t/update-collection-and-singleton-via-api/404/5 "2018-11-19T14:02:12Z")

</div>

> [@elpeyotl](#):
>
> Is there a way to update singletons as well from frontend? I do not see like /singletons/save in the api.

If you want to save singleton data via api, just create a custom api endpoint in  
`config/api/singletons/save/singletonname.php` with this content:

```php
<?php

return $this->invoke('Singletons\\Controller\\Admin', 'update_data', ['singletonname']);

```

Now send a request:  
`https://url.to/cockpit/api/singletons/save/singletonname?token=xxtokenxx`

json post body:  
`{"data":{"title":"test","content":"updated content"}}`

**Caution: It updates empty values, too. So you always have to send all fields or the other fields will be deleted.**

* * *

edit: fixed wrong folder name of custom endpoint - Thanks @SimonHayden for the correction

---

_[View the full topic](https://discourse.getcockpit.com/t/update-collection-and-singleton-via-api/404)._
