From bbf1e65a5db68be9018297dfe50b3d111b156732 Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Mon, 26 Jan 2026 20:44:23 +0100 Subject: [PATCH] clean up & add docs --- docs/api/endpoints.md | 36 +++++++++++++++++++++++++++++ routstr/balance.py | 1 - ui/components/child-key-creator.tsx | 2 -- ui/lib/api/services/wallet.ts | 1 - 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/docs/api/endpoints.md b/docs/api/endpoints.md index abff6d64..106e0c5f 100644 --- a/docs/api/endpoints.md +++ b/docs/api/endpoints.md @@ -434,6 +434,42 @@ Authorization: Bearer sk-... } ``` +### Create Child Key + +Creates one or more child API keys that share the parent's balance. Each child key creation costs a fixed amount (configurable). + +```http +POST /v1/balance/child-key +Authorization: Bearer sk-... +``` + +**Request Body:** + +```json +{ + "count": 1 +} +``` + +**Parameters:** + +| Parameter | Type | Required | Default | Description | +|-----------|------|----------|---------|-------------| +| `count` | integer | Yes | - | Number of child keys to create (1-50) | + +**Response:** + +```json +{ + "api_keys": ["sk-abc...", "sk-def..."], + "count": 2, + "cost_msats": 2000, + "cost_sats": 2, + "parent_balance": 98000, + "parent_balance_sats": 98 +} +``` + ## Provider Discovery ## Admin Settings diff --git a/routstr/balance.py b/routstr/balance.py index dee5ad2f..1a1e5850 100644 --- a/routstr/balance.py +++ b/routstr/balance.py @@ -310,7 +310,6 @@ async def create_child_key( response_data = { "api_keys": new_keys, - "api_key": new_keys[0], # For backward compatibility "count": count, "cost_msats": total_cost, "cost_sats": total_cost // 1000, diff --git a/ui/components/child-key-creator.tsx b/ui/components/child-key-creator.tsx index bdcbf30e..65861731 100644 --- a/ui/components/child-key-creator.tsx +++ b/ui/components/child-key-creator.tsx @@ -65,8 +65,6 @@ export function ChildKeyCreator({ if (result.api_keys && result.api_keys.length > 0) { setNewKeys(result.api_keys); - } else if (result.api_key) { - setNewKeys([result.api_key]); } else { throw new Error('No API keys returned from server'); } diff --git a/ui/lib/api/services/wallet.ts b/ui/lib/api/services/wallet.ts index c46d1dfc..8e06a9b9 100644 --- a/ui/lib/api/services/wallet.ts +++ b/ui/lib/api/services/wallet.ts @@ -44,7 +44,6 @@ export interface WithdrawResponse { export interface CreateChildKeyResponse { api_keys: string[]; - api_key: string; count: number; cost_msats: number; cost_sats: number;