---
title: Manage Database Credentials with the Public API
description: Learn how to reset database credentials via the public GraphQL API.
---
Here are examples to help you reset a database service's credentials using the Public API.

## Reset a database password

Reset a database service's credentials and update its variables:

<GraphQLCodeTabs query={`mutation databasePasswordReset($input: DatabasePasswordResetInput!) {
  databasePasswordReset(input: $input) {
    newPassword
    rotationInProgress
    updatedVariables
  }
}`} variables={{ input: { environmentId: "environment-id", serviceId: "service-id", databaseType: "postgres" } }} />

`databaseType` identifies the engine, for example `postgres`, `mysql`, `mongodb`, or `redis`. Railway returns the new password in `newPassword` and the service's updated variables in `updatedVariables`.

<Banner variant="warning">Resetting credentials invalidates the old password immediately. Anything connecting with the old value, outside of other Railway services that reference it with a [variable reference](/integrations/api/manage-variables#variable-references), loses its connection until it's updated.</Banner>

On a high-availability cluster, the rotation keeps running after this mutation returns, reported as `rotationInProgress: true`, and `updatedVariables` is empty until it finishes. Use `databasePasswordRotationProgress` below to follow it.

## Get HA rotation progress

Poll rotation progress on a high-availability cluster until it finishes:

<GraphQLCodeTabs query={`query databasePasswordRotationProgress($environmentId: String!, $serviceId: String!) {
  databasePasswordRotationProgress(environmentId: $environmentId, serviceId: $serviceId) {
    phase
    memberServiceId
    memberServiceName
    completedMembers
    error
  }
}`} variables={{ environmentId: "environment-id", serviceId: "service-id" }} />

The query returns `null` once there's no rotation running for the service, whether it finished or none was ever started.