Sarna API — Agent Quickstart
Copy this entire page into your AI coding assistant to integrate with the Sarna API.
Sandbox Credentials
Base URL: https://api.sandbox.sarna.io Authorization: Bearer sandbox_test_xxxx12345 Content-Type: application/json
Golden Workflow: Quote → Order → Positions
1. Get Quote
curl -H "Authorization: Bearer sandbox_test_xxxx12345" \ https://api.sandbox.sarna.io/quote/AAPL
Response: {"Errors":[],"Warnings":[],"HasData":true,"Quote":{"Symbol":"AAPL","Bid":149.85,"Ask":150.10,"Last":150.00}}
2. Place Order
curl -X POST \
-H "Authorization: Bearer sandbox_test_xxxx12345" \
-H "Content-Type: application/json" \
-d '{"AccountId":500123,"Symbol":"AAPL","Quantity":100,"PriceType":"Limit","LimitPrice":-150.25,"Side":"Buy","TimeInForce":"Day"}' \
https://api.sandbox.sarna.io/orders Note: LimitPrice is negative (buy = debit, money out).
Response: {"Errors":[],"HasData":true,"Order":{"OrderId":"ORD-2026031900042","Status":"Pending"}}
3. Check Positions
curl -X POST \
-H "Authorization: Bearer sandbox_test_xxxx12345" \
-H "Content-Type: application/json" \
-d '{"AccountId":500123}' \
https://api.sandbox.sarna.io/positions Response Handling
- Check
Errorsarray — if non-empty, operation failed - Check
Warningsarray — log for user attention - Check
HasData— if false, no results found - Process business data fields
Data Conventions
| Field names | PascalCase (AccountId, OrderId) |
| Financial signs | Negative = debit (buy), Positive = credit (sell) |
| Timestamps | UTC, ISO 8601 |
| Enum value 0 | Undefined/invalid — never use as input |
Common Errors
| 401 | Check Bearer token |
| 429 | Rate limited — exponential backoff |
| 400 | INSUFFICIENT_BUYING_POWER — check balance first |
| 403 | Admin permission required for /admin/* endpoints |