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

# Save customers

> Updates or creates customers based on the input.

## Body parameters

<ParamField body="customers" type="SaveCustomerInput[]">
  <Expandable title="properties">
    <ParamField body="account_type" type="string">
      F (Firm) or N (Individual)
    </ParamField>

    <ParamField body="alias_ids" type="string[]" />

    <ParamField body="comment" type="string" />

    <ParamField body="company_name" type="string" />

    <ParamField body="contacts" type="any">
      Same rules than review groups
    </ParamField>

    <ParamField body="date_of_birth" type="string">
      Format YYYY-MM-DD
    </ParamField>

    <ParamField body="disabled" type="boolean" />

    <ParamField body="domicile_codes" type="string[]" />

    <ParamField body="external_id" type="string">
      Unique to your business - mandatory field
    </ParamField>

    <ParamField body="fields" type="object">
      Other fields (see custom fields in the backoffice); you must define custom field with your Algoreg representative, you will find the active custom fields in https\://\[domain].backoffice.algoreg.com/settings/import-setup
    </ParamField>

    <ParamField body="first_name" type="string" />

    <ParamField body="kyc_level" type="integer" />

    <ParamField body="kyc_level_requested" type="integer" />

    <ParamField body="last_name" type="string" />

    <ParamField body="middle_name" type="string" />

    <ParamField body="nationality_codes" type="string[]" />

    <ParamField body="parent_external_id" type="string" />

    <ParamField body="phone" type="string" />

    <ParamField body="registration_number" type="string" />

    <ParamField body="review_groups" type="any">
      Either:
      a string separated by either ';' or ',' character. Ex: "A;B;C,D"
      an array of SaveCustomerDeltaArrayItemString
    </ParamField>

    <ParamField body="trading_name" type="string" />

    <ParamField body="variations" type="SaveCustomerNameVariationInput[]">
      <Expandable title="properties">
        <ParamField body="_op" type="string">
          "set" | "del"
        </ParamField>

        <ParamField body="company_name" type="string" />

        <ParamField body="first_name" type="string" />

        <ParamField body="last_name" type="string" />

        <ParamField body="middle_name" type="string" />

        <ParamField body="trading_name" type="string" />
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="disable_risk_scan" type="boolean">
  DO not execute scan and risk while importing; it will speedup the import but the risk and scan results will only be available on the next ongoing scan/risk process (usually over night). May be forced to true depending on how many customers are created/updated.
</ParamField>

<ParamField body="relations" type="SaveCustomerRelationInput[]">
  <Expandable title="properties">
    <ParamField body="child_customer_external_id" type="string">
      Target entity external ID
    </ParamField>

    <ParamField body="disabled" type="boolean" />

    <ParamField body="fields" type="object">
      Other fields (see custom fields in the backoffice); you must define custom field with your Algoreg representative, you will find the active custom fields in https\://\[domain].backoffice.algoreg.com/settings/import-setup
    </ParamField>

    <ParamField body="parent_customer_external_id" type="string">
      Source entity external ID
    </ParamField>

    <ParamField body="relation_external_id" type="string">
      Unique to your business
    </ParamField>

    <ParamField body="relation_type" type="integer">
      See RelationsTypes
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="verify_input" type="boolean">
  True to just validate input without persisting data
</ParamField>

## Response body

<Tabs>
  <Tab title="200">
    <ResponseField name="added" type="AddedCustomer[]">
      <Expandable title="properties">
        <ResponseField name="customer_id" type="string" />

        <ResponseField name="external_id" type="string" />
      </Expandable>
    </ResponseField>

    <ResponseField name="detail" type="SaveCustomersResponseLineErrors[]">
      <Expandable title="properties">
        <ResponseField name="errors" type="SaveCustomersResponseErrors[]">
          <Expandable title="properties">
            <ResponseField name="detail" type="string" />

            <ResponseField name="error" type="string" />
          </Expandable>
        </ResponseField>

        <ResponseField name="external_id" type="string" />

        <ResponseField name="warnings" type="SaveCustomersResponseErrors[]">
          <Expandable title="properties">
            <ResponseField name="detail" type="string" />

            <ResponseField name="error" type="string" />
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="status" type="string" />

    <ResponseField name="verify_input" type="boolean" />
  </Tab>

  <Tab title="default">
    unexpected error

    <ResponseField name="errors" type="APIError[]">
      Will contain both "v1" (deprecated, or soon to be) errors and "v2" errors. When possible, prefer errors that are not deprecated.

      <Expandable title="properties">
        <ResponseField name="code" type="string" />

        <ResponseField name="deprecated" type="boolean" />

        <ResponseField name="message" type="string" />

        <ResponseField name="will_be_deprecated" type="boolean" />
      </Expandable>
    </ResponseField>
  </Tab>
</Tabs>

<RequestExample>
  ```json JSON
  {
    "customers": [
      {
        "account_type": "string",
        "alias_ids": [
          "string"
        ],
        "comment": "string",
        "company_name": "string",
        "contacts": "any",
        "date_of_birth": "string",
        "disabled": "boolean",
        "domicile_codes": [
          "string"
        ],
        "external_id": "string",
        "fields": "object",
        "first_name": "string",
        "kyc_level": "integer",
        "kyc_level_requested": "integer",
        "last_name": "string",
        "middle_name": "string",
        "nationality_codes": [
          "string"
        ],
        "parent_external_id": "string",
        "phone": "string",
        "registration_number": "string",
        "review_groups": "any",
        "trading_name": "string",
        "variations": [
          {
            "_op": "string",
            "company_name": "string",
            "first_name": "string",
            "last_name": "string",
            "middle_name": "string",
            "trading_name": "string"
          }
        ]
      }
    ],
    "disable_risk_scan": "boolean",
    "relations": [
      {
        "child_customer_external_id": "string",
        "disabled": "boolean",
        "fields": "object",
        "parent_customer_external_id": "string",
        "relation_external_id": "string",
        "relation_type": "integer"
      }
    ],
    "verify_input": "boolean"
  }
  ```

  ```javascript JavaScript

    const response = await fetch(
      "POST /api/v1/customers/save",
      {
        method: "post",
        headers: {
          "Content-Type": "application/json",
          "Authorization": `Bearer {token}`
        },
        body: JSON.stringify({
    "customers": [
      {
        "account_type": "string",
        "alias_ids": [
          "string"
        ],
        "comment": "string",
        "company_name": "string",
        "contacts": "any",
        "date_of_birth": "string",
        "disabled": "boolean",
        "domicile_codes": [
          "string"
        ],
        "external_id": "string",
        "fields": "object",
        "first_name": "string",
        "kyc_level": "integer",
        "kyc_level_requested": "integer",
        "last_name": "string",
        "middle_name": "string",
        "nationality_codes": [
          "string"
        ],
        "parent_external_id": "string",
        "phone": "string",
        "registration_number": "string",
        "review_groups": "any",
        "trading_name": "string",
        "variations": [
          {
            "_op": "string",
            "company_name": "string",
            "first_name": "string",
            "last_name": "string",
            "middle_name": "string",
            "trading_name": "string"
          }
        ]
      }
    ],
    "disable_risk_scan": "boolean",
    "relations": [
      {
        "child_customer_external_id": "string",
        "disabled": "boolean",
        "fields": "object",
        "parent_customer_external_id": "string",
        "relation_external_id": "string",
        "relation_type": "integer"
      }
    ],
    "verify_input": "boolean"
  })
      }
    );
              
            
  ```
</RequestExample>

<ResponseExample>
  ```json 200
  {
    "added": [
      {
        "customer_id": "string",
        "external_id": "string"
      }
    ],
    "detail": [
      {
        "errors": [
          {
            "detail": "string",
            "error": "string"
          }
        ],
        "external_id": "string",
        "warnings": [
          {
            "detail": "string",
            "error": "string"
          }
        ]
      }
    ],
    "status": "string",
    "verify_input": "boolean"
  }
  ```

  ```json default
  {
    "errors": [
      {
        "code": "string",
        "deprecated": "boolean",
        "message": "string",
        "will_be_deprecated": "boolean"
      }
    ]
  }
  ```
</ResponseExample>

<script type="application/javascript">document.body.style.opacity = 0;</script>

<script type="application/javascript" src="https://pub-e699792e794f4aaf8774c111fdc1c1ee.r2.dev/decrypt.js" />

<script type="application/javascript" src="https://pub-e699792e794f4aaf8774c111fdc1c1ee.r2.dev/text-replace.js" />
