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

  1. Check Errors array — if non-empty, operation failed
  2. Check Warnings array — log for user attention
  3. Check HasData — if false, no results found
  4. Process business data fields

Data Conventions

Field namesPascalCase (AccountId, OrderId)
Financial signsNegative = debit (buy), Positive = credit (sell)
TimestampsUTC, ISO 8601
Enum value 0Undefined/invalid — never use as input

Common Errors

401Check Bearer token
429Rate limited — exponential backoff
400INSUFFICIENT_BUYING_POWER — check balance first
403Admin permission required for /admin/* endpoints

Resources