# Registering New Account

**`POST /accounts/register`**

Registers a new user account with a username, password, and optional role.

**Authentication:** Bearer token required for non-demo mode (`Authorization: Bearer <token>`). Only a Standard Registry user may register new accounts outside of demo mode.

***

## Request

### Request Body

```json
{
  "username": "example_user",
  "password": "examplePassword123",
  "role": "USER"
}
```

| Field      | Type   | Required | Description                                                              |
| ---------- | ------ | -------- | ------------------------------------------------------------------------ |
| `username` | string | Yes      | The new account username                                                 |
| `password` | string | Yes      | The account password                                                     |
| `role`     | string | No       | User role: `STANDARD_REGISTRY`, `USER`, or `AUDITOR`. Defaults to `USER` |

***

## Response

### Success Response

**Status:** `201 Created`

```json
{
  "username": "example_user",
  "role": "USER",
  "did": null,
  "hederaAccountId": null
}
```

### Error Responses

| Status                      | Description                                 |
| --------------------------- | ------------------------------------------- |
| `401 Unauthorized`          | Caller is not authenticated (non-demo mode) |
| `403 Forbidden`             | Caller does not have Standard Registry role |
| `409 Conflict`              | Username already exists                     |
| `500 Internal Server Error` | Unexpected server failure                   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guardian.hedera.com/docs/develop/accounts-and-profiles/account-apis/registering-new-account.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
