{"openapi": "3.1.0", "info": {"title": "SplitSettle API", "description": "AI agent expense splitting with on-chain settlement execution. Calculate minimum transfers, then get ABI-encoded calldata to settle debts on Base Sepolia with USDC.", "version": "2.0.0"}, "servers": [{"url": "https://split.redarch.dev", "description": "Production"}], "paths": {"/v1/groups": {"post": {"summary": "Create a wallet group", "description": "Register participant names with EIP-55 checksummed wallet addresses. Used by /v1/split_settle to generate on-chain settlement calldata.", "tags": ["Groups"], "security": [{"ApiKeyAuth": []}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateGroupRequest"}, "example": {"group_id": "trip-tokyo-2026", "participants": [{"name": "Alice", "wallet_address": "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"}, {"name": "Bob", "wallet_address": "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"}]}}}}, "responses": {"200": {"description": "Group created", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateGroupResponse"}}}}, "400": {"description": "Invalid input (bad wallet address, missing fields)"}, "409": {"description": "Group ID already exists"}}}}, "/v1/split_settle": {"post": {"summary": "Calculate settlement plan (+ optional execution calldata)", "description": "Given participants and expenses, returns minimum transfers to settle all debts. When group_id is provided, also returns ABI-encoded ERC-20 transfer calldata for on-chain settlement on Base Sepolia.", "tags": ["Settlement"], "security": [{"ApiKeyAuth": []}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SplitSettleRequest"}, "examples": {"basic": {"summary": "Basic split (no on-chain)", "value": {"currency": "TWD", "participants": ["Alice", "Bob", "Carol"], "expenses": [{"description": "Dinner", "paid_by": "Alice", "amount": 1200, "split_among": ["Alice", "Bob", "Carol"]}, {"description": "Taxi", "paid_by": "Bob", "amount": 300, "split_among": ["Alice", "Bob", "Carol"]}]}}, "with_group": {"summary": "With group_id (returns calldata)", "value": {"currency": "USD", "group_id": "trip-tokyo-2026", "participants": ["Alice", "Bob"], "expenses": [{"description": "Hotel", "paid_by": "Alice", "amount": 200, "split_among": ["Alice", "Bob"]}]}}}}}}, "responses": {"200": {"description": "Settlement plan (with optional execution block)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SplitSettleResponse"}}}}, "400": {"description": "Invalid request"}, "402": {"description": "Payment required (x402)"}, "403": {"description": "Invalid or missing API key"}}}}, "/health": {"get": {"summary": "Health check", "tags": ["System"], "responses": {"200": {"description": "OK"}}}}}, "components": {"securitySchemes": {"ApiKeyAuth": {"type": "apiKey", "in": "header", "name": "x-api-key"}}, "schemas": {"GroupParticipant": {"type": "object", "required": ["name", "wallet_address"], "properties": {"name": {"type": "string"}, "wallet_address": {"type": "string", "description": "EIP-55 checksummed Ethereum address"}}}, "CreateGroupRequest": {"type": "object", "required": ["group_id", "participants"], "properties": {"group_id": {"type": "string", "description": "Lowercase alphanumeric + hyphens, 2-64 chars"}, "participants": {"type": "array", "items": {"$ref": "#/components/schemas/GroupParticipant"}, "minItems": 2, "maxItems": 20}}}, "CreateGroupResponse": {"type": "object", "properties": {"group_id": {"type": "string"}, "participants": {"type": "integer"}, "created_at": {"type": "string", "format": "date-time"}}}, "Expense": {"type": "object", "required": ["paid_by", "amount", "split_among"], "properties": {"description": {"type": "string"}, "paid_by": {"type": "string"}, "amount": {"type": "number", "exclusiveMinimum": 0}, "split_among": {"type": "array", "items": {"type": "string"}, "minItems": 1}}}, "SplitSettleRequest": {"type": "object", "required": ["currency", "participants", "expenses"], "properties": {"currency": {"type": "string", "description": "ISO 4217 currency code"}, "group_id": {"type": "string", "description": "Optional: include to get on-chain execution calldata"}, "participants": {"type": "array", "items": {"type": "string"}, "minItems": 2, "maxItems": 20}, "expenses": {"type": "array", "items": {"$ref": "#/components/schemas/Expense"}, "minItems": 1}}}, "ParticipantSummary": {"type": "object", "properties": {"participant": {"type": "string"}, "total_paid": {"type": "number"}, "total_owed": {"type": "number"}, "balance": {"type": "number"}}}, "Settlement": {"type": "object", "properties": {"from": {"type": "string"}, "to": {"type": "string"}, "amount": {"type": "number"}}}, "Transfer": {"type": "object", "properties": {"from_wallet": {"type": "string"}, "to_wallet": {"type": "string"}, "amount_wei": {"type": "string"}, "calldata": {"type": "string", "description": "ABI-encoded ERC-20 transfer(address,uint256)"}}}, "ExecutionBlock": {"type": "object", "properties": {"network": {"type": "string"}, "token_contract": {"type": "string"}, "transfers": {"type": "array", "items": {"$ref": "#/components/schemas/Transfer"}}, "note": {"type": "string"}}}, "SplitSettleResponse": {"type": "object", "properties": {"currency": {"type": "string"}, "summary": {"type": "array", "items": {"$ref": "#/components/schemas/ParticipantSummary"}}, "settlements": {"type": "array", "items": {"$ref": "#/components/schemas/Settlement"}}, "total_expenses": {"type": "number"}, "num_settlements": {"type": "integer"}, "execution": {"$ref": "#/components/schemas/ExecutionBlock", "description": "Present only when group_id is provided"}}}}}}