> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Password

> Set an initial password for an OAuth-only user

Sets an initial password for the currently authenticated user. This is for accounts that signed up through OAuth (or an external identity) and have **no password yet** — for example, so they can later sign in with email and password, or unlink their last OAuth identity without being locked out. Requires a valid access token in the `Authorization` header.

<Note>
  This endpoint is only for users who do **not** already have a password. If the
  user already has one, use [Change Password](/api-reference/auth/change-password)
  instead, which verifies the current password before changing it.
</Note>

## Headers

<ParamField header="Authorization" type="string" required>
  `Bearer {accessToken}` — a valid access token for the authenticated user.
</ParamField>

## Body Parameters

<ParamField body="newPassword" type="string" required>
  The password to set for the account.
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  `true` on success.
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message: `"Password set successfully."`
</ResponseField>

## Error Responses

<AccordionGroup>
  <Accordion title="User Not Found — 403">
    ```json theme={null}
    {
      "error": "User not found.",
      "code": "auth/no-user-found"
    }
    ```
  </Accordion>

  <Accordion title="Already Password Authenticated — 400">
    ```json theme={null}
    {
      "error": "User already has a password. Use change-password instead.",
      "code": "auth/already-password-authenticated"
    }
    ```

    Returned when the user already has a password. Use
    [Change Password](/api-reference/auth/change-password) instead.
  </Accordion>
</AccordionGroup>

## See Also

* [`useAuth` hook](/hooks/auth/use-auth) — `setPassword`
* [Change Password](/api-reference/auth/change-password)
* [Unlink OAuth Identity](/api-reference/oauth/unlink-identity)
* [Built-in Auth guide](/sdk/authentication/built-in)
