# Set database password

`POST https://api.instacloud.com/projects/{projectId}/database/password`

**Token scope:** `account` · `org` · `project` — read-only tokens refused (not a GET).

Set or regenerate the postgres user password. Omitting password asks the provider to generate one.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `branch` | query | `string` | no | branch name (default branch if omitted) |
| `group` | query | `string` | no | postgres service name (default: the sole postgres service) |
| `projectId` | path | `string` | yes |  |

## Request body (application/json)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `password` | `string` | no | new password; omit to generate one |

## Response 200

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `connString` | `string` | no |  |
| `password` | `string` | no |  |
| `privateConnString` | `string` | no | the private network lane twin of connString (with the password). Present only while the instance has private access. |
| `credentialsStored` | `boolean` | no | password rotation only (insta-db) — true: the new connection strings were stored in the project secrets (DATABASE_URL, and DATABASE_PRIVATE_URL while private access is on). false: the password rotated but storing them failed, so the project secrets still carry the retired password and this response holds the only copy of the new credentials — rotate again to re-store them. Absent on a provider path that stores no credentials. Branch on this, not on `warnings` text: a warning can accompany a successful store. |
| `warnings` | `string[]` | no | password rotation only — what to act on: compute services bound to this database that must be redeployed to pick up the new password, or (the rotation still succeeded) that re-storing DATABASE_URL / DATABASE_PRIVATE_URL failed, in which case this response holds the only copy of the new credentials. |

## Response 202

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `"approval_required"` | no |  |
| `approvalId` | `string` | no |  |
| `action` | `string` | no | the gated action, or a comma-joined compound set — prefer `actions` |
| `actions` | `string[]` | no | every capability this approval covers |
| `message` | `string` | no |  |
| `url` | `string` | no | the console page where a project admin reviews this request |
| `nextActions` | `object[]` | no |  |
| `nextActions.op` | `string` | yes | Neutral logical action id, e.g. "service.add" — NOT an operationId or a CLI/MCP tool name; each client maps it to its own surface. |
| `nextActions.reason` | `string` | yes | Natural-language, human/LLM-facing "why do this now". |
| `nextActions.args` | `object` | no | Suggested, flat named arguments; "<placeholder>"s where a value is unknown. |
| `nextActions.gated` | `boolean` | no | True if the action passes a governance gate. |

## Response 400

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |

## Response 403

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |

## Response 404

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |

## Response 409

code credential_change_in_progress: another credential change for this database (a rotation or a private-access toggle) is in flight — nothing was changed and the password is not rotated; retry in a moment

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |
| `code` | `string` | no | stable machine-readable reason, e.g. private_lane_disabled, private_lane_unavailable_in_region, public_access_closed, credential_change_in_progress |

## Response 502

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |
