REST API Reference
This section documents B2B endpoints under /api/v1.
Scope
- Includes only B2B endpoints from
modules/integrations/b2b - Excludes portal authentication/session endpoints
External user id (userId / externalUserId)
Across most B2B routes, the JSON field or path parameter userId is the external user id your integration uses for that user (for example client-user-001). Sonar maps it to an internal user.
Exception: POST /users uses the JSON field externalUserId for the same value (see Users — POST /users request body). The SDK createOrUpdate also uses externalUserId.
Domains
- Users — Users: registration, lookup, native balances,
getUserPools,getTokenBalance - Pools — Pools:
getUserPools,getClientPools,GET /pools/{poolId} - Strategies — Strategies:
- Create: four
createStrategy*routes (DCA buy/sell, volume buy/sell) - Update: four
setStrategy*routes - Read: list, filter, dashboard stats, get by id
- Lifecycle: halt, archive, suspend/resume/stop, change balance, duplicate, bulk remove, disable/remove all (see lifecycle table)
- Create: four
- Operations — Operations: transaction history, claim history, deposits (including bulk, retry, cancel,
depositAndCreateStrategy), withdraws, quotes (getEvmQuote,getSolQuote), swaps
See Authentication for which routes require portal 2FA (403 when not enabled).
OpenAPI
| Source | Location |
|---|---|
| Checked-in snapshot | openapi/integrations-v1.json |
| Live Swagger (staging) | integration-be Swagger UI |
| Live spec JSON (staging) | https://p01--integration-be--kk8g24mq2rc2.code.run/api/docs-json |
yarn sync:openapi
# or: OPENAPI_URL=http://localhost:3100/api/docs-json yarn sync:openapiSDK setup
Use SonarClient from @sonar/api-sdk:
import { SonarClient } from "@sonar/api-sdk";
const client = new SonarClient({
baseUrl: "https://partners.sonar.trade/api",
apiKey: process.env.SONAR_API_KEY!,
apiSecret: process.env.SONAR_API_SECRET!,
});