# Is it possible to update a singleton via the API?

**URL:** <https://discourse.getcockpit.com/t/is-it-possible-to-update-a-singleton-via-the-api/1846>\
**Category:** Support\
**Created:** [March 1, 2021, 10:29am UTC](https://discourse.getcockpit.com/t/is-it-possible-to-update-a-singleton-via-the-api/1846 "2021-03-01T10:29:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommueller](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tommueller](https://discourse.getcockpit.com/u/tommueller)\
**Post date:** [March 1, 2021, 10:29am UTC](https://discourse.getcockpit.com/t/is-it-possible-to-update-a-singleton-via-the-api/1846/1 "2021-03-01T10:29:51Z")

</div>

Surprisingly I could neither find any hints in the documentation (neither the official one, not at zeraton) about using the API to update singleton data.

From checking the requests sent when updating a singleton from the admin interface, I figured out that it is using the `singletons/update_data/singleton_name`-endpoint. This however seems to be protected behind login. Using it without logging in just results in a redirect, to the authentication page.

Is there any way to update singleton data via the API, or is it just not possible currently?

Thanks!  
Tom

---

<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:** [March 23, 2021, 5:50pm UTC](https://discourse.getcockpit.com/t/is-it-possible-to-update-a-singleton-via-the-api/1846/2 "2021-03-23T17:50:01Z")

</div>

Have a look here:

> [@Update collection and singleton via api](https://discourse.getcockpit.com/t/update-collection-and-singleton-via-api/404/5):
>
> 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 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 othe…

I also renamed that old thread from “Update collection” to “Update collection and singleton via api” to make it more clear.
