Create Trade Intent
Submit a fully specified Trade Intent for execution
API: POST https://api.sniperoute.io/api/v1/intents
Request
Headers
| Header | Value | Required |
|---|---|---|
Authorization | Bearer your_api_key | Yes |
Content-Type | application/json | Yes |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
intent_id | string | Yes | Unique identifier from upstream platform (idempotency key) |
symbol | string | Yes | Trading symbol (e.g., "AAPL", "TSLA") |
side | string | Yes | Order side: "buy" or "sell" |
quantity | number | Yes | Number of shares/units to trade |
order_type | string | Yes | Order type: "market", "limit", "stop", "stop_limit" |
broker_id | string | Yes | ID of the user's connected broker account |
limit_price | number | Conditional | Required when order_type is "limit" or "stop_limit" |
stop_price | number | Conditional | Required when order_type is "stop" or "stop_limit" |
time_in_force | string | No | "day", "gtc", "ioc", "fok" (default: "day") |
extended_hours | boolean | No | Allow trading in extended hours (default: false) |
Response
Success (201 Created)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"intent_id": "trade_001",
"symbol": "AAPL",
"side": "buy",
"quantity": 10,
"order_type": "market",
"status": "pending",
"broker_id": "alpaca_abc123",
"orders": [],
"created_at": "2025-11-30T10:29:59Z",
"updated_at": "2025-11-30T10:29:59Z"
}Error (4xx/5xx)
{
"detail": "Error message",
"error_code": "specific_error_code",
"request_id": "req_abc123"
}Examples
Market Buy Order
curl -X POST https://api.sniperoute.io/api/v1/intents \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_abc123..." \
-d '{
"intent_id": "trade_001",
"symbol": "AAPL",
"side": "buy",
"quantity": 10,
"order_type": "market",
"broker_id": "alpaca_abc123"
}'Limit Sell Order
curl -X POST https://api.sniperoute.io/api/v1/intents \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_abc123..." \
-d '{
"intent_id": "trade_002",
"symbol": "TSLA",
"side": "sell",
"quantity": 5,
"order_type": "limit",
"limit_price": 250.00,
"time_in_force": "gtc",
"broker_id": "alpaca_abc123"
}'Stop-Limit Order
curl -X POST https://api.sniperoute.io/api/v1/intents \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_live_abc123..." \
-d '{
"intent_id": "trade_003",
"symbol": "NVDA",
"side": "buy",
"quantity": 20,
"order_type": "stop_limit",
"stop_price": 500.00,
"limit_price": 505.00,
"time_in_force": "day",
"broker_id": "alpaca_abc123"
}'Validation Rules
intent_id Must Be Unique
Each intent_id must be unique across all Trade Intents for a given user. Duplicate intent_id will result in 409 Conflict.
{
"detail": "Trade Intent with this intent_id already exists"
}Limit Orders Require limit_price
If order_type is "limit" or "stop_limit", you must provide limit_price.
{
"detail": "limit_price is required for limit orders"
}Stop Orders Require stop_price
If order_type is "stop" or "stop_limit", you must provide stop_price.
{
"detail": "stop_price is required for stop orders"
}Quantity Must Be Positive
The quantity must be greater than 0.
{
"detail": "quantity must be greater than 0"
}Broker Must Be Connected
The broker_id must correspond to a connected broker account.
{
"detail": "Broker connection not found"
}Error Codes
| Status Code | Error Code | Description |
|---|---|---|
400 | validation_error | Invalid request parameters |
401 | unauthorized | Invalid or missing API key |
404 | broker_not_found | Broker connection not found |
409 | duplicate_intent_id | Trade Intent with this intent_id already exists |
422 | unprocessable_entity | Validation error (e.g., missing limit_price) |
429 | rate_limit_exceeded | Too many requests |
500 | internal_server_error | Server error |