You've successfully subscribed to Alpaca Resources
Great! Next, complete checkout for full access to Alpaca Resources
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.
  • Home
  • We're hiring
  • Support
  • Forum
  • Docs
  • Log in
  • Sign up
Broker API

How to Fund an Account via Broker API

Alpaca Team
Alpaca Team
How to Fund an Account via Broker API

This tutorial is a step-by-step demonstration of how to fund an account via the Broker API and is part of the Alpaca 101 Tutorial Series. We will move forward assuming that you’ve registered on the Alpaca website. If you haven’t please visit Alpaca and sign up. Feel free to check out the other tutorials in this series at Alpaca Resources.

Please note that this tutorial reflects a sandbox testing environment. If you decide to transition to a live production environment, features and entitlements may differ to ensure handling of clients’ live accounts are compliant with all applicable rules and regulations.


What is Broker API?

Alpaca is built for developers and traders. That being said we are incredibly excited to announce we have established our very own broker product that can evolve alongside the Alpaca platform. Alpaca users can develop in sandbox environments, allowing users to access all the functionality of an operational brokerage in parallel with becoming compliant with applicable rules and regulations should you decide to transition to a live production environment. We are releasing a series of tutorials to provide guidance on the core features of the Broker API, so make sure to check out Alpaca Resources. Let’s get started!


How to Fund an Account via Broker API

Step 1: Broker Dashboard

Similar to the Algo Dashboard, the Broker Dashboard displays all of the information relevant to one’s broker account. The main page, shown below, includes an overview of the number of active accounts, assets under management (AUM) along recent signups, transactions, and orders. When logging in for the first time, you will notice there is not any information present in the dashboard as below

Broker Dashboard Overview 

There are also subpages for the firm’s balance, active accounts, transactions (orders and ACH/Wire transfers), and documents.


Step 2: Live Testing

To set up your environment first navigate to the API/Devs page where there is a box in the right-hand corner called Seed Env. By clicking this, your environment will be populated with random test users. This allows you to start testing different API calls without needing to create user accounts in your environment. After this, your dashboard should contain randomly generated test signups and amounts under Assets Under Management (AUM).

Broker Dashboard with random test users

Now that the sandbox environment contains users, we can move on to testing out the API calls. Navigate first to the API/Devs page and then the Live Testing page which will look like this

Live Testing

This will be the medium in which we test the API call in the next section.


Step 3: Sending the Request Body

Let’s create a raw request to fund an account via the Broker API below. In this tutorial, we will be depositing $5000 via a wire transfer. As we want to transfer the amount into our account we will POST to the following endpoint: /v1/transfers. Note in the sandbox environment, you can instantly deposit to or withdraw from an account with a virtual money amount. More information concerning transfers in the production environment can be found in our Broker Documentation.

Welcome to Alpaca Broker API Guide
Open brokerage accounts, enable commission-free trading, and manage the ongoing user experience with Alpaca Broker API
Alpaca Broker API Documentation 

Find the JSON body for our request below:

{
"transfer_type": "wire",
"amount": "5000",
"direction": "INCOMING",
"additional_information": "my additional wire info details"
}
JSON Request

Step 4: Response for a Successful Request

If all has been successful one will receive the following response object which includes properties such as the type of transfer, amount, status, the direction of the transaction.

{
 "id": "18a97668-b376-4277-a7bc-0fec28ca06a9",
 "account_id": "fb17c119-7249-4b56-a55c-46bc18b96da6",
 "type": "wire",
 "status": "COMPLETE",
 "amount": "5000",
 "direction": "INCOMING",
 "created_at": "2021-02-24T14:12:04.834258706Z",
 "updated_at": "2021-02-24T14:12:05.008472291Z",
 "expires_at": "2021-03-03T14:12:04.833688899Z",
 "additional_information": "my additional wire info details"
}
JSON Response for Successful Request 

Great! Now, moving forward here are some important points to remember:

  • In the sandbox environment, you can instantly deposit and withdraw from an account with a virtual money amount, however, for wire transfers in production, you would need to create the bank resource first using the Bank API.
  • One can query a list of transfers for an account, specified by an account_id, using the following API call:

GET /v1/accounts/{account_id}/transfers

Some Enums to be aware of:

  • TransferDirection: INCOMING (Deposits) or OUTGOING (Withdrawals)
  • TransferType: ach (ACH Transfer) or wire (Wire Transfers)
  • TransferStatus: QUEUED, PENDING, REJECTED, and APPROVED with the respective qualifications of each status found here in the Broker Documentation.
Alpaca API

Thank you for using Alpaca. Here are a couple more links that you might be interested in.

Alpaca GitHub repository

Alpaca
Alpaca builds an API for free stock trading. Alpaca has 42 repositories available. Follow their code on GitHub.

Alpaca Blog

Alpaca Blog | API for Stock Trading
Alpaca Blog for product updates, new integration, and more. Alpaca’s commission-free trading API is built for algorithmic trading and building apps

Alpaca Forum

Alpaca Community Forum
Alpaca user forum for FAQ, feature requests, many discussions around Alpaca stock trading API

Alpaca API documentation

Documentation | Alpaca
Alpaca API lets you build and trade with real-time market data for free.

Sign up for the weekly newsletter to keep up with the API updates and upcoming competitions,  job opportunities by clicking here.

You can also follow Alpaca and our weekly updates on our LinkedIn, Alpaca Community Slack, and @AlpacaHQ on Twitter!

Commission-Free trading means that there are no commission charges for Alpaca self-directed individual cash brokerage accounts that trade U.S. listed securities through an API. Relevant SEC and FINRA fees may apply.

Brokerage services are provided by Alpaca Securities LLC ("Alpaca"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.


Broker API

Alpaca Team

API-first stock brokerage. *Securities are offered through Alpaca Securities LLC* http://alpaca.markets/#disclosures