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

# Create a trading account

> Creates a trading account and securely stores its broker credentials. The caller must be an organization admin; live accounts also require live-trading access. Organization broker-connection limits apply.



## OpenAPI

````yaml /api-reference/accounts.openapi.json post /v1/accounts
openapi: 3.1.0
info:
  title: accounts
  description: ''
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.anthid.com
    description: Production
security: []
tags:
  - name: Accounts
    description: Create, inspect, update, and disable trading accounts
  - name: Broker Credentials
    description: Inspect and manage credentials linked to trading accounts
paths:
  /v1/accounts:
    post:
      tags:
        - Accounts
      summary: Create a trading account
      description: >-
        Creates a trading account and securely stores its broker credentials.
        The caller must be an organization admin; live accounts also require
        live-trading access. Organization broker-connection limits apply.
      operationId: createAccount
      requestBody:
        description: Credentials for a supported broker. All values shown are placeholders.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BrokerCredentialVariant'
            example:
              Lightspeed:
                account_id: LS-123456
                api_key: lightspeed-api-key
                environment: paper
        required: true
      responses:
        '201':
          description: Account created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCredentialResponse'
              example:
                broker_credential_id: 550e8400-e29b-41d4-a716-446655440111
                trading_account_id: 550e8400-e29b-41d4-a716-446655440000
        '400':
          description: >-
            Invalid credentials, unsupported broker, or broker-connection limit
            reached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            Missing or invalid bearer token, or caller is not an organization
            admin
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Live trading is not enabled for the organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: An active connection already exists for this broker and environment
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Caller exceeded the request rate limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Unexpected server error while creating the account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    BrokerCredentialVariant:
      oneOf:
        - type: object
          required:
            - Lightspeed
          properties:
            Lightspeed:
              $ref: '#/components/schemas/LightspeedCredential'
        - type: object
          required:
            - Alpaca
          properties:
            Alpaca:
              $ref: '#/components/schemas/AlpacaCredential'
        - type: string
          enum:
            - Unspecified
    CreateCredentialResponse:
      type: object
      required:
        - trading_account_id
        - broker_credential_id
      properties:
        broker_credential_id:
          type: string
          format: uuid
        trading_account_id:
          type: string
          format: uuid
    Error:
      oneOf:
        - type: object
          required:
            - EncryptionError
          properties:
            EncryptionError:
              type: string
        - type: object
          required:
            - WorkOsError
          properties:
            WorkOsError:
              type: string
        - type: object
          required:
            - KvError
          properties:
            KvError:
              type: string
        - type: object
          required:
            - StreamError
          properties:
            StreamError:
              type: string
        - type: object
          required:
            - InternalError
          properties:
            InternalError:
              type: string
        - type: object
          required:
            - ThirdPartyError
          properties:
            ThirdPartyError:
              type: string
        - type: object
          required:
            - ParseError
          properties:
            ParseError:
              type: string
        - type: object
          required:
            - NotFound
          properties:
            NotFound:
              type: string
        - type: object
          required:
            - AlreadyExists
          properties:
            AlreadyExists:
              type: string
        - type: object
          required:
            - BadRequest
          properties:
            BadRequest:
              type: string
        - type: object
          required:
            - Forbidden
          properties:
            Forbidden:
              type: string
        - type: object
          required:
            - Unauthorized
          properties:
            Unauthorized:
              type: string
        - type: object
          required:
            - Database
          properties:
            Database:
              type: string
        - type: object
          required:
            - TooManyRequests
          properties:
            TooManyRequests:
              type: string
        - type: object
          required:
            - BrokerError
          properties:
            BrokerError:
              type: string
        - type: object
          required:
            - AuthError
          properties:
            AuthError:
              type: string
        - type: object
          required:
            - InvalidInput
          properties:
            InvalidInput:
              type: string
        - type: object
          required:
            - ConnectionLimitExceeded
          properties:
            ConnectionLimitExceeded:
              type: string
    LightspeedCredential:
      type: object
      required:
        - account_id
        - environment
        - api_key
      properties:
        account_id:
          type: string
        api_key:
          type: string
        environment:
          $ref: '#/components/schemas/BrokerEnvironment'
    AlpacaCredential:
      type: object
      required:
        - environment
        - api_key_id
        - api_key_secret
      properties:
        api_key_id:
          type: string
        api_key_secret:
          type: string
        environment:
          $ref: '#/components/schemas/BrokerEnvironment'
    BrokerEnvironment:
      type: string
      enum:
        - paper
        - live
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````