{"openapi":"3.0.3","info":{"title":"ArchX CaaS API","version":"1.0.0","description":"Crypto-as-a-Service API for quotes, OTC orders and balances.\n\n**Authentication:** send your API key via `X-Api-Key` header or `Authorization: Bearer <key>`.\nRequests are also checked against the key IP allowlist (when configured).","contact":{"name":"ArchX Capital"}},"servers":[{"url":"https://caas.madarbit.tech","description":"Production"},{"url":"/","description":"Current host"}],"tags":[{"name":"Health","description":"Liveness"},{"name":"Trading","description":"Quotes and orders"},{"name":"Account","description":"Balances"}],"components":{"securitySchemes":{"ApiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Customer API key"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"Same API key as Bearer token"}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","example":"Missing API key"}}},"Health":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"service":{"type":"string","example":"caas-api"},"timestamp":{"type":"string","format":"date-time"}}},"Quote":{"type":"object","properties":{"main_currency":{"type":"string","example":"USDT"},"quote_currency":{"type":"string","example":"BRL"},"side":{"type":"string","enum":["buy","sell"]},"price":{"type":"string","description":"Final price with customer spread","example":"5.20000000"},"price_base":{"type":"string","description":"Pair base price before spread","example":"5.14450000"},"spread_percent":{"type":"number","example":0.3},"spread_applied":{"type":"string","example":"0.01543350"},"customer_id":{"type":"string","format":"uuid"}}},"CreateOrderRequest":{"type":"object","required":["main_currency","quote_currency","side"],"properties":{"main_currency":{"type":"string","example":"USDT"},"quote_currency":{"type":"string","example":"BRL"},"side":{"type":"string","enum":["buy","sell"]},"amount":{"type":"string","description":"Order amount in main currency. Required unless `percentage` is set.","example":"100"},"percentage":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":100,"description":"Optional: use this % of available balance instead of a fixed amount","example":50},"d_level":{"type":"string","enum":["d0","d1","d2"],"description":"Settlement level (optional)"}}},"Order":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"customer_id":{"type":"string"},"account_id":{"type":"string"},"main_currency":{"type":"string"},"quote_currency":{"type":"string"},"amount":{"type":"string"},"fund_amount":{"type":"string"},"fund_amount_buy":{"type":"string"},"fee":{"type":"string"},"status":{"type":"string","enum":["created","pending","done","cancelled","offmarket"]},"side":{"type":"string","enum":["buy","sell"]},"price":{"type":"string"},"price_buy":{"type":"string"},"base_price":{"type":"string"},"spread_percent":{"type":"number"},"spread_applied":{"type":"string"},"d_level":{"type":"string","enum":["d0","d1","d2"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"deleted_at":{"type":"string","nullable":true}}},"Account":{"type":"object","properties":{"id":{"type":"string"},"customer_id":{"type":"string"},"currency":{"type":"string","example":"BRL"},"balance":{"type":"number","example":1500.5},"account_type":{"type":"string"},"status":{"type":"string","example":"active"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"BalancesResponse":{"type":"object","properties":{"customer_id":{"type":"string"},"accounts":{"type":"array","items":{"$ref":"#/components/schemas/Account"}}}}}},"paths":{"/health":{"get":{"tags":["Health"],"summary":"Health check","operationId":"getHealth","security":[],"responses":{"200":{"description":"Service is up","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/v1/quote":{"get":{"tags":["Trading"],"summary":"Get price quote","description":"Returns the OTC pair price with the authenticated customer spread applied.","operationId":"getQuote","security":[{"ApiKeyHeader":[]},{"BearerAuth":[]}],"parameters":[{"name":"main_currency","in":"query","required":true,"schema":{"type":"string","example":"USDT"}},{"name":"quote_currency","in":"query","required":true,"schema":{"type":"string","example":"BRL"}},{"name":"side","in":"query","required":false,"schema":{"type":"string","enum":["buy","sell"],"default":"buy"}}],"responses":{"200":{"description":"Quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Quote"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden (IP or API access)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Pair not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders":{"post":{"tags":["Trading"],"summary":"Create OTC order","description":"Creates a customer OTC order (same flow as dashboard createCustomerOrder).","operationId":"createOrder","security":[{"ApiKeyHeader":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderRequest"}}}},"responses":{"201":{"description":"Order created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"Validation or business rule error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/balances":{"get":{"tags":["Account"],"summary":"List balances","description":"Returns all currency accounts for the authenticated customer.","operationId":"getBalances","security":[{"ApiKeyHeader":[]},{"BearerAuth":[]}],"responses":{"200":{"description":"Balances","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BalancesResponse"}}}},"400":{"description":"Failed to fetch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}