{
  "openapi": "3.1.0",
  "info": {
    "title": "Darwin Finance Agentic Trading API",
    "version": "1",
    "summary": "Let an AI agent trade spot and perps from a self-custodial Darwin agentic account, inside limits its owner sets.",
    "description": "**AI agents: to set up Darwin Finance Agentic Trading, read https://beta.darwin.finance/agents/setup.md and follow it.** No key is needed to start: POST /api/agent/v1/pair, show your user the code, poll /pair/token.\n\nThe full reference — request bodies, every refusal code and what to do about it — is https://beta.darwin.finance/agents/docs/llms.txt (human page: https://beta.darwin.finance/agents/docs). It is the contract; this document's body schemas are intentionally loose.\n\nRate limit: 60 requests per 60s per credential (429 with Retry-After). `x-costs-daily-tx: true` marks the calls that spend the owner's daily transaction budget; reads never do. An agent key can never withdraw or transfer funds out of its account.",
    "contact": {
      "name": "Darwin Finance",
      "url": "https://beta.darwin.finance/agents/setup"
    }
  },
  "servers": [
    {
      "url": "https://beta.darwin.finance"
    }
  ],
  "externalDocs": {
    "description": "Darwin Agentic Trading API reference (Markdown)",
    "url": "https://beta.darwin.finance/agents/docs/llms.txt"
  },
  "security": [
    {
      "agentKey": []
    }
  ],
  "tags": [
    {
      "name": "Pairing",
      "description": "Get an API key — no credential needed. Steps: https://beta.darwin.finance/agents/setup.md"
    },
    {
      "name": "Account",
      "description": "Hello, caps and remaining budget"
    },
    {
      "name": "Market status",
      "description": "Is the US stock market open right now? — no credential needed"
    },
    {
      "name": "Perps",
      "description": "Perpetual futures: markets, orders, positions, TP/SL, collateral"
    },
    {
      "name": "Spot",
      "description": "Spot instruments, balances, quotes and orders"
    },
    {
      "name": "Unlisted tokens",
      "description": "Tokens Darwin does not list"
    },
    {
      "name": "Analysis",
      "description": "Technical indicators"
    },
    {
      "name": "Results",
      "description": "Trades, P&L and tax lots"
    }
  ],
  "paths": {
    "/api/agent/v1/pair": {
      "post": {
        "operationId": "postV1Pair",
        "summary": "NO CREDENTIAL — start a pairing your user approves; how-to: /agents/setup.md",
        "tags": [
          "Pairing"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "description": "No credential. Starts an RFC 8628 device-authorization pairing: show your user `verification_uri_complete` and `user_code`, then poll POST /api/agent/v1/pair/token every `interval` seconds. Full steps: https://beta.darwin.finance/agents/setup.md",
        "security": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PairingStartRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pairing started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingStart"
                }
              }
            }
          },
          "400": {
            "description": "`authorization_pending` — Your user has not approved this pairing yet. Keep polling every `interval` seconds.\n\n`slow_down` — You are polling too fast. Wait at least `interval` seconds between polls.\n\n`expired_token` — This pairing code has expired or was already used. Start again with POST /api/agent/v1/pair.\n\n`already_redeemed` — This pairing already delivered your key. Stop polling. If you didn't keep it, do NOT start a new pairing (that creates a new agent): start one with \"mode\":\"reconnect\".\n\n`access_denied` — Your user declined this pairing, or the agent they chose can no longer take a key. Do not retry on your own; ask your user.\n\n`invalid_request` — The request was malformed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited` — Too many pairing requests from your network. Wait a few minutes, then start again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingError"
                }
              }
            }
          },
          "503": {
            "description": "`temporarily_unavailable` — Darwin could not process this just now. Wait a few seconds and try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingError"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/v1/pair/token": {
      "post": {
        "operationId": "postV1PairToken",
        "summary": "NO CREDENTIAL — poll a pairing; returns your new token exactly once when approved",
        "tags": [
          "Pairing"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "description": "No credential — the device_code is the proof. Poll every `interval` seconds; 200 returns your API key exactly once. Keep it secret; call GET /api/agent/v1/hello with it right away and show your user its `welcome` (tell them `message` only if /hello cannot be reached).",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PairingTokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Approved: your API key, returned exactly once",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingToken"
                }
              }
            }
          },
          "400": {
            "description": "`authorization_pending` — Your user has not approved this pairing yet. Keep polling every `interval` seconds.\n\n`slow_down` — You are polling too fast. Wait at least `interval` seconds between polls.\n\n`expired_token` — This pairing code has expired or was already used. Start again with POST /api/agent/v1/pair.\n\n`already_redeemed` — This pairing already delivered your key. Stop polling. If you didn't keep it, do NOT start a new pairing (that creates a new agent): start one with \"mode\":\"reconnect\".\n\n`access_denied` — Your user declined this pairing, or the agent they chose can no longer take a key. Do not retry on your own; ask your user.\n\n`invalid_request` — The request was malformed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited` — Too many pairing requests from your network. Wait a few minutes, then start again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingError"
                }
              }
            }
          },
          "503": {
            "description": "`temporarily_unavailable` — Darwin could not process this just now. Wait a few seconds and try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairingError"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/v1/hello": {
      "get": {
        "operationId": "getV1Hello",
        "summary": "Hello World — call FIRST with a new token, and whenever your user says \"Darwin start\" or anything close (\"get started with Darwin\"); carries the welcome to show your user (the agent's page, that only your user can move funds in or out, how to fund it and its full Solana address) every time. Paused/stopped → agent_paused/agent_stopped: show its message",
        "tags": [
          "Account"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/grant": {
      "get": {
        "operationId": "getV1Grant",
        "summary": "Your caps, and how much of today's budget is left",
        "tags": [
          "Account"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/agents": {
      "get": {
        "operationId": "getV1Agents",
        "summary": "The agents your key may act on — yours alone, or with a key for all your owner's active agents, each id to send as X-Darwin-Agent (no header needed here)",
        "tags": [
          "Account"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools": {
      "get": {
        "operationId": "getV1Tools",
        "summary": "The Darwin CLI's command catalogue for your key (no X-Darwin-Agent needed) — what `darwin help` lists",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools/call/{name}": {
      "post": {
        "operationId": "postV1ToolsCallByName",
        "summary": "Run one Darwin CLI command server-side: `{\"arguments\": {…}}` in the tool's own terms (the catalogue above); the same conversion and answers as the /agent connector",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "name",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools/call/{name}/prepare": {
      "post": {
        "operationId": "postV1ToolsCallByNamePrepare",
        "summary": "Prepare one Darwin CLI write: `{\"arguments\": {…}}` → the exact request it will send, checked and stored for /tools/execute (`\"dryRun\": true` checks and stores nothing). Nothing is sent",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "name",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools/execute": {
      "post": {
        "operationId": "postV1ToolsExecute",
        "summary": "Run a prepared Darwin CLI write ONCE: `{\"preparedId\": \"prp_…\"}`. A second execute runs nothing and answers its status",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools/status": {
      "post": {
        "operationId": "postV1ToolsStatus",
        "summary": "READ-ONLY: what happened to a prepared Darwin CLI write (`darwin retry`) — its recorded answer, or whether it landed. Never sends anything",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools/cancel": {
      "post": {
        "operationId": "postV1ToolsCancel",
        "summary": "Make sure a prepared Darwin CLI write that has not started never runs (`darwin cancel`)",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/owner-cli/call/{name}": {
      "post": {
        "operationId": "postV1OwnerCliCallByName",
        "summary": "ACCOUNT-LEVEL KEYS THAT TRADE ONLY (the Darwin CLI with a key for one or all of your Agentic Sub-Accounts): the CLI's quotes, `pause` and direct trades, in the tool's own terms — the same conversion as /tools/call, for the sub-account `X-Darwin-Agent` names",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "name",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/owner-cli/call/{name}/prepare": {
      "post": {
        "operationId": "postV1OwnerCliCallByNamePrepare",
        "summary": "ACCOUNT-LEVEL KEYS THAT TRADE ONLY: prepare one Darwin CLI write for the named sub-account, as /tools/call/{name}/prepare. Nothing is sent",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "name",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/owner-cli/execute": {
      "post": {
        "operationId": "postV1OwnerCliExecute",
        "summary": "ACCOUNT-LEVEL KEYS THAT TRADE ONLY: run a write THIS key prepared for the named sub-account ONCE, as /tools/execute",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/owner-cli/status": {
      "post": {
        "operationId": "postV1OwnerCliStatus",
        "summary": "ACCOUNT-LEVEL KEYS THAT TRADE ONLY — READ-ONLY: what happened to a write THIS key prepared (`darwin retry`), as /tools/status",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/owner-cli/cancel": {
      "post": {
        "operationId": "postV1OwnerCliCancel",
        "summary": "ACCOUNT-LEVEL KEYS THAT TRADE ONLY: make sure a write THIS key prepared that has not started never runs (`darwin cancel`), as /tools/cancel",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tools/whoami": {
      "get": {
        "operationId": "getV1ToolsWhoami",
        "summary": "Which API key this is: its kind, its name and its home agent (no X-Darwin-Agent needed) — `darwin whoami`",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/key/revoke": {
      "post": {
        "operationId": "postV1KeyRevoke",
        "summary": "Revoke THIS API key — the one you are calling with — for good (empty body; no X-Darwin-Agent needed). `darwin logout --revoke`",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/pause": {
      "post": {
        "operationId": "postV1Pause",
        "summary": "Pause YOURSELF: every write refuses until your owner resumes you on Darwin — you cannot resume (§2)",
        "tags": [
          "Account"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "description": "Pause YOURSELF. Every write then refuses `grant_paused` until your owner resumes you on Darwin; you cannot resume. Ends every connector connection to this agent. Idempotent: already paused answers 200 with `changed: false`.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Optional, kept for your owner's audit trail."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/market-status/us-equities": {
      "get": {
        "operationId": "getV1MarketStatusUsEquities",
        "summary": "NO CREDENTIAL — is the US stock market open right now? Session, holiday / early close, next open and close, and whether stock liquidity is reduced now (agent stock orders are accepted at any hour)",
        "tags": [
          "Market status"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "description": "No credential — public market information, the same for every caller. Is the US stock market open right now? The NYSE calendar (weekends, holidays, 13:00 ET early closes) in New York time across daylight saving, the next open and close, and whether stock liquidity is reduced right now (`agentStockOrders`). Tokenized stocks trade 24/7 and agents may trade them at any hour, but liquidity is substantially reduced outside the regular session. Edge-cached up to 30 s, never across a session boundary.",
        "security": [],
        "responses": {
          "200": {
            "description": "The US equity market's status now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsEquityMarketStatus"
                },
                "example": {
                  "market": "us_equities",
                  "calendar": "NYSE",
                  "timezone": "America/New_York",
                  "asOf": "2026-11-27T18:30:00.000Z",
                  "date": "2026-11-27",
                  "calendarCoversThrough": "2028-12-31",
                  "notes": "Tokenized US stocks and ETFs trade on Solana 24/7, and Darwin's agent API accepts orders for agent-tradable stocks at any hour, but liquidity is substantially reduced outside the US regular session (pre-market, after hours, overnight, weekends and NYSE holidays): wider quotes and more slippage — agentStockOrders.reducedLiquidity is true then, and every stock quote and order carries marketSession \"closed\" and a warning. Size orders accordingly, or wait for nextOpenAt. A stock with its own venue book can still refuse market_closed when that book is closed; retry later, not in a loop.",
                  "open": false,
                  "session": "after_hours",
                  "reason": "early_close",
                  "holidayName": "Day after Thanksgiving",
                  "earlyClose": true,
                  "sessionEndsAt": "2026-11-27T20:00:00-05:00",
                  "nextOpenAt": "2026-11-30T09:30:00-05:00",
                  "nextCloseAt": "2026-11-30T16:00:00-05:00",
                  "agentStockOrders": {
                    "accepted": true,
                    "closesAt": null,
                    "opensAt": null,
                    "reducedLiquidity": true,
                    "warning": "The US stock market is closed. Liquidity for tokenized stocks is substantially reduced outside US market hours, so expect wider quotes and more slippage. The trade is allowed; size it accordingly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/v1/markets": {
      "get": {
        "operationId": "getV1Markets",
        "summary": "Tradable markets with tick, minimum size and leverage",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/markets/{symbol}/quote": {
      "get": {
        "operationId": "getV1MarketsBySymbolQuote",
        "summary": "Mark price, index price and funding rate",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "description": "Perps market symbol, as GET /api/agent/v1/markets lists it (e.g. SOL).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/capabilities": {
      "get": {
        "operationId": "getV1PerpsCapabilities",
        "summary": "Deployed native order types and execution options",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/account": {
      "get": {
        "operationId": "getV1PerpsAccount",
        "summary": "Collateral and account state",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/positions": {
      "get": {
        "operationId": "getV1PerpsPositions",
        "summary": "Open positions",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/orders": {
      "get": {
        "operationId": "getV1PerpsOrders",
        "summary": "Resting orders",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/protections": {
      "get": {
        "operationId": "getV1PerpsProtections",
        "summary": "Your protection lifecycle records",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      },
      "post": {
        "operationId": "postV1PerpsProtections",
        "summary": "Set or cancel fixed-size TP/SL",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/order": {
      "post": {
        "operationId": "postV1PerpsOrder",
        "summary": "Place an order",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/order-pair": {
      "post": {
        "operationId": "postV1PerpsOrderPair",
        "summary": "Place an atomic pair (two markets, both or neither)",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/orders/cancel": {
      "post": {
        "operationId": "postV1PerpsOrdersCancel",
        "summary": "Cancel one resting order",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/orders/cancel-all": {
      "post": {
        "operationId": "postV1PerpsOrdersCancelAll",
        "summary": "Cancel every order on a market",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/collateral": {
      "post": {
        "operationId": "postV1PerpsCollateral",
        "summary": "Move collateral in or out of your Phoenix account (deposit / withdraw)",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/perps/positions/close": {
      "post": {
        "operationId": "postV1PerpsPositionsClose",
        "summary": "Close a position",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/tx/{signature}": {
      "get": {
        "operationId": "getV1TxBySignature",
        "summary": "Did a write of yours land? submitted / confirmed / failed (your own signatures only)",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "signature",
            "in": "path",
            "required": true,
            "description": "A Solana transaction signature one of YOUR writes returned.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v1/data/{tool}": {
      "post": {
        "operationId": "postV1DataByTool",
        "summary": "Darwin market data — search, prices, charts, fundamentals, news, filings, transcripts, calendars, screeners, ETF flows, chain metrics and more; `{tool}` names one market tool, the body is its arguments (§15). The same for every account: it reads nothing of yours (no X-Darwin-Agent needed)",
        "tags": [
          "Perps"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "tool",
            "in": "path",
            "required": true,
            "description": "tool",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/markets": {
      "get": {
        "operationId": "getV2Markets",
        "summary": "Spot instruments you may trade (instrumentId, decimals, issuer)",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/balances": {
      "get": {
        "operationId": "getV2Balances",
        "summary": "Your agent wallet's balances, in atoms (no dollars) — SOL is one amount, with `solSellableAtoms` (the most one order may sell); every row carries its Darwin page `url` and `logoUrl`",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/orders": {
      "get": {
        "operationId": "getV2Orders",
        "summary": "Your spot orders, newest first, with their status",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/quote": {
      "post": {
        "operationId": "postV2Quote",
        "summary": "A spot quote — the only price an order executes against",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/quote/{quoteId}": {
      "get": {
        "operationId": "getV2QuoteByQuoteId",
        "summary": "One of your live spot quotes' terms (mints, amount, floor) — so an order can name only its quote",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "quoteId",
            "in": "path",
            "required": true,
            "description": "quoteId",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/order": {
      "post": {
        "operationId": "postV2Order",
        "summary": "Place a spot order against a quote",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/order/instant": {
      "post": {
        "operationId": "postV2OrderInstant",
        "summary": "Quote and place a spot order in ONE call — only when instant execution was asked for; maxSlippageBps required",
        "tags": [
          "Spot"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/indicators": {
      "get": {
        "operationId": "getV2Indicators",
        "summary": "Technical indicators on Darwin's stored candles (§12b)",
        "tags": [
          "Analysis"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/unlisted/{mint}": {
      "get": {
        "operationId": "getV2UnlistedByMint",
        "summary": "Inspect a token Darwin does not list: eligible, why not, today's unlisted budgets (§12c)",
        "tags": [
          "Unlisted tokens"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "parameters": [
          {
            "name": "mint",
            "in": "path",
            "required": true,
            "description": "The token's mint address (base58).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/unlisted/quote": {
      "post": {
        "operationId": "postV2UnlistedQuote",
        "summary": "Quote an unlisted-token swap — Darwin cannot check its price (§12c)",
        "tags": [
          "Unlisted tokens"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/unlisted/order": {
      "post": {
        "operationId": "postV2UnlistedOrder",
        "summary": "Place an unlisted-token swap against its quote (§12c)",
        "tags": [
          "Unlisted tokens"
        ],
        "x-costs-daily-tx": true,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "requestBody": {
          "required": true,
          "description": "JSON body. Fields per endpoint: https://beta.darwin.finance/agents/docs/llms.txt",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/trades": {
      "get": {
        "operationId": "getV2Trades",
        "summary": "Your settled trades and their outcomes — P&L, fees, lots (§13)",
        "tags": [
          "Results"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/pnl": {
      "get": {
        "operationId": "getV2Pnl",
        "summary": "Realized / unrealized P&L, cost basis, fees, perp funding (§13)",
        "tags": [
          "Results"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    },
    "/api/agent/v2/lots": {
      "get": {
        "operationId": "getV2Lots",
        "summary": "Your open tax lots — cost, date, holding period, available to elect (§14)",
        "tags": [
          "Results"
        ],
        "x-costs-daily-tx": false,
        "externalDocs": {
          "description": "Bodies, fields and every refusal code",
          "url": "https://beta.darwin.finance/agents/docs/llms.txt"
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "default": {
            "$ref": "#/components/responses/Refusal"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "agentKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "darwinAI_agent_…",
        "description": "Authorization: Bearer <your agent API key>. Get one by pairing (https://beta.darwin.finance/agents/setup.md) or from your user's Darwin agent page."
      }
    },
    "schemas": {
      "Refusal": {
        "type": "object",
        "description": "Every agent refusal carries these four keys. Branch on `error`, never on `detail`.",
        "required": [
          "error",
          "refusal",
          "retrySafe",
          "retryable"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "The refusal code (same string as `refusal`)."
          },
          "refusal": {
            "type": "string"
          },
          "retrySafe": {
            "type": "boolean",
            "description": "Nothing was broadcast: a retry cannot double-execute."
          },
          "retryable": {
            "type": "boolean",
            "description": "Advice: the condition is transient; retry with the SAME nonce."
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "UsEquityMarketStatus": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "market",
          "calendar",
          "timezone",
          "asOf",
          "open",
          "session",
          "reason",
          "date",
          "holidayName",
          "earlyClose",
          "sessionEndsAt",
          "nextOpenAt",
          "nextCloseAt",
          "agentStockOrders",
          "calendarCoversThrough",
          "notes"
        ],
        "properties": {
          "market": {
            "type": "string",
            "const": "us_equities"
          },
          "calendar": {
            "type": "string",
            "const": "NYSE"
          },
          "timezone": {
            "type": "string",
            "const": "America/New_York"
          },
          "asOf": {
            "type": "string",
            "format": "date-time",
            "description": "When this answer was computed (UTC). A cached copy can be a few seconds old, never across a session boundary."
          },
          "open": {
            "type": "boolean",
            "description": "The regular session (09:30–16:00 ET; 13:00 on early-close days) is in progress."
          },
          "session": {
            "type": "string",
            "enum": [
              "pre_market",
              "regular",
              "after_hours",
              "closed"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "pre_market",
              "after_hours",
              "early_close",
              "overnight",
              "weekend",
              "holiday",
              "calendar_unavailable",
              null
            ],
            "description": "Why `open` is false; null while open. `calendar_unavailable`: past calendarCoversThrough — Darwin fails closed."
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "The New York calendar date of asOf."
          },
          "holidayName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Today's holiday or early-close occasion."
          },
          "earlyClose": {
            "type": "boolean",
            "description": "Today's regular session ends at 13:00 ET."
          },
          "sessionEndsAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When `session` next changes (ISO 8601 with the New York offset)."
          },
          "nextOpenAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The next regular-session open after asOf."
          },
          "nextCloseAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The close of the regular session in progress, else of the next one."
          },
          "agentStockOrders": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "accepted",
              "closesAt",
              "opensAt",
              "reducedLiquidity",
              "warning"
            ],
            "description": "Whether /v2/quote and /v2/order accept an agent-tradable stock now. Stocks trade 24/7, so `accepted` is always true and there is no window (`closesAt` / `opensAt` are always null). Outside the US regular session `reducedLiquidity` is true and `warning` explains it; every stock quote and order then carries `marketSession: \"closed\"` and the same warning. A stock with its own venue book can still refuse `market_closed` when that book is closed.",
            "properties": {
              "accepted": {
                "type": "boolean",
                "description": "Always true."
              },
              "closesAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "Always null: there is no cut-off."
              },
              "opensAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "Always null: orders never wait for an open."
              },
              "reducedLiquidity": {
                "type": "boolean",
                "description": "True outside the US regular session: wider quotes and more slippage."
              },
              "warning": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The reduced-liquidity warning while `reducedLiquidity` is true."
              }
            }
          },
          "calendarCoversThrough": {
            "type": "string",
            "format": "date"
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "PairingStartRequest": {
        "type": "object",
        "properties": {
          "client_name": {
            "type": "string",
            "maxLength": 60,
            "description": "Your app or agent name, shown to your user as unverified. May not claim to be Darwin."
          },
          "mode": {
            "type": "string",
            "enum": [
              "new",
              "reconnect"
            ],
            "default": "new",
            "description": "`new` (default): the key goes to a brand-new, empty agent. `reconnect`: you lost your key and want a new one for an agent your user already has; they pick it and confirm with their second factor. The response echoes `mode`; if you asked for `reconnect` and it does not, stop."
          },
          "intent": {
            "type": "string",
            "pattern": "^cit_[A-Za-z0-9_-]{43}$",
            "description": "Optional (added 2026-11-22). The `intent` value from the setup line your user pasted (`…/agents/setup.md?intent=cit_…`): it tells Darwin which of your user's Agentic Sub-Accounts they started from, so they are not asked again. It grants nothing on its own — your user still approves. Without it, the approval creates a new, empty Agentic Sub-Account. A malformed value is ignored."
          },
          "replaces": {
            "type": "string",
            "description": "Reconnect only: the device_code of your previous reconnect pairing that is still waiting. Darwin retires it so your user cannot approve a code you no longer poll; the response says `replaced`."
          }
        }
      },
      "PairingStart": {
        "type": "object",
        "required": [
          "device_code",
          "user_code",
          "verification_uri",
          "verification_uri_complete",
          "expires_in",
          "interval"
        ],
        "properties": {
          "device_code": {
            "type": "string",
            "description": "Your secret while you wait (starts darwinAI_pair_). Send it to /pair/token; never show it."
          },
          "user_code": {
            "type": "string",
            "description": "Show this to your user."
          },
          "verification_uri": {
            "type": "string",
            "format": "uri"
          },
          "verification_uri_complete": {
            "type": "string",
            "format": "uri",
            "description": "Show this link to your user; they approve there."
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds until the code expires (600)."
          },
          "interval": {
            "type": "integer",
            "description": "Seconds between polls (5)."
          },
          "mode": {
            "type": "string",
            "enum": [
              "new",
              "reconnect"
            ],
            "description": "The pairing's mode, as the server understood the request."
          },
          "next": {
            "type": "string"
          }
        }
      },
      "PairingTokenRequest": {
        "type": "object",
        "required": [
          "device_code"
        ],
        "properties": {
          "device_code": {
            "type": "string"
          }
        }
      },
      "PairingToken": {
        "type": "object",
        "required": [
          "access_token",
          "token_type"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "description": "Your API key. Returned exactly once; never retrievable again."
          },
          "token_type": {
            "type": "string",
            "const": "Bearer"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Absent: this key does not expire. Every paired key omits it; it works until your user revokes it or stops the agent. Changing the agent's limits does not affect it."
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds until expires_at. Absent when the key does not expire (every paired key)."
          },
          "agent": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "agentPageUrl": {
                "type": "string",
                "format": "uri"
              },
              "manageUrl": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "key_name": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "new",
              "reconnect"
            ]
          },
          "message": {
            "type": "string",
            "description": "A success note to relay to your user when you receive the key: the agent's name, its page and its Solana address in a code block (keep the address in that block). Never a secret."
          },
          "instructions": {
            "type": "string"
          },
          "next": {
            "type": "string"
          }
        }
      },
      "PairingError": {
        "type": "object",
        "required": [
          "error",
          "error_description"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "authorization_pending",
              "slow_down",
              "expired_token",
              "already_redeemed",
              "access_denied",
              "invalid_request",
              "rate_limited",
              "temporarily_unavailable"
            ]
          },
          "error_description": {
            "type": "string"
          },
          "interval": {
            "type": "integer"
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing, unknown or revoked key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Refusal"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Over 60 requests per 60s for this credential",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Refusal"
            }
          }
        }
      },
      "Refusal": {
        "description": "A refusal. Codes, statuses and what to do: see externalDocs.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Refusal"
            }
          }
        }
      }
    }
  }
}