# Run a datastore method

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

`POST /datastore/{id}/test/{method}`

Resource: **Datastores**

Runs one method of a datastore with the request body as its input, to check the datastore's config and credentials. The method runs for real: `uploadObject`, `insertRows`, `upsert` and the like write to your storage.

Methods by type: `s3`, `google_cloud_storage`, `azure_blob_storage`: `listObjects`, `uploadObject`. `qdrant` datastores can't be tested here (`400`). `postgres`: `testConnection`, `insertRows`, `upsertRows`, `deleteRows`, `executeStatement`. `pinecone`: `testConnection`, `upsert`, `query`, `deleteVectors`, `upsertDocuments`, `searchDocuments`, `deleteDocuments`. `bigquery`: `testConnection`, `insertRows`. `snowflake`: `testConnection`, `insertRows`, `executeStatement`. A datastore of the removed `mongo_data_api` type has none, and is refused with a `400`.

## Path parameters

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

## Response body

- **`success`** _(boolean)_
- **`data`** _(unknown)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | The datastore was not found in your environments, the type has no test methods, `method` is not one of the type's, or the method failed. |

## Code examples

### Truto CLI

```bash
truto datastores test '<id>' -o json
```

### curl

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

### JavaScript

```javascript
const response = await fetch('https://api.truto.one/datastore/{id}/test/{method}', {
  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/datastore/{id}/test/{method}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}

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