Create a Subclient with a Virtual Account¶
This guide combines examples described in the API documentation in these places:
Prerequisites¶
The code snippets provided in this scenario require the following variables:
BASE_API_URL- The target GIB API domain, which can be found in the API-Reference.API_KEY- The API key setup by the client for using the API. Can be generated using the Dashboard.FBO_ACCOUNT_NUMBER- The number for the FBO account that this Subclient will have a virtual account in.FBO_ROUTING_NUMBER- The routing number for the FBO account that this Subclient will have a virtual account in.
The routing number that all virtual accounts use is a bank-wide setting and is applied automatically, so it is not part of the request. It is returned with the created account.
Step 1 - Create Subclient¶
To record end-user data into the system, a client creates a Subclient which has identifying information - name, address, external_key to client ledger, etc.
url = f"{BASE_API_URL}/subclient"
payload = {
"name": "Jane Doe",
"external_key": "ABC-123-0001",
"type": "natural_person",
"data": {
"type": "natural_person",
"first_name": "Jane",
"last_name": "Doe",
},
"address": {
"street_address_1": "123 Somewhere St",
"city": "Sometown",
"country_alpha_2_code": "US",
},
}
headers = {
"Content-type": "application/json",
"Authorization": f"{API_KEY}"
}
response = requests.request("POST", url, json=payload, headers=headers)
response.raise_for_status()
SUBCLIENT_ID = response.json()["id"]
Step 2 - Create Virtual Account (Subclient Account)¶
Once a Subclient is created, Subclient Account information can be attached. A Subclient Account can be a virtual account that is within an existing client FBO account.
url = f"{BASE_API_URL}/subclient/{SUBCLIENT_ID}/account"
payload = {
"type": "virtual",
"description": "Jane Doe's Virtual Account",
"active": True,
"core_account_number": f"{FBO_ACCOUNT_NUMBER}",
}
headers = {
"Content-type": "application/json",
"Authorization": f"{API_KEY}"
}
response = requests.request("POST", url, json=payload, headers=headers)
response.raise_for_status()
account = response.json()
VIRTUAL_ACCOUNT_NUMBER = account["account_number"]
VIRTUAL_ROUTING_NUMBER = account["routing_number"]