You've successfully subscribed to Alpaca Learn | Developer-First API for Crypto and Stocks
Great! Next, complete checkout for full access to Alpaca Learn | Developer-First API for Crypto and Stocks
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.
Search
Broker API

How to Open an Account for an End-User by Broker API

Alpaca Team
Alpaca Team
How to Open an Account for an End-User by Broker API

This tutorial is a step-by-step demonstration of how to open an account for an end-user using 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!

Alpaca Broker API - Launch your own commission-free trading app
Alpaca is a modern platform for trading. Alpaca’s API is the interface for your trading algorithms, bots, or applications to communicate with Alpaca’s brokerage and other services.

How to Open an Account for an End User

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 open an account for an end-user below. In this tutorial, we will be providing all of the necessary information a user needs to open a brokerage account. Let’s note the required attributes are contact, identity, disclosures, agreements, and documents along with the optional attribute of trusted_contact. In each attribute, there are related fields that can be found described in detail here in our Broker Documentation.

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

As we wish to open an account for an end user we POST to the following endpoint /v1/accounts

It is important to realize that within each attribute there are required and optional fields. Take the ‘contact’ attribute where email_address and city are required but postal_code is optional as an example. Nonetheless, find the JSON body for our sample request below

{
 "contact": {
   "email_address": "[email protected]",
   "phone_number": "555-666-7788",
   "street_address": ["20 N San Mateo Dr"],
   "city": "San Mateo",
   "state": "CA",
   "postal_code": "94401",
   "country": "USA"
 },
 "identity": {
   "given_name": "John",
   "family_name": "Doe",
   "date_of_birth": "1990-01-01",
   "country_of_tax_residence": "SGP",
   "funding_source": ["employment_income"]
 },
 "disclosures": {
   "is_control_person": false,
   "is_affiliated_exchange_or_finra": false,
   "is_politically_exposed": false,
   "immediate_family_exposed": false
 },
 "agreements": [
   {
     "agreement": "margin_agreement",
     "signed_at": "2020-09-11T18:09:33Z",
     "ip_address": "185.13.21.99"
   },
   {
     "agreement": "account_agreement",
     "signed_at": "2020-09-11T18:13:44Z",
     "ip_address": "185.13.21.99"
   },
   {
     "agreement": "customer_agreement",
     "signed_at": "2020-09-11T18:13:44Z",
     "ip_address": "185.13.21.99"
   }
 ],
 "documents": [
   {
     "document_type": "cip_result",
     "content": "VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4=",
     "mime_type": "application/pdf"
   },
   {
     "document_type": "identity_verification",
     "document_sub_type": "passport",
     "content": "QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=",
     "mime_type": "image/jpeg"
   }
 ],
 "trusted_contact": {
   "given_name": "Jane",
   "family_name": "Doe",
   "email_address": "[email protected]"
 }
}
Sample Request to Open an Account 

Step 4: Response for a Successful Request

If all has been successful one will receive a status code 200. The response is the resulting account model as shown below. Note if one of the parameters was not entered correctly, the form is not well-formed, or if there is already another account registered under the same email, you will receive an error code. This is listed in detail in the Broker Documentation.

{
 "id": "a3c0bc7a-86c9-4995-b4d8-691fe2ac20cb",
 "account_number": "927048240",
 "status": "APPROVED",
 "currency": "USD",
 "last_equity": "0",
 "created_at": "2021-02-24T14:04:24.449501Z"
}
Sample Response

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

  • Accounts can instantly be created in the Sandbox Environment provided all of the parameters were submitted correctly.
  • After submitting all of the information in the Production Environment the account status may or may not be ACTIVE immediately and you will receive account status updates on the event API.
  • One can query the list of accounts with conditions using the endpoint

GET /v1/accounts

  • Or retrieve an account, specified by account_id, using the following endpoint

GET /v1/accounts/{account_id}

There are a variety of Enums for the POST /v1/accounts endpoint such as

  • TaxIdType: Denotes the TaxId
  • FundingSource: Funding Source for the account
  • EmploymentStatus: Current Employment Status
  • Agreement: Alpaca Agreements
  • DocumentType: Types of Documents necessary for account creation

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

API-first solutions for stocks and crypto
Alpaca offers simple, modern API-first solutions to get market data, trade stocks and crypto, build apps and more.

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.

Interested in learning more about Broker API?

Don't miss out on any updates about our Broker API suite of solutions! Share your details with us and be the first to know about our latest content.

Broker API

Alpaca Team

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