SSE Events
Alpaca Broker API provides replayable and real-time event streams via Server-Sent Event (SSE). The SSE protocol is a simple yet powerful protocol to satisfy a lot of your needs to build flawless user experience. Each endpoint can be queried by the event timestamp or monotonically incremental integer ID to seamlessly subscribe from the past point-in-time event to the real-time pushes with a simple HTTP request. While all SSE endpoints follow the same JSON object model as other REST endpoints, SSE protocol is a lightweight addition on top of the basic HTTP protocol which is a bit different from REST protocol. Please make sure your client program handles the SSE protocol correctly.
Why Use SSE?
- Low Latency: Receive updates in real-time for timely decisions about your customers
- Resource Efficiency: A single connection serves multiple updates and streamlines where you receive updates about your customers
- Simplicity: Integration requires fewer lines of code compared to WebSockets.
Best Practices
- Connection Health: Implement heartbeat checks.
- Error Recovery: Code for auto-reconnection.
- Selective Listening: Subscribe to specific event types relevant to your use case.
Types of SSE Events
Account Status Events
Stay abreast of changes to account statuses. Learn more here.
You can find some sample responses below:
{
"account_blocked": false,
"account_id": "d16f0c84-2bcc-4caf-bd68-a97889986d74",
"account_number": "",
"admin_configurations": {
"allow_instant_ach": true,
"disable_shorting": true
},
"at": "2023-10-13T13:18:16.936397Z",
"crypto_status_from": "",
"crypto_status_to": "INACTIVE",
"event_id": 12627496,
"event_ulid": "01HCMK03B8JV4YDB8W2HZ0K6V2",
"pattern_day_trader": false,
"status_from": "",
"status_to": "APPROVED",
"trading_blocked": false
}
{
"account_id": "d16f0c84-2bcc-4caf-bd68-a97889986d74",
"account_number": "307781498",
"at": "2023-10-13T13:18:18.472537Z",
"event_id": 12627497,
"event_ulid": "01HCMK04V979EMCGB96Z6T0H00",
"status_from": "APPROVED",
"status_to": "ACTIVE"
}Trade Events
Keep tabs on the status of orders, trades, and executions in real-time. Documentation here.
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2023-10-13T13:28:58.387652Z",
"event_id": "01HCMKKNRK7S5C1JYP50QGDECQ",
"event": "new",
"timestamp": "2023-10-13T13:28:58.37957033Z",
"order": {
"id": "bb2403bc-88ec-430b-b41c-f9ee80c8f0e1",
"client_order_id": "508789e5-cea3-4235-b546-6c62ff92bd79",
"created_at": "2023-10-13T13:28:58.361530031Z",
"updated_at": "2023-10-13T13:28:58.386058029Z",
"submitted_at": "2023-10-13T13:28:58.360070731Z",
"filled_at": null,
"expired_at": null,
"cancel_requested_at": null,
"canceled_at": null,
"failed_at": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
"symbol": "AAPL",
"asset_class": "us_equity",
"notional": "10",
"qty": null,
"filled_qty": "0",
"filled_avg_price": null,
"order_class": "",
"order_type": "market",
"type": "market",
"side": "buy",
"time_in_force": "day",
"limit_price": null,
"stop_price": null,
"status": "new",
"extended_hours": false,
"legs": null,
"trail_percent": null,
"trail_price": null,
"hwm": null,
"commission": "0"
},
"execution_id": "7922ab44-5b33-4049-ab9a-0cfd805ba989"
}
:heartbeat
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2023-10-13T13:30:00.664778Z",
"event_id": "01HCMKNJJRJ4E3RNFA1XR8CX7R",
"event": "fill",
"timestamp": "2023-10-13T13:30:00.658443088Z",
"order": {
"id": "db04069d-2e5a-48d4-a42f-6a0dea8ea0b8",
"client_order_id": "be139e2d-8153-4ae8-83ee-7b98b4e17419",
"created_at": "2023-10-13T13:22:21.887914Z",
"updated_at": "2023-10-13T13:30:00.661902331Z",
"submitted_at": "2023-10-13T13:23:05.411141Z",
"filled_at": "2023-10-13T13:30:00.658443088Z",
"expired_at": null,
"cancel_requested_at": null,
"canceled_at": null,
"failed_at": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
"symbol": "AAPL",
"asset_class": "us_equity",
"notional": "10",
"qty": null,
"filled_qty": "0.05513895",
"filled_avg_price": "181.36",
"order_class": "",
"order_type": "market",
"type": "market",
"side": "buy",
"time_in_force": "day",
"limit_price": null,
"stop_price": null,
"status": "filled",
"extended_hours": false,
"legs": null,
"trail_percent": null,
"trail_price": null,
"hwm": null,
"commission": "0"
},
"price": "181.36",
"qty": "0.05513895",
"position_qty": "0.05513895",
"execution_id": "a958bb42-b034-4d17-bf07-805cf0820ffe"
}
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2023-10-13T13:30:00.673857Z",
"event_id": "01HCMKNJK1Y0R7VF6Q6CAC3SH7",
"event": "fill",
"timestamp": "2023-10-13T13:30:00.658388668Z",
"order": {
"id": "bb2403bc-88ec-430b-b41c-f9ee80c8f0e1",
"client_order_id": "508789e5-cea3-4235-b546-6c62ff92bd79",
"created_at": "2023-10-13T13:28:58.361530031Z",
"updated_at": "2023-10-13T13:30:00.665807961Z",
"submitted_at": "2023-10-13T13:28:58.360070731Z",
"filled_at": "2023-10-13T13:30:00.658388668Z",
"expired_at": null,
"cancel_requested_at": null,
"canceled_at": null,
"failed_at": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
"symbol": "AAPL",
"asset_class": "us_equity",
"notional": "10",
"qty": null,
"filled_qty": "0.05513895",
"filled_avg_price": "181.36",
"order_class": "",
"order_type": "market",
"type": "market",
"side": "buy",
"time_in_force": "day",
"limit_price": null,
"stop_price": null,
"status": "filled",
"extended_hours": false,
"legs": null,
"trail_percent": null,
"trail_price": null,
"hwm": null,
"commission": "0"
},
"price": "181.36",
"qty": "0.05513895",
"position_qty": "0.1102779",
"execution_id": "33cbb614-bfc0-468b-b4d0-ccf08588ef77"
}
:heartbeat
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2024-09-23T13:30:00.673857Z",
"event_id": "01HCMQR4S73L9G6EHI0JKL2M3N",
"event": "trade_bust",
"timestamp": "2024-09-23T15:30:48.601741737Z",
"order": {
"id": "c86e4d6c-2cdf-4b81-b658-5728bdc8310b",
"client_order_id": "10671b99-2cb3-43c3-92a0-96054edd59a8",
"created_at": "2024-09-23T15:30:48.599363562Z",
"updated_at": "2024-09-23T16:09:21.642880502Z",
"submitted_at": "2024-09-23T15:30:48.601741737Z",
"filled_at": "2024-09-23T20:09:21.635Z",
"expired_at": null,
"cancel_requested_at": null,
"canceled_at": null,
"failed_at": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"asset_id": "a153fd9c-fd4e-4416-9adc-f9040aa2e125",
"symbol": "JTAI",
"asset_class": "us_equity",
"notional": null,
"qty": "2",
"filled_qty": "0",
"filled_avg_price": "0.107703",
"order_class": "",
"order_type": "market",
"type": "market",
"side": "buy",
"time_in_force": "day",
"limit_price": null,
"stop_price": null,
"status": "filled",
"extended_hours": false,
"legs": null,
"trail_percent": null,
"trail_price": null,
"hwm": null
},
"price": "0.107703",
"qty": "-2",
"position_qty": "0",
"execution_id": "df61d6ec-511f-4cc1-ae61-20456b0cb7a5",
"previous_execution_id": "aeb60660-412f-4537-8d1f-1101b3fc8f64"
}
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2024-10-18T13:30:00.673857Z",
"event_id": "01HCMQR4S73L9G6EHI0JKL2M3N",
"event": "trade_correct",
"timestamp": "2024-10-18T22:26:32.988Z",
"order": {
"id": "390cd7d0-07fa-4ab0-8b99-7ffb8d7408ff",
"client_order_id": "21975666-5eae-4149-b86f-3682f4fd8c69",
"created_at": "2024-10-18T09:10:13.311667892Z",
"updated_at": "2024-10-18T18:26:32.996327532Z",
"submitted_at": "2024-10-18T09:10:13.31490803Z",
"filled_at": "2024-10-18T22:26:32.988Z",
"expired_at": null,
"cancel_requested_at": null,
"canceled_at": null,
"failed_at": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"asset_id": "6b0137a2-4efb-4fba-aa39-9f64f6afe5f4",
"symbol": "BSRR",
"asset_class": "us_equity",
"notional": null,
"qty": "1",
"filled_qty": "1",
"filled_avg_price": "25",
"order_class": "",
"order_type": "limit",
"type": "limit",
"side": "buy",
"time_in_force": "day",
"limit_price": "28.93",
"stop_price": null,
"status": "filled",
"extended_hours": true,
"legs": null,
"trail_percent": null,
"trail_price": null,
"hwm": null
},
"price": "25",
"qty": "1",
"position_qty": "1",
"execution_id": "2ff98545-9082-469a-8aa8-7f6c09ac258f",
"previous_execution_id": "f116d6c7-fc4a-49b1-a649-317aace34783"
}{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2023-10-13T13:22:21.927554Z",
"event": "accepted",
"event_id": 10676063,
"event_ulid": "01HCMK7JJ3EJD9P4JSM1M0HTZ0",
"order": {
"asset_class": "us_equity",
"asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
"cancel_requested_at": null,
"canceled_at": null,
"client_order_id": "be139e2d-8153-4ae8-83ee-7b98b4e17419",
"commission": "0",
"created_at": "2023-10-13T09:22:21.887913787-04:00",
"expired_at": null,
"extended_hours": false,
"failed_at": null,
"filled_at": null,
"filled_avg_price": null,
"filled_qty": "0",
"hwm": null,
"id": "db04069d-2e5a-48d4-a42f-6a0dea8ea0b8",
"legs": null,
"limit_price": null,
"notional": "10",
"order_class": "",
"order_type": "market",
"qty": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"side": "buy",
"status": "accepted",
"stop_price": null,
"submitted_at": "2023-10-13T09:22:21.886066537-04:00",
"symbol": "AAPL",
"time_in_force": "day",
"trail_percent": null,
"trail_price": null,
"type": "market",
"updated_at": "2023-10-13T09:22:21.887913787-04:00"
},
"timestamp": "2023-10-13T09:22:21.888053477-04:00"
}
:heartbeat
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2023-10-13T13:30:01.118487Z",
"event": "fill",
"event_id": 10676567,
"event_ulid": "01HCMKNJJRJ4E3RNFA1XR8CX7R",
"execution_id": "a958bb42-b034-4d17-bf07-805cf0820ffe",
"order": {
"asset_class": "us_equity",
"asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
"cancel_requested_at": null,
"canceled_at": null,
"client_order_id": "be139e2d-8153-4ae8-83ee-7b98b4e17419",
"commission": "0",
"created_at": "2023-10-13T13:22:21.887914Z",
"expired_at": null,
"extended_hours": false,
"failed_at": null,
"filled_at": "2023-10-13T13:30:00.658443088Z",
"filled_avg_price": "181.36",
"filled_qty": "0.05513895",
"hwm": null,
"id": "db04069d-2e5a-48d4-a42f-6a0dea8ea0b8",
"legs": null,
"limit_price": null,
"notional": "10",
"order_class": "",
"order_type": "market",
"qty": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"side": "buy",
"status": "filled",
"stop_price": null,
"submitted_at": "2023-10-13T13:23:05.411141Z",
"symbol": "AAPL",
"time_in_force": "day",
"trail_percent": null,
"trail_price": null,
"type": "market",
"updated_at": "2023-10-13T09:30:00.661902331-04:00"
},
"position_qty": "0.05513895",
"price": "181.36",
"qty": "0.05513895",
"timestamp": "2023-10-13T13:30:00.658443088Z"
}
{
"account_id": "aa4439c3-cf7d-4251-8689-a575a169d6d3",
"at": "2023-10-13T13:30:02.667443Z",
"event": "fill",
"event_id": 10676601,
"event_ulid": "01HCMKNJK1Y0R7VF6Q6CAC3SH7",
"execution_id": "33cbb614-bfc0-468b-b4d0-ccf08588ef77",
"order": {
"asset_class": "us_equity",
"asset_id": "b0b6dd9d-8b9b-48a9-ba46-b9d54906e415",
"cancel_requested_at": null,
"canceled_at": null,
"client_order_id": "508789e5-cea3-4235-b546-6c62ff92bd79",
"commission": "0",
"created_at": "2023-10-13T09:28:58.361530031-04:00",
"expired_at": null,
"extended_hours": false,
"failed_at": null,
"filled_at": "2023-10-13T13:30:00.658388668Z",
"filled_avg_price": "181.36",
"filled_qty": "0.05513895",
"hwm": null,
"id": "bb2403bc-88ec-430b-b41c-f9ee80c8f0e1",
"legs": null,
"limit_price": null,
"notional": "10",
"order_class": "",
"order_type": "market",
"qty": null,
"replaced_at": null,
"replaced_by": null,
"replaces": null,
"side": "buy",
"status": "filled",
"stop_price": null,
"submitted_at": "2023-10-13T09:28:58.360070731-04:00",
"symbol": "AAPL",
"time_in_force": "day",
"trail_percent": null,
"trail_price": null,
"type": "market",
"updated_at": "2023-10-13T09:30:00.665807961-04:00"
},
"position_qty": "0.1102779",
"price": "181.36",
"qty": "0.05513895",
"timestamp": "2023-10-13T13:30:00.658388668Z"
}Message Ordering
For the messages received on the SSE stream we guarantee that the order of the received events is the same as the order they were happening on a per account basis.
Example: if event E1 has been received earlier then another event E2 for the same account, then E1 happened before E2 according to our bookkeeping.
We do not have this guarantee across accounts: if two events for different accounts are received it is the consumer’s responsibility to decide which event happened first based on the timestamp/ulid fields of the event.
Example: E1 happened for account A1 before E2 which was affecting A2. The streaming endpoint might return the events in E1, E2 or E2, E1 ordering. Both responses should be considered valid.
Note: since ULIDs contain a random part other events might have arrived in the same millisecond as the last event received being lexiographicly less than the previous event.
If the stream is used for recon purposes, we recommend to restart the stream from a since that is a few mintues before the time of latest event received.
This approach means that the consumer will receive some events twice when restarting a stream: it is the consumer’s responsibility to process the recevied messages in an idempotent manner so that duplicate messages get ignored on the consumer side.
Note: since and until parameters are parsing as RFC3339 where timezone can be specified (e.g 2006-01-02T15:04:05+07:00), however plus sign character (+) is a special character in HTTP, so use the URL encoded version instead, e.g. ...events/trades?since=2006-01-02T15:04:05%2B07:00
Comment messages
According to the SSE specification, any line that starts with a colon is a comment which does not contain data. It is typically a free text that does not follow any data schema. A few examples mentioned below for comment messages.
Slow client
The server sends a comment when the client is not consuming messages fast enough. Example: : you are reading too slowly, dropped 10000 messages
Internal server error
An error message is sent as a comment when the server closes the connection on an internal server error (only sent by the v2 and v2beta1 endpoints). Example: : internal server error
Admin Action Events
These events pertain to administrative actions like account suspensions and liquidations performed by Alpaca Administrators. See more here.
[
{
"event_id": "01GTVS4FVS2KJDTPYH2WM6NAXF",
"at": "2023-09-21T10:52:38.429059991Z",
"note": "Status changed to REJECTED.",
"type": "legacy_note_admin_event",
"context": {},
"category": "other",
"event_id": "03HBVNXKMWYGFTKTGNVR5R41F2",
"correspondent": "ABCD",
"belongs_to_kind": "account",
"created_by_kind": "admin",
"belongs_to_id_reference": "b4fe44b0-e51c-48f4-b674-990bea6cf8d7",
"created_by_id_reference": "f0e150df-94ad-48f9-8b0f-05433a3b53c3"
}
]Non-Trade Activities Events
The legacy NTA stream (GET /v1/events/nta) is not documented for new EU integrations.
Use the Activity Events SSE instead: GET /v2beta1/events/activities. That endpoint covers trade fills, corporate actions, fees, journals, deposits, withdrawals, and other account activities in one stream.
See Activity Events below.
System Events
These events pertain to system-wide actions, and are mainly created by automated processes on our backends. Documentation here
{
"event_id": "01KE90MX0DXW9NCG9HT4N2WDPW",
"at": "2026-01-06T06:41:57.261948Z",
"type": "eod_balances_ready",
"system_date": "2026-01-05",
"description": "End-of-day balances are now available."
}{
"event_id": "01KE90P5Q4J1WPBEF6075A48RE",
"at": "2026-01-06T06:42:38.948967Z",
"type": "eod_positions_ready",
"system_date": "2026-01-05",
"description": "End-of-day positions are now available."
}Activity Events
These events provide a more holistic view of the transactions that affect an account. Such transaction events are both trade and non-trade activities including, but not limited to: trade, corporate action, fees, journal, transfers (deposit, withdrawal).
- API reference: Subscribe to Activity Events (SSE)
- Single-event lookup: Get a single activity (V2) event
Updated 4 days ago