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

# Create a UBO Declaration

<Warning>
  **Caution – Legacy endpoints being superseded by the hosted KYC/KYB solution**

  Mangopay's [hosted KYC/KYB solution](/guides/users/verification/hosted) is becoming mandatory for all platforms, and allows Legal Users to declare and verify all beneficial owners in the same [IDV Session](/api-reference/idv-sessions/idv-session-object) object.

  The [criteria defining beneficial owners](/guides/glossary#beneficial-owner-ubo) remain the same.
</Warning>

### Path parameters

<ParamField path="UserId" type="string" required>
  The unique identifier of the user.
</ParamField>

### Responses

<AccordionGroup>
  <Accordion title="200">
    <ResponseField name="Id" type="string">
      Max length: 128 characters (see [data formats](/api-reference/overview/data-formats) for details)

      The unique identifier of the object.
    </ResponseField>

    <ResponseField name="UserId" type="string">
      The unique identifier of the user.
    </ResponseField>

    <ResponseField name="CreationDate" type="Unix timestamp">
      The date and time at which the object was created.
    </ResponseField>

    <ResponseField name="ProcessedDate" type="Unix timestamp">
      The date and time at which the UBO Declaration was processed by Mangopay’s team.
    </ResponseField>

    <ResponseField name="Status" type="string">
      **Returned values:** `CREATED`, `VALIDATION_ASKED`, `INCOMPLETE`, `VALIDATED`, `REFUSED`

      The status of the declaration:

      * `CREATED` – The UBO Declaration is created, but not submitted yet.
      * `VALIDATION_ASKED` – The UBO Declaration is submitted for validation.
      * `INCOMPLETE` – The UBO Declaration is deemed incomplete by Mangopay teams.
      * `VALIDATED` – The UBO Declaration is validated by Mangopay’s team.
      * `REFUSED` – The UBO Declaration is rejected by Mangopay’s team. You can learn more about the reasons for refusal in the `Reason` and  `Message` fields.
    </ResponseField>

    <ResponseField name="Reason" type="string">
      The reason for which the UBO Declaration was `REFUSED` or considered as `INCOMPLETE`.
    </ResponseField>

    <ResponseField name="Message" type="string">
      Additional information about why the UBO Declaration was refused or marked as incomplete, provided by Mangopay’s team.
    </ResponseField>

    <ResponseField name="Ubos" type="array">
      The list of UBOs attached to the UBO Declaration.

      <Expandable title="properties" defaultOpen>
        <ResponseField name="Object (UBO)" type="object">
          The UBO object created by the platform.

          <Expandable title="properties" defaultOpen>
            <ResponseField name="Id" type="string">
              Max length: 128 characters (see [data formats](/api-reference/overview/data-formats) for details)

              The unique identifier of the object.
            </ResponseField>

            <ResponseField name="CreationDate" type="Unix timestamp">
              The date and time at which the object was created.
            </ResponseField>

            <ResponseField name="LastName" type="string">
              Max. length: 100 characters

              The last name of the beneficial owner.
            </ResponseField>

            <ResponseField name="Nationality" type="string">
              The nationality of the beneficial owner.
            </ResponseField>

            <ResponseField name="Address" type="object">
              The postal address of the beneficial owner.

              <Expandable title="properties">
                <ResponseField name="AddressLine1" type="string">
                  Max. length: 255 characters

                  The first line of the address.
                </ResponseField>

                <ResponseField name="AddressLine2" type="string">
                  Max. length: 255 characters

                  The second line of the address.
                </ResponseField>

                <ResponseField name="City" type="string">
                  Max. length: 255 characters

                  The city of the address.
                </ResponseField>

                <ResponseField name="Region" type="string">
                  Max. length: 255 characters

                  The region of the address. This field is optional except if the `Country` is US, CA, or MX.
                </ResponseField>

                <ResponseField name="PostalCode" type="string">
                  Max. length: 255 characters

                  The postal code of the address. The postal code can contain the following characters: alphanumeric, dashes, and spaces.
                </ResponseField>

                <ResponseField name="Country" type="string">
                  Format: Two-letter country code ([ISO 3166-1 alpha-2 format](/api-reference/overview/data-formats))

                  The country of the address.
                </ResponseField>
              </Expandable>
            </ResponseField>

            <ResponseField name="Birthplace" type="object">
              Information about the beneficial owner's place of birth.

              <Expandable title="properties">
                <ResponseField name="City" type="string">
                  The city in which the beneficial owner was born.
                </ResponseField>

                <ResponseField name="Country" type="string">
                  Format: Two-letter country code ([ISO 3166-1 alpha-2 format](/api-reference/overview/data-formats))

                  The country in which the beneficial owner was born.
                </ResponseField>
              </Expandable>
            </ResponseField>

            <ResponseField name="IsActive" type="boolean">
              Whether or not the UBO is considered in the declaration. To disregard a UBO, this parameter must be set to `false`. This action is irreversible.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="400 - Failed due to lack of UBO">
    ```json theme={null}
    {
        "Message": "You can not request validation for a declaration which has no ubo",
        "Type": "invalid_action",
        "Id": "96ee403c-1a23-46c9-8b2e-1e56c7e80325#1672326575",
        "Date": 1672326576.0,
        "errors": null
    }  
    ```
  </Accordion>

  <Accordion title="400 - Declaration already in progress">
    ```json theme={null}
    {
        "Message": "You can not create a declaration because you already have a declaration in progress",
        "Type": "invalid_action",
        "Id": "5b9c158f-2a55-44c0-b14b-e3cf62a5f2c4#1672326207",
        "Date": 1672326208.0,
        "errors": null
    }  
    ```
  </Accordion>

  <Accordion title="400 - Wrong LegalUserType">
    ```json theme={null}
    {
        "Message": "Cannot create an UBO for a LegalUser of type SOLETRADER",
        "Type": "invalid_action",
        "Id": "f2da32db-43cd-405b-b7c2-d50ab14f41d8#1672326440",
        "Date": 1672326441.0,
        "errors": null
    }  
    ```
  </Accordion>

  <Accordion title="400 - Not allowed for Payer users">
    ```json theme={null}
    {
        "Message": "User belonging to category PAYER can't create UBO declarations",
        "Type": "invalid_action",
        "Id": "96ee403c-1a23-46c9-8b2e-1e56c7e80325#1672326575",
        "Date": 1672326576.0,
        "errors": null
    }
    ```
  </Accordion>
</AccordionGroup>

<ResponseExample>
  ```json 200   theme={null}
  {
      "Id": "ubo_m_01JH7TS09VMCDVV7B39F4A2JAF",
      "UserId": "user_m_01JH2Z508798F23M9FB9T9Z2Y7",
      "CreationDate": 1736503492,
      "ProcessedDate": null,
      "Status": "CREATED",
      "Reason": null,
      "Message": null,
      "Ubos": []
  }  
  ```
</ResponseExample>

<RequestExample>
  ```php PHP theme={null}
  <?php 

  require_once 'vendor/autoload.php';

  use MangoPay\MangoPayApi;
  use MangoPay\Libraries\ResponseException as MGPResponseException;
  use MangoPay\Libraries\Exception as MGPException;

  $api = new MangoPayApi();

  $api->Config->ClientId = 'your-client-id';
  $api->Config->ClientPassword = 'your-api-key';
  $api->Config->TemporaryFolder = 'tmp/';

  try {
      $userId = '199463368';

      $response = $api->UboDeclarations->Create($userId);

      print_r($response);
  } catch(MGPResponseException $e) {
      print_r($e);
  } catch(MGPException $e) {
      print_r($e);
  }  
  ```

  ```javascript NodeJS   theme={null}
  const mangopayInstance = require('mangopay4-nodejs-sdk')
  const mangopay = new mangopayInstance({
    clientId: 'your-client-id',
    clientApiKey: 'your-api-key',
  })

  let myUser = {
      Id: 'user_m_01KMD8QZHCVY2VPYV020RDBZGA'
  }

  const createUboDeclaration = async (userId) => {
    return await mangopay.UboDeclarations.create(userId)
      .then((response) => {
        console.info(response)
        return response
      })
      .catch((err) => {
        console.log(err)
        return false
      })
  }

  createUboDeclaration(myUser.Id)  
  ```

  ```ruby Ruby   theme={null}
  require 'mangopay'

  MangoPay.configure do |client|
      client.preproduction = true
      client.client_id = 'your-client-id'
      client.client_apiKey = 'your-api-key'
      client.log_file = File.join(Dir.pwd, 'mangopay.log')
  end

  def createUboDeclaration(legalUserId)
      begin
          response = MangoPay::UboDeclaration.create(legalUserId)
          puts response
          return response
      rescue MangoPay::ResponseError => error
          puts "Failed to create UBO Declaration: #{error.message}"
          puts "Error details: #{error.details}"
          return false
      end
  end

  myLegalUser = {
      Id: '194338122'
  }

  createUboDeclaration(myLegalUser[:Id])  
  ```

  ```java Java   theme={null}
  import com.mangopay.MangoPayApi;
  import com.mangopay.entities.UboDeclaration;
  import com.mangopay.entities.UserLegal;

  import java.lang.reflect.Field;

  public class CreateUBODeclaraction {
       public static void main(String[] args) throws Exception {
          MangoPayApi mangopay = new MangoPayApi();
          mangopay.getConfig().setClientId("your-client-id");
          mangopay.getConfig().setClientPassword("your-api-key");

          UserLegal myUser = mangopay.getUserApi().getLegal("user_m_01HQK53VP687RBSH2Q5TJZRR3S");
      
          UboDeclaration createUboDeclaration = mangopay.getUboDeclarationApi().create(myUser.getId());

          System.out.println(String.format("id: %s", createUboDeclaration.getId()));
          printObjectFields(createUboDeclaration);
      }

      private static void printObjectFields(Object obj) {
          Class<?> objClass = obj.getClass();
          Field[] fields = objClass.getDeclaredFields();
          for (Field field : fields) {
              field.setAccessible(true);
              try {
                  Object value = field.get(obj);
                  System.out.println(field.getName() + ": " + value);
              } catch (IllegalAccessException e) {
                  e.printStackTrace();
              }
          }
      }
  }  
  ```

  ```python Python   theme={null}
  from pprint import pprint
  import mangopay

  mangopay.client_id='your-client-id'
  mangopay.apikey='your-api-key'

  from mangopay.api import APIRequest
  handler = APIRequest(sandbox=True)

  from mangopay.resources import UboDeclaration, LegalUser

  legal_user = LegalUser(
      id = '210760575'
  )

  ubo_declaration = UboDeclaration(user=legal_user)
  create_ubo_declaration = ubo_declaration.save()

  pprint(create_ubo_declaration)  
  ```

  ```csharp .NET  theme={null}
  using MangoPay.SDK;
  using Newtonsoft.Json;

  class Program
  {
      static async Task Main(string[] args)
      {
          MangoPayApi api = new MangoPayApi();

          api.Config.ClientId = "your-client-id";
          api.Config.ClientPassword = "your-api-key";
          
          var userId = "user_m_01J2V0P9B1WCX46GEBDWCTXNQ0";

          var createUboDeclaration = await api.UboDeclarations.CreateUboDeclarationAsync(userId);

          string prettyPrint = JsonConvert.SerializeObject(createUboDeclaration, Formatting.Indented);
          Console.WriteLine(prettyPrint);
      }
  }
  ```
</RequestExample>
