---
docId: doc_3a62fcf07f3f46479122b4446d40fcfb
title: Update a database
description: "Change a connection or its hidden tables and columns."
api:
  group: herramientas/bases-de-datos
  auth: bearer
  operations:
    - operationId: updateDatabase
      method: PATCH
      path: '/v1/tools/databases/{databaseId}'
      postmanName: Update a database
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Update a database

Update the fields you send. If you send `hiddenTables` or `hiddenColumns`, the supplied list fully replaces the previous one.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X PATCH https://api.platic.ai/v1/tools/databases/$DB_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "hiddenColumns": ["customers.phone"] }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.tools.databases.update("db_123", { hiddenColumns: ["customers.phone"] });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `databaseId` | string | The `id` of the connection | ✓ |

## Request body

It accepts the same fields as [connect a database](/api-reference/databases/connect#request-body), all optional, with at least one. `passwordSecretId: null` stops using the current password; the secret stays in [Secrets](/api-reference/secrets/list).

```json
{
  "hiddenTables": ["payments"],
  "hiddenColumns": ["customers.phone", "customers.email"],
  "pageSize": 100
}
```

### What happens when you change something

| If you change… | What happens |
|----------------|--------------|
| `engine`, `host`, `port`, `database`, `user`, or `ssl` | `lastTest` goes back to `null`: [test it](/api-reference/databases/test) again |
| `host`, `port`, or `ssl` | The same password is authorized for the new destination. If that is not possible, the response has `passwordError` and `password.state` stays `needs_authorization` |
| `name` | The tools are renamed (`db_<name>_…`) and keep their `id`: agents that have them keep using them |
| `password` or `passwordSecretId` | Replaces the password. A new password is stored as another secret |

## Response

`200 OK`. `data` has the connection with the fields in [get a database](/api-reference/databases/get#response-fields) and `message` is `Connection updated`.

```json
{
  "status": "success",
  "message": "Connection updated",
  "data": {
    "id": "Xb2mQe7LtR9sKd4fHw1N",
    "name": "store",
    "status": "enabled",
    "hiddenTables": ["payments"],
    "hiddenColumns": ["customers.phone", "customers.email"],
    "pageSize": 100,
    "password": { "state": "authorized", "secretId": "7e4a1c9b3d5f7a0c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d0f2a4c6e8b0d2f4a6c", "secretName": "Password of the store database" },
    "lastTest": { "ok": true, "at": "2026-11-14T16:01:12.000Z", "version": "PostgreSQL 16.4", "tableCount": 3 },
    "nextStep": "Ready. Give its tools to an agent with PUT /v1/agents/{agentId}/tools/{toolId} and a toolId from tools."
  }
}
```

The example omits some fields of the connection.

<Note type="important">

If the changes are saved but the password is not, the response is still `200`: `message` is `Connection updated, but its password was not: see passwordError` and `data.passwordError` has `{ code, message }`.

</Note>

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | The body is empty, a value is not accepted, it has `password` and `passwordSecretId` together, or an unknown field. `details.issues` says which |
| `400` | `INVALID_NAME`, `INVALID_CONFIG`, or `INVALID_CONNECTION_STRING` | As in [connect a database](/api-reference/databases/connect#errors) |
| `403` | `FORBIDDEN` or `INSUFFICIENT_SCOPE` | The person behind the token does not have access to Integrations, or the token does not have write permission |
| `404` | `NOT_FOUND` | There is no connection with that id in the workspace |
| `409` | `NAME_TAKEN` | There is already another connection or tool with that name |

## Notes

- This call is not retried on its own: a password sent twice would be stored in two secrets. If the response is lost, [get the connection](/api-reference/databases/get) to see what was left.
