# Move secrets to key store

> Source: https://truto.one/docs/api-reference/admin/key-stores/move-secrets/

`POST /key-store/{id}/move-secrets`

Resource: **Key stores**

Team admins only (signed-in users; API tokens get 403). Moves every secret of the environment that Truto still encrypts, or that is in another of its key stores, into this key store, in the background. The other store's copy is deleted a couple of minutes after its row moves. The store must be current and `active` (400 otherwise). Returns how many integrated accounts and environment integrations were waiting to move; follow the progress with `GET /key-store/{id}/usage` (`in_truto` and `in_other_stores` going down to 0). Safe to call again while a move runs: each row moves with a conditional update. A row that fails to move is logged and skipped; calling this again retries it.

## Path parameters

- **`id`** _(string, required)_

## Response body

- **`integrated_accounts`** _(integer)_
- **`environment_integrations`** _(integer)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | The key store is not active. |

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/key-store/{id}/move-secrets' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json'
```

### JavaScript

```javascript
const response = await fetch('https://api.truto.one/key-store/{id}/move-secrets', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/key-store/{id}/move-secrets"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}

response = requests.post(url, headers=headers, params=params)
print(response.json())
```
