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

# User API

> API docs for registering, authenticating, and managing a Silicon Data user account.

These endpoints cover the user account lifecycle: registration, email confirmation, login, password management, and account deletion. Successful responses are wrapped in the standard `{ "meta": ..., "data": ... }` envelope, where `data` holds the value described under each endpoint.

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/register

Create the admin user and company account with the related parameters. After registering, a confirmation code is emailed to the user.

### Authorization

This endpoint is **unauthenticated**. No access token is required.

### Request Body

The request body must be in `application/json` format.

| Field                 | Type           | Required | Description                          | Constraints             |
| --------------------- | -------------- | -------- | ------------------------------------ | ----------------------- |
| `email`               | string         | Yes      | Email address (used as the username) | Valid email             |
| `password`            | string         | Yes      | Account password                     | Min 3 characters        |
| `company_name`        | string         | Yes      | Your company name                    | \[ 2 .. 60 ] characters |
| `first_name`          | string or null | No       | First name                           | \[ 1 .. 50 ] characters |
| `last_name`           | string or null | No       | Last name                            | \[ 1 .. 50 ] characters |
| `company_description` | string or null | No       | Description of your company          | Max 1024 characters     |
| `country`             | string or null | No       | Country                              | \[ 2 .. 60 ] characters |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com",
  "password": "S3curePass!",
  "company_name": "Acme Compute",
  "first_name": "Jane",
  "last_name": "Doe",
  "company_description": "GPU cloud provider",
  "country": "United States"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/register",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": "User registered successfully. Please confirm your email."
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/confirm

Confirm the registration of the user using the confirmation code that was emailed during registration.

### Authorization

This endpoint is **unauthenticated**. No access token is required.

### Request Body

The request body must be in `application/json` format.

| Field               | Type   | Required | Description                         | Constraints |
| ------------------- | ------ | -------- | ----------------------------------- | ----------- |
| `email`             | string | Yes      | Email address                       | Valid email |
| `confirmation_code` | string | Yes      | The confirmation code sent by email |             |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com",
  "confirmation_code": "123456"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/confirm",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": "User confirmed successfully."
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/resend-confirmation-code

Resend the registration verification code to the user's email.

### Authorization

This endpoint is **unauthenticated**. No access token is required.

### Request Body

The request body must be in `application/json` format.

| Field   | Type   | Required | Description   | Constraints |
| ------- | ------ | -------- | ------------- | ----------- |
| `email` | string | Yes      | Email address | Valid email |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/resend-confirmation-code",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": "The verification code already sent to your email:jane.doe@acme.com"
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/initiate-set-password

Used for the user's initial authentication. Exchanges a temporary password for a new password and returns the authentication tokens. This is required when an account was created with a temporary password and login returns a `NEW_PASSWORD_REQUIRED` challenge.

### Authorization

This endpoint is **unauthenticated**. No access token is required (the temporary password is supplied in the body).

### Request Body

The request body must be in `application/json` format.

| Field                | Type   | Required | Description             | Constraints      |
| -------------------- | ------ | -------- | ----------------------- | ---------------- |
| `email`              | string | Yes      | Email address           | Valid email      |
| `temporary_password` | string | Yes      | The temporary password  | Min 3 characters |
| `new_password`       | string | Yes      | The new password to set | Min 3 characters |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com",
  "temporary_password": "Temp1234",
  "new_password": "S3curePass!"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/initiate-set-password",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": {
    "access_token": "eyJraWQiOiJ...",
    "refresh_token": "eyJjdHkiOiJ...",
    "id_token": "eyJraWQiOiJ...",
    "token_type": "Bearer",
    "expires_in": 3600
  }
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/login

Log in with email and password to obtain the `access_token`, `id_token`, and `refresh_token`. The `id_token` is the Bearer token used to authenticate the other user and application endpoints.

### Authorization

This endpoint is **unauthenticated**. No access token is required.

### Request Body

The request body must be in `application/json` format.

| Field      | Type   | Required | Description   | Constraints |
| ---------- | ------ | -------- | ------------- | ----------- |
| `email`    | string | Yes      | Email address | Valid email |
| `password` | string | Yes      | Password      |             |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com",
  "password": "S3curePass!"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/login",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": {
    "access_token": "eyJraWQiOiJ...",
    "refresh_token": "eyJjdHkiOiJ...",
    "id_token": "eyJraWQiOiJ...",
    "token_type": "bearer",
    "expires_in": 3600,
    "company_name": "Acme Compute"
  }
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#28A745', border: '2px solid #28A745', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>GET</span> /api/user/me

Get the current user's information using the `id_token`.

### Authorization

**🔒OAuth2**: OAuth2PasswordBearer\
**Flow type**: password\
**Token URL**: token

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/me",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": {
    "email": "jane.doe@acme.com",
    "first_name": "Jane",
    "last_name": "Doe",
    "company_name": "Acme Compute"
  }
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/forgot-password

Send a confirmation code to the user's email to begin a password reset.

### Authorization

This endpoint is **unauthenticated**. No access token is required.

### Request Body

The request body must be in `application/json` format.

| Field   | Type   | Required | Description   | Constraints |
| ------- | ------ | -------- | ------------- | ----------- |
| `email` | string | Yes      | Email address | Valid email |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/forgot-password",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": [
    "Password reset has been initiated, please check your email:jane.doe@acme.com for the confirmation code"
  ]
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#007BFF', border: '2px solid #007BFF', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>POST</span> /api/user/reset-password

Reset the password for the user using the confirmation code sent by `forgot-password`.

### Authorization

This endpoint is **unauthenticated**. No access token is required.

### Request Body

The request body must be in `application/json` format.

| Field               | Type   | Required | Description                         | Constraints |
| ------------------- | ------ | -------- | ----------------------------------- | ----------- |
| `email`             | string | Yes      | Email address                       | Valid email |
| `confirmation_code` | string | Yes      | The confirmation code sent by email |             |
| `new_password`      | string | Yes      | The new password to set             |             |

### Request Example

```json theme={null}
{
  "email": "jane.doe@acme.com",
  "confirmation_code": "123456",
  "new_password": "N3wSecurePass!"
}
```

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/reset-password",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": "Update your password successfully"
}
```

* **422**: Validation Error

```json theme={null}
{
  "detail": [
    {
      "loc": [
        "string"
        ],
        "msg": "string",
        "type": "string"
    }
  ]
}
```

***

## <span style={{ color: 'white', fontWeight: 'bold', backgroundColor: '#DC3545', border: '2px solid #DC3545', borderRadius: '5px', padding: '5px', display: 'inline-block' }}>DELETE</span> /api/user/delete-current-account

Delete the currently authenticated user's account. The user must have logged in successfully and supply a valid access token.

### Authorization

**🔒OAuth2**: OAuth2PasswordBearer\
**Flow type**: password\
**Token URL**: token

### Responses

* **200**: Successful Response

```json theme={null}
{
  "meta": {
    "code": 0,
    "url": "/api/user/delete-current-account",
    "message": "OK",
    "timestamp": 1744201871
  },
  "data": "Your account has been deleted."
}
```
