# Update datastore

> Source: https://truto.one/docs/api-reference/admin/datastores/update/

`PATCH /datastore/{id}`

Resource: **Datastores**

## Path parameters

- **`id`** _(string, required)_
  The ID of the datastore to update.

## Request body

- **`label`** _(string)_
  New label for this datastore.
- **`config`** _(object)_
  Updated config object. Partial updates are accepted; fields not supplied are left unchanged. Shape still depends on `type`.
  _One of:_
  - **Mongo Data Api**
    - **`data_source`** _(string)_
      Name of the Atlas cluster (the Data API "data source").
    - **`database`** _(string)_
    - **`api_url`** _(string)_
      Base URL of your Atlas Data API endpoint.
    - **`api_key`** _(string)_
      Atlas Data API key. Treat as a secret.
  - **Google Cloud Storage**
    - **`bucket`** _(string)_
    - **`credentials`** _(object, required)_
      Service-account JSON used to authenticate against Google Cloud Storage.
      - **`type`** _(string)_
      - **`project_id`** _(string)_
      - **`private_key_id`** _(string)_
      - **`private_key`** _(string)_
      - **`client_email`** _(string)_
      - **`client_id`** _(string)_
      - **`auth_uri`** _(string)_
      - **`token_uri`** _(string)_
      - **`auth_provider_x509_cert_url`** _(string)_
      - **`client_x509_cert_url`** _(string)_
      - **`universe_domain`** _(string)_
  - **S3**
    - **`access_key_id`** _(string)_
    - **`secret_access_key`** _(string)_
      Secret access key. Treat as a secret.
    - **`region`** _(string)_
    - **`bucket`** _(string)_
    - **`base_url`** _(string)_
      Optional override for non-AWS S3 endpoints (e.g. R2, MinIO).
  - **Qdrant**
    - **`base_url`** _(string)_
    - **`api_key`** _(string)_
      Qdrant API key. Treat as a secret.
    - **`port`** _(integer)_
    - **`collection`** _(string)_
- **`config_secret`** _(string)_
  New secret credentials if needed.

## Response body

- **`id`** _(string)_
  The unique ID of the datastore.
- **`type`** _(string)_
  The datastore's backend type. Determines the shape of `config`.
  Allowed: `mongo_data_api`, `google_cloud_storage`, `s3`, `qdrant`
- **`label`** _(string)_
  A friendly label for identifying this datastore.
- **`config`** _(object)_
  Config object for the datastore connection (minus sensitive fields). The shape depends on `type`.
  _One of:_
  - **Mongo Data Api**
    - **`data_source`** _(string)_
      Name of the Atlas cluster (the Data API "data source").
    - **`database`** _(string)_
    - **`api_url`** _(string)_
      Base URL of your Atlas Data API endpoint.
    - **`api_key`** _(string)_
      Atlas Data API key. Treat as a secret.
  - **Google Cloud Storage**
    - **`bucket`** _(string)_
    - **`credentials`** _(object, required)_
      Service-account JSON used to authenticate against Google Cloud Storage.
      - **`type`** _(string)_
      - **`project_id`** _(string)_
      - **`private_key_id`** _(string)_
      - **`private_key`** _(string)_
      - **`client_email`** _(string)_
      - **`client_id`** _(string)_
      - **`auth_uri`** _(string)_
      - **`token_uri`** _(string)_
      - **`auth_provider_x509_cert_url`** _(string)_
      - **`client_x509_cert_url`** _(string)_
      - **`universe_domain`** _(string)_
  - **S3**
    - **`access_key_id`** _(string)_
    - **`secret_access_key`** _(string)_
      Secret access key. Treat as a secret.
    - **`region`** _(string)_
    - **`bucket`** _(string)_
    - **`base_url`** _(string)_
      Optional override for non-AWS S3 endpoints (e.g. R2, MinIO).
  - **Qdrant**
    - **`base_url`** _(string)_
    - **`api_key`** _(string)_
      Qdrant API key. Treat as a secret.
    - **`port`** _(integer)_
    - **`collection`** _(string)_
- **`environment_id`** _(string)_
  The environment to which this datastore belongs.
- **`created_at`** _(string)_
  Timestamp when the datastore record was created.
- **`updated_at`** _(string)_
  Timestamp when the datastore record was last updated.

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/datastore/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "label": "your_label",
  "config_secret": "your_config_secret"
}'
```

### JavaScript

```javascript
const body = {
  "label": "your_label",
  "config_secret": "your_config_secret"
};

const response = await fetch('https://api.truto.one/datastore/{id}', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

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

### Python

```python
import requests

url = "https://api.truto.one/datastore/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "label": "your_label",
    "config_secret": "your_config_secret"
}

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

### Truto TS SDK

```typescript
import Truto from '@truto/truto-ts-sdk';

const truto = new Truto({
  token: '<your_api_token>',
});

const body = {
  "label": "your_label",
  "config_secret": "your_config_secret"
};

const result = await truto.datastore.update('<id>', body);

console.log(result);
```

### Truto Python SDK

```python
import asyncio
from truto_python_sdk import TrutoApi

truto_api = TrutoApi(token="<your_api_token>")

async def main():
    body = {
        "label": "your_label",
        "config_secret": "your_config_secret"
    }

    result = await truto_api.datastores.update("<id>", body)
    print(result)

asyncio.run(main())
```
