Skip to content
Start Trading

Get Accounts

client.V1.Accounts.GetAccounts(ctx, query) (*V1AccountGetAccountsResponse, error)
GET/v1/accounts

List accounts the authenticated user has permission to access.

Results can be narrowed with the optional account_id and account_name filters. account_id is a lexicographic prefix match on the decimal account id (e.g. 100 matches 100345 and 100567); account_name is a case-insensitive substring match on the account’s full name. When both are supplied an account must match both. When neither is supplied every accessible account is returned.

ParametersExpand Collapse
query V1AccountGetAccountsParams
AccountID param.Field[string]Optional

Filter to accounts whose id starts with this value (lexicographic prefix match on the decimal id, e.g. 100 matches 100345).

AccountName param.Field[string]Optional

Filter to accounts whose full name contains this value (case-insensitive substring match).

PageSize param.Field[int64]Optional

The number of items to return per page. Only used when page_token is not provided.

formatint64
maximum1000
minimum1
PageToken param.Field[string]Optional

Token for retrieving the next or previous page of results. Contains encoded pagination state; when provided, page_size is ignored.

formatbyte
ReturnsExpand Collapse
type V1AccountGetAccountsResponse struct{…}
ID int64

The unique identifier for the account

formatint64
AccountHolderEntityID int64

The account holder entity identifier

formatint64
FullName string

The full legal name of the account

OpenDate Time

The date the account was opened

formatdate
OptionsLevel int64

The options level of the account

formatint64
ShortName string

The short name of the account

The current status of the account

One of the following:
const AccountStatusActive AccountStatus = "ACTIVE"
const AccountStatusInactive AccountStatus = "INACTIVE"
const AccountStatusClosed AccountStatus = "CLOSED"

The sub-type of account

One of the following:
const AccountSubtypeCash AccountSubtype = "CASH"
const AccountSubtypeMargin AccountSubtype = "MARGIN"
const AccountSubtypeOther AccountSubtype = "OTHER"

The type of account

One of the following:
const AccountTypeCustomer AccountType = "CUSTOMER"
const AccountTypeOther AccountType = "OTHER"
CloseDate TimeOptional

The date the account was closed, if applicable When a null/undefined value is observed, it indicates it does not apply.

formatdate

Get Accounts

package main

import (
  "context"
  "fmt"

  "github.com/clear-street/clear-street-go"
  "github.com/clear-street/clear-street-go/option"
)

func main() {
  client := clearstreet.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.V1.Accounts.GetAccounts(context.TODO(), clearstreet.V1AccountGetAccountsParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
{
  "data": [
    {
      "account_holder_entity_id": 987654321,
      "close_date": null,
      "full_name": "Test Trading Account",
      "id": 19816,
      "open_date": "2023-01-15",
      "options_level": 1,
      "short_name": "TST-ACCOUNT-01",
      "status": "ACTIVE",
      "subtype": "MARGIN",
      "type": "CUSTOMER"
    },
    {
      "account_holder_entity_id": 987654322,
      "close_date": "2024-08-01",
      "full_name": "Old Test Account",
      "id": 19817,
      "open_date": "2021-05-20",
      "options_level": 0,
      "short_name": "TST-ACCOUNT-02-CLOSED",
      "status": "CLOSED",
      "subtype": "CASH",
      "type": "CUSTOMER"
    }
  ],
  "error": null,
  "metadata": {
    "next_page_token": "cGFnZT0yJmxhc3RfaWQ9MTk4MTc=",
    "page_number": 1,
    "request_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
    "total_items": 25,
    "total_pages": 3
  }
}
{
  "error": {
    "code": 403,
    "message": "The caller does not have permission to execute the specified operation"
  },
  "metadata": {
    "request_id": "5518f0c6-58ff-4b4a-81a5-701556d41206"
  }
}
Returns Examples
{
  "data": [
    {
      "account_holder_entity_id": 987654321,
      "close_date": null,
      "full_name": "Test Trading Account",
      "id": 19816,
      "open_date": "2023-01-15",
      "options_level": 1,
      "short_name": "TST-ACCOUNT-01",
      "status": "ACTIVE",
      "subtype": "MARGIN",
      "type": "CUSTOMER"
    },
    {
      "account_holder_entity_id": 987654322,
      "close_date": "2024-08-01",
      "full_name": "Old Test Account",
      "id": 19817,
      "open_date": "2021-05-20",
      "options_level": 0,
      "short_name": "TST-ACCOUNT-02-CLOSED",
      "status": "CLOSED",
      "subtype": "CASH",
      "type": "CUSTOMER"
    }
  ],
  "error": null,
  "metadata": {
    "next_page_token": "cGFnZT0yJmxhc3RfaWQ9MTk4MTc=",
    "page_number": 1,
    "request_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
    "total_items": 25,
    "total_pages": 3
  }
}
{
  "error": {
    "code": 403,
    "message": "The caller does not have permission to execute the specified operation"
  },
  "metadata": {
    "request_id": "5518f0c6-58ff-4b4a-81a5-701556d41206"
  }
}