> ## 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 Wallet

<Check>
  **Best practice – Create one wallet per user and currency**

  While Mangopay authorizes you to create as many wallets as required, we recommend you create one wallet per user and currency.
</Check>

<Warning>
  **Caution – Currency not updatable**

  The `Currency` of a created wallet cannot be changed.
</Warning>

### Body parameters

<ParamField body="Description" type="string" required>
  Max. length: 255 characters

  The description of the wallet. It can be a name, the type, or anything else that can help you clearly identify the wallet on the platform (and for your end users).
</ParamField>

<ParamField body="Owners" type="array" required>
  string

  The unique identifier of the user owning the wallet.

  **Note:** Only one owner can be defined; this array accepts only one string.
</ParamField>

<ParamField body="Currency" type="string" required>
  **Allowed values:** The three-letter <a href="/api-reference/overview/data-formats" target="_blank">ISO 4217 code</a> (EUR, GBP, etc) of a <a href="/guides/currencies" target="_blank">supported currency</a> (depends on feature, contract, and activation settings).

  The currency of the wallet.
</ParamField>

<ParamField body="Tag" type="string">
  Max. length: 255 characters

  Custom data that you can add to this object.\
  For wallets, you can use this parameter to identify the corresponding end user in your platform.
</ParamField>

### Responses

<AccordionGroup>
  <Accordion title="200">
    <ResponseField name="Description" type="string">
      Max. length: 255 characters

      The description of the wallet. It can be a name, the type, or anything else that can help you clearly identify the wallet on the platform (and for your end users).
    </ResponseField>

    <ResponseField name="Owners" type="array">
      string

      The unique identifier of the user owning the wallet.

      **Note:** Only one owner can be defined; this array accepts only one string.
    </ResponseField>

    <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="Balance" type="object">
      The current balance of the wallet.

      <Expandable title="properties">
        <ResponseField name="Currency" type="string">
          **Returned values:** The three-letter <a href="/api-reference/overview/data-formats" target="_blank">ISO 4217 code</a> (EUR, GBP, etc.) of a <a href="/guides/currencies" target="_blank">supported currency</a> (depends on feature, contract, and activation settings).

          The currency of the balance.
        </ResponseField>

        <ResponseField name="Amount" type="integer">
          An amount of money in the smallest sub-division of the currency (e.g., EUR 12.60 would be represented as `1260` whereas JPY 12 would be represented as just `12`).
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="Currency" type="string">
      **Returned values:** The three-letter <a href="/api-reference/overview/data-formats" target="_blank">ISO 4217 code</a> (EUR, GBP, etc.) of a <a href="/guides/currencies" target="_blank">supported currency</a> (depends on feature, contract, and activation settings).

      The currency of the wallet.
    </ResponseField>

    <ResponseField name="FundsType" type="string">
      **Returned values:** `DEFAULT`, `FEES`, `CREDIT`

      The type of funds in the wallet:

      * `DEFAULT` – Regular funds for user-owned wallets. Wallets with this `FundsType` cannot have a negative balance.
      * `FEES` – Fees Wallet, for fees collected by the platform, specific to the Client Wallet object.
      * `CREDIT` – Repudiation Wallet, for funds for the platform's dispute management, specific to the Client Wallet object.

      **Note:** The Fees Wallet and Repudiation Wallet are created automatically by Mangopay for each currency.
    </ResponseField>

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

      Custom data that you can add to this object.\
      For wallets, you can use this parameter to identify the corresponding end user in your platform.
    </ResponseField>

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

<AccordionGroup>
  <Accordion title="400 - Limited to one owner per wallet">
    ```json theme={null}
    {
        "Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
        "Type": "param_error",
        "Id": "c09ebc81-24d6-47ef-8cef-d491209faee8",
        "Date": 1702037849.0,
        "errors": {
            "Owners": "Owners doesn't support multiple values for the moment"
        }
    }  
    ```
  </Accordion>

  <Accordion title="400 - Currency not supported">
    ```json theme={null}
    {
        "Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
        "Type": "param_error",
        "Id": "d3370a5b-af3c-4b99-9e6e-6c7dea052e19",
        "Date": 1690284549.0,
        "errors": {
            "Currency": "Currency: The currency AZN is not available"
        }
    }  
    ```
  </Accordion>

  <Accordion title="403 - User's UserStatus is CLOSED">
    ```json theme={null}
    {
        "Message": "User closed: No action can be performed",
        "Type": "user_closed",
        "Id": "10cdfa86-e743-4d0e-8172-9de82128e1d2#1779272906",
        "Date": 1779272907,
        "errors": null
    }
    ```
  </Accordion>
</AccordionGroup>

<ResponseExample>
  ```json 200   theme={null}
  {
      "Description": "Description of the user's wallet",
      "Owners": [
          "user_m_01J18HZSACR1EMYNY1TBS8KTJD"
      ],
      "Id": "wlt_m_01J6EN9X1Q0PGM0CJ9QD197CRG",
      "Balance": {
          "Currency": "EUR",
          "Amount": 0
      },
      "Currency": "EUR",
      "FundsType": "DEFAULT",
      "Tag": "Created using Mangopay API Postman Collection",
      "CreationDate": 1724921476
  }
  ```
</ResponseExample>

<RequestExample>
  ```json REST   theme={null}
  {
      "Description": "Description of the user's wallet",
      "Owners": [
          "user_m_01J18HZSACR1EMYNY1TBS8KTJD"
      ],
      "Currency": "EUR",
      "Tag": "Created using Mangopay API Postman Collection",
  }  
  ```

  ```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 {
      
      $wallet = new \MangoPay\Wallet();

      $wallet->Owners = ['198675238'];
      $wallet->Currency = 'EUR';
      $wallet->Description = 'EUR Wallet';
      $wallet->Tag = 'Created with Mangopay PHP SDK';

      $response = $api->Wallets->Create($wallet);

      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 userId = '165863393'

  let wallet = {
      Owners: [userId],
      Currency: 'EUR',
      Description: 'Wallet in EUR',
      Tag: 'Created using Mangopay NodeJS SDK'
  }

  const createWallet = async (walletObject) => {
    return await mangopay.Wallets.create(wallet)
      .then((response) => {
        console.info(response)
        return response
      })
      .catch((err) => {
        console.log(err)
        return false
      })
  }

  createWallet(wallet)  
  ```

  ```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 createWallet(walletObject)
      begin
          response = MangoPay::Wallet.create(walletObject)
          puts response
          return response
      rescue MangoPay::ResponseError => error
          puts "Failed to create wallet: #{error.message}"
          puts "Error details: #{error.details}"
          return false
      end
  end

  myUser = {
    Id: '146476890',
  }

  myWallet = {
      Owners: [myUser[:Id]],
      Currency: 'EUR',
      Description: 'Wallet in EUR',
      Tag: 'Created using Mangopay Ruby SDK'
  }

  createWallet(myWallet)  
  ```

  ```java Java   theme={null}
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.mangopay.MangoPayApi;
  import com.mangopay.core.Money;
  import com.mangopay.core.enumerations.CurrencyIso;
  import com.mangopay.entities.Wallet;

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

          ArrayList<String> owner = new ArrayList<String>();
          owner.add("user_m_01HSAVT2J0REPGV5ZRPNK079K9");
          Wallet wallet = new Wallet();

          wallet.setOwners(owner);
          wallet.setCurrency(CurrencyIso.EUR);
          wallet.setDescription("EUR Wallet");
          wallet.setTag("Created using the Mangopay Java SDK"); 

          Wallet createWallet = mangopay.getWalletApi().create(wallet);
          
          Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
          String prettyJson = prettyPrint.toJson(updateUbo);

          System.out.println(createWallet);
      }
  }
  ```

  ```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 NaturalUser, Wallet

  natural_user = NaturalUser.get('213753890')

  user_wallet = Wallet(
      owners=[natural_user],
      description='Wallet of Rhoda Keeling',
      currency='EUR',
      tag="Created using the Mangopay Python SDK"
  )

  create_wallet = user_wallet.save()

  pprint(create_wallet)  
  ```

  ```csharp .NET  theme={null}
  using MangoPay.SDK;
  using MangoPay.SDK.Core.Enumerations;
  using MangoPay.SDK.Entities.POST;
  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_01J2TZ261WZNDM0ZDRWGDYA4GN";

          var wallet = new WalletPostDTO(
              [userId],
              "Wallet in GBP",
              CurrencyIso.GBP
          );

          var createWallet = await api.Wallets.CreateAsync(wallet);

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