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

# Approvisionnement de compte

<Note>
  Cette documentation a été mise à jour le **07/11/23**.
</Note>

## Introduction

Le provisioning est un type de transaction qui permet de transferer des fonds depuis le compte de collecte (PAY-IN account) vers le compte de transfert (PAY-OUT account) du même marchand.

<Tip>
  Cette action est soumise à validation et approbation par les administrateurs  de la plateforme.
  Cependant en dessous d'un certain montant, la plateforme peut décider de l'approuver automatiquement.
  Veuillez vous rapprocher de l'équipe support pour plus d'informations sur les conditions d'approvisionnement.
</Tip>

## Créer un approvisionnement

<CodeGroup>
  ```bash Curl theme={null}
  curl --location --request POST 'https://api.hub2.io/provisionings' \
  --header 'ApiKey: [REDACTED]' \
  --header 'MerchantId: [REDACTED]' \
  --header 'Environment: sandbox' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "amount": 200,
      "currency": "XOF",
      "description": "TEST APPRO",
  }'
  ```

  ```typescript Typescript theme={null}
  const headers = {
      'ApiKey': '[REDACTED]',
      'MerchantId': '[REDACTED]',
      'Environment': 'sandbox',
      'Content-Type': 'application/json',
  }

  const data = {
      amount: 200,
      currency: "XOF",
      description: "TEST APPRO",
  }

  fetch('https://api.hub2.io/provisionings', {
      method: 'POST',
      headers: headers,
      body: JSON.stringify(data)
  })
  .then(response => response.json())
  .then(data => console.log(data))
  .catch((error) => console.error('Error:', error));
  ```

  ```python Python theme={null}
  import requests

  headers = {
      'ApiKey': '[REDACTED]',
      'MerchantId': '[REDACTED]',
      'Environment': 'sandbox',
      'Content-Type': 'application/json',
  }

  data = {
      "amount": 200,
      "currency": "XOF",
      "description": "TEST APPRO",
  }

  response = requests.post('https://api.hub2.io/provisionings', headers=headers, json=data)

  print(response.json())
  ```
</CodeGroup>

La réponse à cette commande est une action qui a été créée et est en attente d'approbation.

```json theme={null}
{
    "id": 32,
    "action": "provisioning",
    "status": "created",
    "authorId": "apiKey",
    "merchantId": "[REDACTED]",
    "params": {
        "amount": 200,
        "currency": "XOF",
        "description": "TEST APPRO",
        "mode": "sandbox"
    },
    "createdAt": "2023-11-07T11:21:19.561Z",
    "updatedAt": "2023-11-07T11:21:19.561Z"
}
```

Une fois que l'action aura été approuvée, la transaction correspondante pourra être consultée depuis la route qui permet d'avoir la liste des approvisionnements ou depuis le dashboard.

## Récuperer les approvisionnements

<CodeGroup>
  ```bash Curl theme={null}
  curl --location --request GET 'https://api.hub2.io/provisionings' \
  --header 'ApiKey: [REDACTED]' \
  --header 'MerchantId: [REDACTED]' \
  --header 'Environment: sandbox' \
  --header 'Content-Type: application/json'
  ```

  ```typescript Typescript theme={null}
  import fetch from 'node-fetch';

  const url = 'https://api.hub2.io/provisionings';
  const headers = {
      'ApiKey': '[REDACTED]',
      'MerchantId': '[REDACTED]',
      'Environment': 'sandbox',
      'Content-Type': 'application/json'
  };

  fetch(url, { method: 'GET', headers: headers })
      .then(response => response.json())
      .then(data => console.log(data))
      .catch((error) => console.error('Error:', error));
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.hub2.io/provisionings"
  headers = {
      'ApiKey': '[REDACTED]',
      'MerchantId': '[REDACTED]',
      'Environment': 'sandbox',
      'Content-Type': 'application/json',
  }

  response = requests.request("GET", url, headers=headers)

  print(response.text)
  ```
</CodeGroup>

```json theme={null}
{
    "data": [
        {
            "id": "prov_wz17MSJ2vRZcefkAdSehs",
            "date": "2023-10-17T12:31:27.793Z",
            "withdrawal": {
                "id": "wtd_9meMoAxGjGaqfamCb_cEU",
                "type": "withdrawal",
                "date": "2023-10-17T12:31:27.959Z",
                "amount": "100",
                "currency": "XOF"
            },
            "deposit": {
                "id": "dep_zLHUdczCwG52EGAWvldFf",
                "type": "deposit",
                "date": "2023-10-17T12:31:27.959Z",
                "amount": "100",
                "currency": "XOF"
            },
            "description": "TEST OL PREPROD",
            "status": "successful"
        },
        {
            "id": "prov_Mkw33s1i-DIacr6J4CN0C",
            "date": "2023-10-17T12:31:27.749Z",
            "withdrawal": {
                "id": "wtd_OqpCQzO0q84e508CbL0WU",
                "type": "withdrawal",
                "date": "2023-10-17T12:31:27.831Z",
                "amount": "100",
                "currency": "XOF"
            },
            "deposit": {
                "id": "dep_KLuaXcEGeor-qC9vvolC2",
                "type": "deposit",
                "date": "2023-10-17T12:31:27.831Z",
                "amount": "100",
                "currency": "XOF"
            },
            "description": "TEST OL PREPROD",
            "status": "successful"
        },
        {
            "id": "prov_N1xMSdSAFexce4DbPnNDu",
            "date": "2023-10-17T12:31:04.405Z",
            "withdrawal": {
                "id": "wtd__DjJfMdNgk7XAAkWVtpNW",
                "type": "withdrawal",
                "date": "2023-10-17T12:31:04.473Z",
                "amount": "100",
                "currency": "XOF"
            },
            "deposit": {
                "id": "dep_jkUWqh-kMxhkJyvunk9ub",
                "type": "deposit",
                "date": "2023-10-17T12:31:04.473Z",
                "amount": "100",
                "currency": "XOF"
            },
            "description": "TEST OL PREPROD",
            "status": "successful"
        }
    ],
    "totalItems": 13,
    "currentPage": 1,
    "countPerPage": 10
}
```
