# Create an account



import Image from 'next/image';

This article explains how to **create an account** in the Socotra Insurance Suite.

Key concepts [#key-concepts]

What is an account? [#what-is-an-account]

In Socotra, an **account** is a data object that represents a third-party entity (a person or a business) that is capable of being quoted for and being issued a policy for an insurance product.

Accounts associate individuals or businesses with the insurance products they’re covered by.

What is the process for creating an account? [#what-is-the-process-for-creating-an-account]

There are broadly three steps for creating an account:

| Step | Name     | Description                                                                                                                                                                                                                                                                                                                                                                                                                |
| ---- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1    | Create   | Once created, an account exists in a draft state. Accounts in a draft state aren’t finalized and can be updated without any restrictions.                                                                                                                                                                                                                                                                                  |
| 2    | Modify   | In a draft state, it’s possible to modify an account. You may want to do this if you want to change any information associated with the account or fix any errors (misspelled names, values that don’t meet field requirements, etc.).                                                                                                                                                                                     |
| 3    | Validate | The final stage of account creation is validation. Once validated, an account can be issued insurance policies. Accounts in a validated state cannot be updated as freely as those in a draft state. Any data provided must adhere to the account configuration, as well as any custom validation provided as part of the validation plugin. Also note that, once validated, an account can never return to a draft state. |

<Callout>
  You only need to validate an account when using the Socotra API. The web app validates the account automatically and raises any issues if validation fails.
</Callout>

API steps [#api-steps]

This section explains how to create an account using the Socotra API.

What will I need? [#what-will-i-need]

You will need the following:

* A Postman account
* [A copy of the Socotra Sample Collection and Environment](/getting-started/socotra-sample-postman-collection-and-environment)
* A workspace configured to use the Socotra API.

For more information about using Postman, see: [Set up Postman to use the Socotra API](/getting-started/set-up-postman-to-use-the-socotra-api).

<span id="create-an-account-1" />

Create an account [#create-an-account]

1. Log into your Postman account and navigate to your Socotra Sample Collection.
2. While viewing the Socotra Sample Collection, navigate to **Policy > Account > Create Account**.

<Image src="/images/create-an-account/sc-postman-create-account.png" alt="Screenshot showing the Create Account endpoint in Postman." width={1999} height={1254} unoptimized />

3. Click the **Body** tab.

<Image src="/images/create-an-account/sc-postman-body-tab.png" alt="Screenshot calling out the Body tab of the Create Account endpoint in Postman." width={1999} height={1254} unoptimized />

4. You should see a text editing field with some pre-populated JSON.

<Image src="/images/create-an-account/sc-postman-prepopulated-json.png" alt="Screenshot showing pre-populated text in the body of the endpoint." width={1999} height={1254} unoptimized />

In the request body, we specify the following:

* A `type` of `consumerAccount`
* A `data` object to contain the field information we want to provide, containing the following:
  * A `firstName` field to record the account holder’s first name.
  * A `lastName` field to record the account holder’s last name.
  * A `crmKey` field to record an API key for a CRM associated with the account holder. This field is optional, as defined in the data schema we saw in Socotra.

5. Provide the relevant data for the account holder. Or, if you just want to see how the request works, provide the default values to see the results.
6. Click **Send**.

If successful, the response message will look something like the screenshot below:

<Image src="/images/create-an-account/sc-postman-create-account-success.png" alt="Screenshot showing a successful response to the endpoint." width={1999} height={1254} unoptimized />

Let’s breakdown the response:

* `locator`: This contains the unique identifier of the account.
* `type`: This contains the type of the account, in this case consumerAccount.
* `state`: This contains the account state. We can see that it’s a draft and has not yet been validated.
* `data`: This contains the data provided in the request body.
* `billingLevel`: This contains the billing level, which determines how the account is billed for its products.

Continue on to Part 2 to learn how to make modifications to the account.

Update an account [#update-an-account]

Once created, an account exists in a draft state. Before we validate the draft, let’s cover how to make changes to it.

If you look in the Postman collection under **Policy > Account**, you’ll see two endpoints labeled as **Update Account**.

<Image src="/images/create-an-account/sc-postman-update-account.png" alt="Screenshot showing the Update Account endpoints in Postman." width={1999} height={1254} unoptimized />

* Update Account (add), with method PATCH
* Update Account (replace), with method PUT

These endpoints achieve similar goals, but the difference is that the PATCH Update Account (add) endpoint adds data to an existing record, while the PUT Update Account (replace) endpoint replaces all of the data of an existing record with what’s provided in the request body.

For this tutorial, we’ll focus on using PATCH Update Account (add) to make partial changes to the account.

**Note**: Remember to update the accountLocator environment variable with the locator of the account you want to modify.

This endpoint modifies an account record by adding data to the existing record. Use this when you want to make a partial change to an account.

Let’s breakdown the request body of this endpoint:

<Image src="/images/create-an-account/sc-postman-update-account-breakdown.png" alt="Screenshot of the request body of the endpoint." width={1999} height={1254} unoptimized />

* The body contains an object called `setData`. This will contain the new data that we want the endpoint to use when updating the account.
  * `firstName`: This contains the new value for the firstName field.
  * `crmKey`: This contains the new value for the crmKey field.

After clicking **Send** to send the request, it should return the following response message upon success:

<Image src="/images/create-an-account/sc-postman-update-account-response.png" alt="Screenshot of the response body of the endpoint." width={1999} height={1254} unoptimized />

Note the updated values in the `firstName` and `crmKey` fields.

Validate an account [#validate-an-account]

Now that you’ve created an account and successfully updated it, the next step is to validate it.

1. While viewing the Socotra Sample Collection, navigate to **Policy > Account > Validate Account**.
2. Make sure that the locator for the account is either input in the accountLocator environment variable.
3. Click **Send**.
4. The response body should show that the request was successful.

<Image src="/images/create-an-account/sc-postman-validate-account.png" alt="Screenshot of account validation in Postman." width={1999} height={1254} unoptimized />

Web app steps [#web-app-steps]

This section explains how to create an account using the Socotra web app.

1. Log into the Socotra web app. For more information, see: [Log into Socotra](/getting-started/log-into-socotra).
2. Click **Operations**.

<Image src="/images/create-an-account/sc-web-operations.png" alt="Screenshot of the Operations button." width={3248} height={2048} unoptimized />

3. Select the tenant you'd like to add an account to.

<Image src="/images/create-an-account/sc-web-example-tenant.png" alt="Screenshot of the tenant selection page." width={3248} height={2048} unoptimized />

4. Click **Accounts**.

<Image src="/images/create-an-account/sc-web-accounts.png" alt="Screenshot of the tenant page." width={3248} height={2048} unoptimized />

5. Click **Add New Account**. You can choose what kind of account to make. This depends on what accounts are configured in your tenant configuration. In this example, there are two options: Commercial Account and Consumer Account.

<Image src="/images/create-an-account/sc-web-add-new-account.png" alt="Screenshot of the Add New Account button." width={3248} height={2048} unoptimized />

6. Fill out the account details.

<Image src="/images/create-an-account/sc-web-new-account-details.png" alt="Screenshot of the Account Details page." width={3248} height={2048} unoptimized />

7. Click **Create**.

Recap [#recap]

In this tutorial, we covered:

* How to create an account using the Socotra API.
* How to update an account using the Socotra API.
* How to validate an account using the Socotra API.
* How to create an account using the Socotra web app.

Now that we have an who can be issued a quote, the next question is: How does Socotra issue quotes? Continue on to the next learning module to learn more.

Ready for the next module? [#ready-for-the-next-module]

See [Execute a quote to bind](/getting-started/execute-a-quote-to-bind) to continue this learning path.
