# User Management and Approvals

As a B2B customer, with Emporix you can easily manage your company data and your company users' data directly from your storefront.

## Company setup while registering as a customer

When a new customer registers at your storefront, all the registration data are automatically reflected in your Emporix account. This includes the company data, like address and contact information that your new customer provided during the registration. The most important piece of information is the customer's email address. By default, the customer is created with the admin role and becomes a primary contact for the company, if no other primary contact exists.

{% hint style="warning" %}
Make sure you add security measures in your implementation for creating new B2B customers on the storefront. For the showcase purposes, the new customer by default gets admin rights which for sure is not the desired behavior on your side.
{% endhint %}

## Creating users within the storefront

1. Log in to your storefront account and go to **My account** -> **Manage Users**.
2. To start creating a new user, choose **Create new user**.
3. Enter the user data, and choose the role for the user: you can select between Admin, Purchaser and Requester.
   * **Admin**: manages users, creates orders, approves orders from other users, who have the purchaser or material manager roles.
   * **Purchaser**: creates orders within the defined account threshold and can approve orders from material managers
   * **Requester**: creates order requests for purchaser or admin
4. Choose if the user should be activated or not.

After you create the new user, they receive an email notification to set the account password.

<figure><img src="/files/DF7trmZgxrCQ8fp3PeRJ" alt=""><figcaption></figcaption></figure>

All of the users' data is reflected and visible in the Emporix account in the backend system.

## B2B sign-up process

During the sign-up process, when the customer has a defined `b2b.companyRegistrationId` property, an additional validation takes place. The populated `b2b` property indicates that the registration process is for the B2B customers. The properties that are required for the B2B customers are:

* `firstName`
* `lastName`
* `company`

By default, a B2B customer is added to a legal entity matched by the name. If such a legal entity doesn’t exist, the company is created in the system, but only after an address is assigned to the newly created customer.

When the `Admin` customer creates a customer, the customer is automatically assigned to the legal entity of the `Admin` customer. When the customer is created for the B2B flow, then the default employee is informed about that by an email notification. The default employee is defined by the `default_employee` property.

## Approval requests flow

Having different user roles within a company helps in keeping the purchasing process in an ordered and transparent way. Anytime an order that is created has to be approved, the approval process starts.

{% hint style="danger" %}
To be able to set up such a workflow and properly resolve relevant access rights, you need to generate a **B2B token** that contains the legal entity information. The `refreshtoken` ensures that the authorization token contains the right legal entity details so that the services retrieve only the relevant information. To learn more about the B2B token, refer to the [B2B Token](/api-references/standard-practices/b2btoken.md) documentation.
{% endhint %}

### Requesting an approval

As a purchaser or material manager, you can create orders within the storefront and then request an approval. To request the approval, a user has to create a standard order first and then go through the standard checkout flow. During the checkout, the user can create an approval request for ordering the items in the cart.

<figure><img src="/files/LEilC72SCM0wagu9tXkv" alt=""><figcaption></figcaption></figure>

1. To start the approval process, choose the **Request approval** option.
2. Choose the person who should be an approver of the request and add any additional information if necessary. After that, use the **Submit** button to send the request.

<figure><img src="/files/Tac9fidjMxP2S6BM7316" alt=""><figcaption></figcaption></figure>

**Result**: After sending the approval request an email notification is sent to the approver. You can also see a confirmation message that the approval was requested. In your **Saved Carts** , you can check the status of your request.

<figure><img src="/files/1BGilcuvEUEGKS5Uu5xa" alt=""><figcaption></figcaption></figure>

### Approving the request

As an admin, you have the permission to approve the order requests that are sent by a purchaser or a material manager. When such a request is created, you get an email notification informing you about a pending approval.

1. To start working on the approval requests, go to the **Saved Carts** in your storefront account. Here, you can check the requests that are pending processing.
2. Choose the approval request to view the checkout details for the order.
3. Review the order, change the shipping information if needed, and decide if you approve or decline the request.
   * If you decide to approve, choose the **Confirm & Pay** button, this completed the checkout process.
   * If you decide not to approve, choose the **Decline Request** option. The requester receives information that the request was declined.

<figure><img src="/files/1LJA9VCwSR50y8x2md2n" alt=""><figcaption></figcaption></figure>


---

# 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://developer.emporix.io/ce/customer-use-cases/scenarios-introduction/right-roles.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.
