# Duplicate singelton

**URL:** <https://discourse.getcockpit.com/t/duplicate-singelton/906>\
**Category:** Support\
**Created:** [July 5, 2019, 7:05am UTC](https://discourse.getcockpit.com/t/duplicate-singelton/906 "2019-07-05T07:05:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [July 7, 2019, 1:29pm UTC](https://discourse.getcockpit.com/t/duplicate-singelton/906/2 "2019-07-07T13:29:16Z")

</div>

There is no easy method, yet.

You can copy and paste the field definitions from `/storage/singleton/old.singleton.php` to `/storage/singleton/new.singleton.php`. Now the fields are cloned.

If you want to clone the data, too, just get the data from the old one and save it to the new one.

The PHP way:

```php
// get data from singleton "old"
$data = $app->module('singletons')->getData('old');

// save data to "new"
$app->module('singletons')->saveData('new', $data);

```

Here is a simple way to save singletons via api:

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

---

_[View the full topic](https://discourse.getcockpit.com/t/duplicate-singelton/906)._
