> For the complete documentation index, see [llms.txt](https://docs.enclaive.cloud/enclaive-multi-cloud-platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.enclaive.cloud/enclaive-multi-cloud-platform/developers/api/client-api/account.md).

# Account

In the "Account" section, endpoints for managing user accounts are described.

## Retrieve detailed user information.

<mark style="color:blue;">`GET`</mark> `{{BASE_URL}}/api/users/current`

Fetches comprehensive information about the currently authenticated user

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "_id": "6548a41138406c14db33b606",
    "email": "john.doe@mail.com",
    "name": "John Doe",
    "createdAt": "2023-11-06T08:30:09.166Z",
    "balance": 0,
    "status": 0,
    "emailVerified": true
}
```

{% endtab %}
{% endtabs %}

## Update user information

<mark style="color:orange;">`PUT`</mark> `{{BASE_URL}}/api/users/current`

Allows users to update their profile information, such as name, email, or other relevant details.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

#### Request Body

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| name        | String |             |
| oldPassword | String |             |
| newPassword | String |             |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "email": "john.doe@mail.com",
    "name": "John Doe",
    "createdAt": "2023-11-06T08:30:09.166Z",
    "_id": "6548a41138406c14db33b606"
}
```

{% endtab %}
{% endtabs %}

Once the user has been deactivated, access to the application will be blocked, but the user will be able to restore the account.

## Deactivate a user

<mark style="color:orange;">`PUT`</mark> `{{BASE_URL}}/api/users/current/deactivate`

Deactivates the user's account, rendering it inaccessible while retaining user data.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
{"message": "Account is deactivated"}
```

{% endtab %}
{% endtabs %}

## Retrieve all notifications for the user.

<mark style="color:blue;">`GET`</mark> `{{BASE_URL}}/api/users/current/notifications`

Retrieves all notifications and messages intended for the user.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
[
 {
  "messageType":"invite",
  "message": "You invited to join Dev team."
 }
]
```

{% endtab %}
{% endtabs %}

After registering, the customer must add the first payment method (default) for paying invoices. We use Stripe to manage payments. We freeze $1 from the customer to check that the card is active and there are funds, then we return that dollar and add that payment method to the user.

## Verify a user

<mark style="color:green;">`POST`</mark> `{{BASE_URL}}/api/users/current/verify-payment`

Confirms and validates a user's selected payment method for future transactions.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

#### Request Body

| Name          | Type   | Description              |
| ------------- | ------ | ------------------------ |
| paymentMethod | String | Stripe Payment method ID |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": "ok"
}
```

{% endtab %}
{% endtabs %}

## &#x20;Retrieve all payment methods added by the user.

<mark style="color:blue;">`GET`</mark> `{{BASE_URL}}/api/users/current/list-payment-methods`

Retrieves a list of all payment methods that the user has added to their account, providing an overview of available payment options for transactions and billing.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "object": "list",
    "data": [
        {
            "id": "pm_1O9OCiA0ZUrt0vQJ7GqrPclY",
            "object": "payment_method",
            "billing_details": {
                "address": {
                    "city": "Test",
                    "country": "DE",
                    "line1": "test",
                    "line2": "test",
                    "postal_code": "34334",
                    "state": "Test"
                },
                "email": "john.doe@mail.com",
                "name": "John Doe",
                "phone": null
            },
            "card": {
                "brand": "visa",
                "checks": {
                    "address_line1_check": "pass",
                    "address_postal_code_check": "pass",
                    "cvc_check": "pass"
                },
                "country": "US",
                "exp_month": 2,
                "exp_year": 2032,
                "fingerprint": "YxdxFzhKIAGEnLMN",
                "funding": "credit",
                "generated_from": null,
                "last4": "4242",
                "networks": {
                    "available": [
                        "visa"
                    ],
                    "preferred": null
                },
                "three_d_secure_usage": {
                    "supported": true
                },
                "wallet": null
            },
            "created": 1699259440,
            "customer": "cus_OxIokju2aarNVm",
            "livemode": false,
            "metadata": {},
            "type": "card"
        }
    ],
    "has_more": false,
    "url": "/v1/customers/cus_OxIokju2aarNVm/payment_methods"
}
```

{% endtab %}
{% endtabs %}

## Delete a payment method.

<mark style="color:red;">`DELETE`</mark> `{{BASE_URL}}/api/users/current/payment-method/{id}`

Deletes a specific payment method associated with the user's account.

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | String | Payment method ID |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="204: No Content " %}

```json
{}
```

{% endtab %}
{% endtabs %}

This enpoint is required to see detailed information about the user in Stripe.

## &#x20;Retrieve payment account information from Stripe.

<mark style="color:blue;">`GET`</mark> `{{BASE_URL}}/api/users/current/retrieve`

Retrieves relevant payment account details for the current user from the Stripe payment gateway.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "id": "cus_OxIokju2aarNVm",
    "object": "customer",
    "address": {
        "city": "Test",
        "country": "Afghanistan",
        "line1": "Test",
        "line2": "test1",
        "postal_code": "34334",
        "state": "Test"
    },
    "balance": 0,
    "created": 1699259424,
    "currency": "usd",
    "default_source": null,
    "delinquent": false,
    "description": null,
    "discount": null,
    "email": "john.doe@mail.com",
    "invoice_prefix": "B96FCFF5",
    "invoice_settings": {
        "custom_fields": null,
        "default_payment_method": "pm_1O9OCiA0ZUrt0vQJ7GqrPclY",
        "footer": null,
        "rendering_options": null
    },
    "livemode": false,
    "metadata": {},
    "name": "John Doe",
    "phone": null,
    "preferred_locales": [],
    "shipping": null,
    "tax_exempt": "none",
    "test_clock": null
}
```

{% endtab %}
{% endtabs %}
