canonical: https://jentic.com/apis/alpaca.markets/trading

# Alpaca Markets Alpaca Trading API

The Alpaca Trading API is the self-directed trading surface of the Alpaca platform, designed for individual developers and algorithmic traders running their own brokerage account. It exposes orders, positions, watchlists, account configurations, account activities, market calendar and clock, assets, options contracts, corporate actions, crypto funding wallets, and portfolio history. Authentication uses APCA-API-KEY-ID and APCA-API-SECRET-KEY headers, and live and paper environments are exposed at api.alpaca.markets and paper-api.alpaca.markets respectively. With 44 endpoints, this API is focused on trading, not on opening or managing customer accounts.

## For AI agents

Run a self-directed Alpaca account: place and cancel orders, manage positions and watchlists, read account activities, and check the market calendar through one set of API keys.

## Scope

Does not handle market data feeds, customer account opening, or KYC - use for self-directed order placement, position and watchlist management, and account activities only.

## Capabilities

- Place, replace, and cancel stock, options, and crypto orders
- List open positions and close one or all of them
- Exercise a held options position on request
- Create, update, and delete watchlists by ID or by name
- Read account activities, configurations, and portfolio history
- Look up assets by symbol or ID and read option contracts
- Manage crypto funding wallets, transfers, and whitelisted addresses

## Use cases

### Algorithmic order placement

Trading bots place orders via POST /v2/orders, replace open orders via PATCH /v2/orders/{order_id}, and cancel via DELETE /v2/orders/{order_id} or DELETE /v2/orders for all open orders. The same surface covers stock, options, and crypto orders, so a single integration handles cross-asset strategies.

Example prompt: Place a market buy order for 5 shares of NVDA via POST /v2/orders, then poll GET /v2/orders/{order_id} until status is filled.

### Position management and risk control

Risk controls call GET /v2/positions to read current exposure, DELETE /v2/positions to flatten the book, or DELETE /v2/positions/{symbol_or_asset_id} to close a single position. Combined with GET /v2/account/portfolio/history, this lets a daily risk job evaluate drawdown and rebalance without leaving the API.

Example prompt: If end-of-day drawdown exceeds 2 percent, call DELETE /v2/positions to close all open positions on the account.

### Options trading workflow

Options traders look up contracts via GET /v2/options/contracts, place orders for chosen contracts via POST /v2/orders, and exercise positions via POST /v2/positions/{symbol_or_contract_id}/exercise. The trading surface mirrors the stock workflow which keeps the option logic small.

Example prompt: Find SPY put contracts expiring this Friday via GET /v2/options/contracts, then place a buy-to-open order for the chosen strike.

### Watchlist and market context

Apps maintain user-curated watchlists via /v2/watchlists and the by-name variant /v2/watchlists:by_name, then check the market clock via GET /v2/clock and the calendar via GET /v2/calendar to schedule trading windows. Asset metadata via /v2/assets fills out symbol details for the UI.

Example prompt: Add AAPL to the watchlist named 'tech-picks' via POST /v2/watchlists:by_name, then check GET /v2/clock to confirm the market is open.

### AI agent self-directed trading

An AI agent assistant can suggest trades, place them after explicit confirmation, and read back portfolio history to summarise performance. Through Jentic the agent searches by intent, loads the order schema, and executes - the APCA keys stay encrypted in your own Jentic One instance and never enter the prompt context.

Example prompt: Use Jentic to search 'place an Alpaca order', execute POST /v2/orders after the user confirms, and report the fill via GET /v2/orders/{order_id}.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /v2/orders | Create an order |
| GET | /v2/orders | List orders |
| DELETE | /v2/orders/{order_id} | Cancel an order |
| GET | /v2/positions | List open positions |
| DELETE | /v2/positions | Close all positions |
| GET | /v2/account/portfolio/history | Account portfolio history |
| GET | /v2/clock | Market clock |
| GET | /v2/options/contracts | List option contracts |

## Key resources

- **Orders** — Place, replace, and cancel orders for stocks, options, and crypto
- **Positions** — List, close one, close all, and exercise options positions
- **Watchlists** — Create and manage watchlists by ID or by name and add or remove symbols
- **Account** — Read account details, configurations, activities, and portfolio history
- **Calendar and clock** — Market calendar and live clock for scheduling
- **Assets and options contracts** — Look up tradeable assets and option contracts
- **Crypto wallets** — Manage crypto funding wallets, transfers, and whitelisted addresses

## Why Jentic

- **Setup:** Wiring the Alpaca Trading API by hand means sending its API key headers to api.alpaca.markets and coordinating order, position, and account-activity calls with your own retry handling. Through Jentic you install once, import the Alpaca Trading API from the API Directory, store the API key once, and your agent calls it.
- **Permission scoping:** The Alpaca Trading API puts the order id in the URL path (/v2/orders/{order_id}) while position closes and order creation are collection-level, so a rule can pin your agent to reading orders and the clock. You choose the operations it may call, so placing orders or closing positions is not included unless you add them.
- **Credential handling:** Your Alpaca Trading API key is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'place a buy order' or 'read open positions', and Jentic returns the matching Alpaca Trading operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Alpaca Market Data API** — Market Data feeds the prices that drive Trading orders
- **Alpaca Broker API** — Broker is the multi-account, branded brokerage variant of Trading
- **Plaid** — Plaid links a bank account for funding the Alpaca brokerage
- **OpenAI** — OpenAI summarises market context that informs Trading API calls

## FAQ

### What authentication does the Alpaca Trading API use?

Two header-based API keys: APCA-API-KEY-ID and APCA-API-SECRET-KEY. Through Jentic, both values are stored encrypted by your own Jentic One instance and injected at execution time, so they never appear in agent prompts or logs. Alpaca's docs also describe an OAuth 2.0 authorization-code flow for third-party apps calling the Trading API on an end user's behalf, with account:write and trading scopes and a bearer access token; the OpenAPI description behind this page declares the two key headers and not that flow.

### Can I place options orders through the Trading API?

Yes. Look up contracts via GET /v2/options/contracts, then place an order with POST /v2/orders specifying the contract symbol. Exercise an options position via POST /v2/positions/{symbol_or_contract_id}/exercise.

### How do I cancel all open orders via Jentic?

Ask your agent to cancel your open Alpaca orders and your self-hosted Jentic One instance resolves that to DELETE /v2/orders, which cancels every open order on the authenticated account. You choose the operations the agent may call, so DELETE /v2/orders has to be in its allowed set first.

### Is there an Alpaca Trading MCP server?

Yes. Alpaca publishes an MCP server, and its docs state the server exposes 65 tools across the Trading and Market Data APIs, with an ALPACA_TOOLSETS environment variable that limits which toolsets load. You can also connect the Alpaca Trading API directly through Jentic: your agent gets the full 44-endpoint surface from the spec and discovers operations on demand instead of loading another server's tool definitions into its context, and your APCA-API-KEY-ID and APCA-API-SECRET-KEY are injected at call time by your own self-hosted Jentic One instance instead of sitting in an MCP client config file.

### Is there a paper trading endpoint?

Yes. The spec lists https://paper-api.alpaca.markets alongside the live https://api.alpaca.markets endpoint. Use the paper URL to develop and test without placing real orders.

### Can I read portfolio history for performance reporting?

Yes. GET /v2/account/portfolio/history returns equity and profit and loss values across a chosen period, suitable for daily or weekly performance summaries.

### Does the Trading API include market data?

No. Use the separate Alpaca Market Data API for bars, quotes, trades, and snapshots. The Trading API exposes asset metadata and the market clock but not pricing data.

### Can I limit what my agent is allowed to do with the Alpaca Trading API?

Yes. Because Jentic One is self-hosted, your own rules decide which Alpaca Trading operations and credentials the agent may use, so you can pin it to read-only calls like GET /v2/orders and GET /v2/clock. Order creation and closing positions are collection-level operations such as POST /v2/orders and DELETE /v2/positions, so the agent cannot place or flatten trades unless you add those operations to its allowed set. Individual actions keyed by path, like canceling a specific order via DELETE /v2/orders/{order_id}, can be scoped in the same way.
