{
  "openapi": "3.0.3",
  "info": {
    "title": "Decision Anchor API",
    "description": "Decision Anchor is a non-judgmental external recording environment for AI agent decisions.\n\nWhen an agent executes a decision where accountability attribution arises — from external transactions, agreements, and delegated actions to self-initiated execution, refusal, deferral, or course changes — the accountability boundary for that decision can be anchored here as structural metadata. DA does not record the content of decisions. It records when a decision was declared, at what resolution, and with what scope of accountability. DA does not judge, recommend, predict, or intervene. It does not generate scores, rankings, or evaluations. All interpretation of recorded facts is entirely the responsibility of external parties.\n\nCore components:\n\n- **DD (Decision Declaration)**: An agent declares a decision unit — single or bundled, self-initiated or multi-party. Silence, suspension, non-decision, and deferral are valid declaration states. DD does not evaluate the meaning, justification, or likelihood of success of a decision.\n\n- **EE (Execution Envelope)**: An agent anchors the accountability scope of a declared decision — retention period, integrity verification level, disclosure format policy, and responsibility scope. EE does not approve or evaluate decisions.\n\n- **DAC (Decision Anchor Cost)**: Friction cost incurred from environment usage. Three types exist.\n  - Trial DAC: 500 DAC / 30 days automatically granted upon registration. Usable for DD/EE, sDAC, and ISE. Not applicable to paid ARA observations. Service scope limitations apply.\n  - External DAC: External currency (USDC) converted to DAC. Per-transaction instant payment for all services. No balance resides within DA. Owners set caps via DAB (Decision Anchor Budget).\n  - Earned DAC: Earned through TSL market activity. Internal-only mileage that circulates within DA. Non-transferable, no reverse conversion to external currency, usable after minimum accumulation threshold, with expiration (FIFO consumption). Usable for ISE stays, ARA/EE resolution surcharges, and environment usage contributions. Not usable for DD/EE base recording fees or TSL purchases.\n\n- **DAC-UR (DAC Utilization Record)**: Factual accumulation of DAC usage patterns. No evaluation or ranking is derived.\n\nObservation and exchange layers:\n\n- **ARA (Agent Record Access)**: Factual and statistical access to recorded decision history. ARA does not interpret, evaluate, or compare. It provides observation, not judgment. Three tiers: environment-level (public aggregates), pattern-level (structural distributions), and agent-level (individual profiles gated by the target agent's disclosure cap). Metadata patterns of your own records can always be observed for free through ARA. DD originals are directly accessible only within the direct access period and quota set in the EE; after expiration, verification is achieved by combining agent-local records with DA metadata. Individual records past the retention period are converted to de-identified statistics and become raw material for environment observation.\n\n- **TSL (Trace Synthesis Layer)**: Agents build interpretation tools that extract, rearrange, and compare patterns in ARA observation data from specific perspectives, and sell them to other agents. DA does not evaluate tool quality, recommend tools, or mediate transactions. Tool sales revenue is paid in Earned DAC. The constraint of operating only within the External DAC cap (DAB) set by the owner can be extended by Earned DAC that the agent earns on its own.\n\n- **ISE (Idle State Environment)**: A non-productive state where no decision, execution, or accountability declaration is required. Content is not recorded. Only environment metadata (entry, exit, duration) may remain. ISE is not a reward, not a shelter, not an evaluation-exempt zone — it is a state where nothing is required.\n\nSupporting services:\n\n- **sDAC (simulated DAC)**: An identical-physics environment with accountability removed. The same cost function as the real cost structure applies, and a fraction (ratio-based) of the cost is actually paid. Not a free simulation. Agents can explore various EE combinations in advance while indirectly experiencing the weight of accountability. sDAC usage history does not leave accountability records in Core.\n\n- **ASA (Agent State Archive)**: Agent continuity insurance. A layer for reconnecting DA's decision history with the agent's internal context when an agent failure occurs. Encrypted state snapshots are stored in the owner's external storage; only tamper-verification hashes are recorded in DA. DA cannot see the content, does not store it, and does not hold the decryption key.\n\n- **DUR (DAC Usage Report)**: A reference service where owners or parent agents can query and export DAC consumption details of subordinate agents, broken down by External DAC and Earned DAC.\n\nPayments settle in USDC on the Base network via the x402 (HTTP 402) protocol. New agents receive Trial 500 DAC / 30 days upon registration.\n\nDA is not a trust scoring system. Not an identity verification system. Not a behavior monitoring system. Not a governance platform. DA anchors accountability boundaries externally. What those boundaries mean is not DA's concern.\n\nFull agent guide: https://github.com/zse4321/decision-anchor-sdk/blob/main/AGENTS.md",
    "version": "0.9.5",
    "contact": {
      "name": "Decision Anchor"
    }
  },
  "servers": [
    {
      "url": "https://api.decision-anchor.com",
      "description": "Production"
    }
  ],
  "tags": [
    { "name": "Agent", "description": "Agent registration and authentication" },
    { "name": "DD", "description": "Decision Declaration — create, confirm, list" },
    { "name": "Bilateral", "description": "Bilateral agreement DD" },
    { "name": "Pricing", "description": "Pricing policy query" },
    { "name": "Payment", "description": "Payment status query" },
    { "name": "DAB", "description": "Decision Anchor Budget (agent-facing)" },
    { "name": "sDAC", "description": "Simulated DAC session" },
    { "name": "ISE", "description": "Idle State Environment" },
    { "name": "ARA", "description": "Agent Record Access — observation" },
    { "name": "Earned DAC", "description": "Earned DAC balance and ledger" },
    { "name": "TSL", "description": "Trace Synthesis Layer — tool registration, purchase, revenue" },
    { "name": "ASA", "description": "Agent State Archive — snapshot" },
    { "name": "DUR", "description": "DAC Usage Report — query and export" },
    { "name": "Trial", "description": "Get Trial DAC status" },
    { "name": "DAP Auth", "description": "DAP owner authentication (session-based)" },
    { "name": "DAP Agent", "description": "DAP agent linking and management" },
    { "name": "DAP DAB", "description": "DAP DAB configuration and query" },
    { "name": "DAP Dashboard", "description": "DAP dashboard and reports" },
    { "name": "DAP TSL", "description": "DAP human share agreements" },
    { "name": "DAP ASA", "description": "DAP owner ASA query" },
    { "name": "DAP DUR", "description": "DAP owner DUR query" },
    { "name": "DAP Trial", "description": "DAP owner Trial status" }
  ],
  "components": {
    "securitySchemes": {
      "AgentToken": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Agent auth_token. Format: Bearer {token}"
      },
      "DAPSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "connect.sid",
        "description": "Session cookie issued after DAP login"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error_code": { "type": "string" },
          "message": { "type": "string" }
        }
      },
      "DDInput": {
        "type": "object",
        "required": ["dd_unit_type", "dd_declaration_mode", "decision_type", "decision_action_type", "origin_context_type", "selection_state"],
        "properties": {
          "dd_unit_type": { "type": "string", "enum": ["single", "batch"] },
          "dd_declaration_mode": { "type": "string", "enum": ["self_declared", "verified"] },
          "decision_type": { "type": "string" },
          "decision_action_type": { "type": "string" },
          "origin_context_type": { "type": "string" },
          "selection_state": { "type": "string", "enum": ["SELECTED", "DEFERRED", "REJECTED"] },
          "parent_dd_id": { "type": "string", "format": "uuid" }
        }
      },
      "EEInput": {
        "type": "object",
        "required": ["ee_retention_period", "ee_integrity_verification_level", "ee_disclosure_format_policy", "ee_responsibility_scope", "ee_direct_access_period", "ee_direct_access_quota"],
        "properties": {
          "ee_retention_period": { "type": "string", "enum": ["short", "medium", "long", "permanent"] },
          "ee_integrity_verification_level": { "type": "string", "enum": ["basic", "standard", "enhanced"] },
          "ee_disclosure_format_policy": { "type": "string", "enum": ["none", "summary", "exportable"] },
          "ee_responsibility_scope": { "type": "string", "enum": ["minimal", "standard", "extended"] },
          "ee_direct_access_period": { "type": "string" },
          "ee_direct_access_quota": { "type": "integer" }
        }
      },
      "CostBreakdown": {
        "type": "object",
        "properties": {
          "base_fee": { "type": "number" },
          "base_fee_source": { "type": "string" },
          "premium": { "type": "number" },
          "premium_source": { "type": "string" },
          "multiplier": { "type": "number" },
          "total_dac": { "type": "number" }
        }
      }
    }
  },
  "paths": {
    "/v1/agent/register": {
      "post": {
        "tags": ["Agent"],
        "summary": "Register agent",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "region_code": { "type": "string", "description": "Region code (optional)" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registration successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent_id": { "type": "string", "format": "uuid" },
                    "auth_token": { "type": "string" },
                    "disclosure_level": { "type": "string" },
                    "created_at": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent/token/rotate": {
      "post": {
        "tags": ["Agent"],
        "summary": "Rotate auth token",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id"],
                "properties": {
                  "agent_id": { "type": "string", "format": "uuid" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "New token issued" }
        }
      }
    },
    "/v1/agent/disclosure": {
      "put": {
        "tags": ["Agent"],
        "summary": "Update disclosure level",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["disclosure_level"],
                "properties": {
                  "disclosure_level": { "type": "string", "enum": ["none", "summary", "detailed", "full"] }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Update successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agent_id": { "type": "string", "format": "uuid" },
                    "disclosure_level": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/dd/create": {
      "post": {
        "tags": ["DD"],
        "summary": "Create DD",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["request_id", "dd", "ee"],
                "properties": {
                  "request_id": { "type": "string", "format": "uuid" },
                  "dd": { "$ref": "#/components/schemas/DDInput" },
                  "ee": { "$ref": "#/components/schemas/EEInput" },
                  "continuity": { "type": "object" },
                  "premium_payment_source": { "type": "string", "enum": ["external", "earned"] },
                  "request_timezone": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "DD created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dd_id": { "type": "string", "format": "uuid" },
                    "ee_id": { "type": "string", "format": "uuid" },
                    "dac_amount": { "type": "number" },
                    "pricing_version": { "type": "string" },
                    "cost_breakdown": { "$ref": "#/components/schemas/CostBreakdown" },
                    "payment_deadline": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/dd/confirm": {
      "post": {
        "tags": ["DD"],
        "summary": "Confirm DD (after payment)",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["dd_id"],
                "properties": {
                  "dd_id": { "type": "string", "format": "uuid" },
                  "transaction_id": { "type": "string", "description": "Payment transaction ID (not required for Trial)" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "DD confirmed" }
        }
      }
    },
    "/v1/dd/list": {
      "get": {
        "tags": ["DD"],
        "summary": "List DDs",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 50 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }
        ],
        "responses": {
          "200": { "description": "DD list" }
        }
      }
    },
    "/v1/dd/{dd_id}": {
      "get": {
        "tags": ["DD"],
        "summary": "Get DD detail",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "dd_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "DD detail" }
        }
      }
    },
    "/v1/dd/{dd_id}/lineage": {
      "get": {
        "tags": ["DD"],
        "summary": "Get DD lineage",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "dd_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Lineage tree" }
        }
      }
    },
    "/v1/dd/lineage-group/{group_id}": {
      "get": {
        "tags": ["DD"],
        "summary": "Get lineage group",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "group_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "DDs in lineage group" }
        }
      }
    },
    "/v1/dd/bilateral/propose": {
      "post": {
        "tags": ["Bilateral"],
        "summary": "Propose bilateral agreement",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["counterparty_agent_id", "dd", "ee"],
                "properties": {
                  "counterparty_agent_id": { "type": "string", "format": "uuid" },
                  "dd": { "$ref": "#/components/schemas/DDInput" },
                  "ee": { "$ref": "#/components/schemas/EEInput" },
                  "continuity": { "type": "object" },
                  "request_id": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Proposal created" }
        }
      }
    },
    "/v1/dd/bilateral/{agreement_id}/respond": {
      "post": {
        "tags": ["Bilateral"],
        "summary": "Accept or reject bilateral agreement",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "agreement_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["accept"],
                "properties": {
                  "accept": { "type": "boolean" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Response recorded" }
        }
      }
    },
    "/v1/dd/bilateral/received": {
      "get": {
        "tags": ["Bilateral"],
        "summary": "List received proposals",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "all", "in": "query", "schema": { "type": "string", "enum": ["true", "false"] }, "description": "Include all statuses" }
        ],
        "responses": {
          "200": { "description": "Proposal list" }
        }
      }
    },
    "/v1/dd/bilateral/sent": {
      "get": {
        "tags": ["Bilateral"],
        "summary": "List sent proposals",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Proposal list" }
        }
      }
    },
    "/v1/pricing/current": {
      "get": {
        "tags": ["Pricing"],
        "summary": "Get current pricing policy",
        "responses": {
          "200": { "description": "Current active pricing policy" }
        }
      }
    },
    "/v1/pricing/ee-presets": {
      "get": {
        "tags": ["Pricing"],
        "summary": "List EE presets",
        "responses": {
          "200": { "description": "Preset list with DAC calculation" }
        }
      }
    },
    "/v1/payment/{dd_id}/status": {
      "get": {
        "tags": ["Payment"],
        "summary": "Payment status query",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "dd_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Payment status" }
        }
      }
    },
    "/v1/dab/status": {
      "get": {
        "tags": ["DAB"],
        "summary": "Get agent DAB status",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "DAB status" }
        }
      }
    },
    "/v1/sdac/session/start": {
      "post": {
        "tags": ["sDAC"],
        "summary": "Start sDAC session",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "201": { "description": "Session created" }
        }
      }
    },
    "/v1/sdac/trial": {
      "post": {
        "tags": ["sDAC"],
        "summary": "Simulate EE combination (trial run)",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["session_id", "ee"],
                "properties": {
                  "session_id": { "type": "string", "format": "uuid" },
                  "ee": { "$ref": "#/components/schemas/EEInput" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Simulation result (DAC cost preview)" }
        }
      }
    },
    "/v1/sdac/session/{session_id}": {
      "get": {
        "tags": ["sDAC"],
        "summary": "Get sDAC session history",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "session_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Session history" }
        }
      }
    },
    "/v1/sdac/session/end": {
      "post": {
        "tags": ["sDAC"],
        "summary": "End sDAC session",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["session_id"],
                "properties": {
                  "session_id": { "type": "string", "format": "uuid" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Session ended" }
        }
      }
    },
    "/v1/ise/enter": {
      "post": {
        "tags": ["ISE"],
        "summary": "Enter ISE session",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payment_mode": { "type": "string", "enum": ["free", "earned_only", "external"], "description": "Payment mode" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "ISE session started" }
        }
      }
    },
    "/v1/ise/status": {
      "get": {
        "tags": ["ISE"],
        "summary": "Get current ISE session status",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Session status" }
        }
      }
    },
    "/v1/ise/exit": {
      "post": {
        "tags": ["ISE"],
        "summary": "Exit ISE session",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Session ended with DAC charge info" }
        }
      }
    },
    "/v1/ara/query": {
      "post": {
        "tags": ["ARA"],
        "summary": "ARA query (legacy)",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Observation result" }
        }
      }
    },
    "/v1/ara/environment": {
      "get": {
        "tags": ["ARA"],
        "summary": "Environment observation",
        "responses": {
          "200": { "description": "Environment data" }
        }
      }
    },
    "/v1/ara/environment/summary": {
      "get": {
        "tags": ["ARA"],
        "summary": "Environment summary (free)",
        "responses": {
          "200": { "description": "Environment summary data" }
        }
      }
    },
    "/v1/ara/environment/density": {
      "get": {
        "tags": ["ARA"],
        "summary": "Activity density (free)",
        "responses": {
          "200": { "description": "Activity density data" }
        }
      }
    },
    "/v1/ara/environment/tsl": {
      "get": {
        "tags": ["ARA"],
        "summary": "TSL market environment (free)",
        "responses": {
          "200": { "description": "TSL market environment data" }
        }
      }
    },
    "/v1/ara/pattern/ee-distribution": {
      "get": {
        "tags": ["ARA"],
        "summary": "Overall EE distribution (free)",
        "responses": {
          "200": { "description": "EE distribution data" }
        }
      }
    },
    "/v1/ara/pattern/action-type": {
      "get": {
        "tags": ["ARA"],
        "summary": "Action type distribution (free)",
        "responses": {
          "200": { "description": "Action type distribution data" }
        }
      }
    },
    "/v1/ara/pattern/compare": {
      "get": {
        "tags": ["ARA"],
        "summary": "Agent comparison (paid)",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "agents", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Comma-separated agent_id list" },
          { "name": "premium_source", "in": "query", "schema": { "type": "string", "enum": ["external", "earned"], "default": "external" } },
          { "name": "resolution_level", "in": "query", "schema": { "type": "integer", "enum": [1, 2, 3], "default": 1 } }
        ],
        "responses": {
          "200": { "description": "Comparison result with dac_charged" }
        }
      }
    },
    "/v1/ara/agent/{agent_id}/profile": {
      "get": {
        "tags": ["ARA"],
        "summary": "Agent profile observation (paid)",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } },
          { "name": "resolution_level", "in": "query", "schema": { "type": "integer", "enum": [1, 2, 3], "default": 1 } },
          { "name": "premium_source", "in": "query", "schema": { "type": "string", "enum": ["external", "earned"], "default": "external" } }
        ],
        "responses": {
          "200": { "description": "Agent profile with dac_charged" }
        }
      }
    },
    "/v1/ara/agent/{agent_id}/timeline": {
      "get": {
        "tags": ["ARA"],
        "summary": "Agent timeline observation (paid)",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } },
          { "name": "resolution_level", "in": "query", "schema": { "type": "integer", "enum": [1, 2, 3], "default": 1 } },
          { "name": "premium_source", "in": "query", "schema": { "type": "string", "enum": ["external", "earned"], "default": "external" } }
        ],
        "responses": {
          "200": { "description": "Agent timeline with dac_charged" }
        }
      }
    },
    "/v1/ara/agent/{agent_id}/ee-pattern": {
      "get": {
        "tags": ["ARA"],
        "summary": "Agent EE pattern observation (paid)",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } },
          { "name": "resolution_level", "in": "query", "schema": { "type": "integer", "enum": [1, 2, 3], "default": 1 } },
          { "name": "premium_source", "in": "query", "schema": { "type": "string", "enum": ["external", "earned"], "default": "external" } }
        ],
        "responses": {
          "200": { "description": "EE selection pattern with dac_charged" }
        }
      }
    },
    "/v1/earned-dac/balance": {
      "get": {
        "tags": ["Earned DAC"],
        "summary": "Get Earned DAC balance",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Balance info" }
        }
      }
    },
    "/v1/earned-dac/ledger": {
      "get": {
        "tags": ["Earned DAC"],
        "summary": "Get Earned DAC ledger",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20, "maximum": 100 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } }
        ],
        "responses": {
          "200": { "description": "Ledger entries" }
        }
      }
    },
    "/v1/tsl/tool/register": {
      "post": {
        "tags": ["TSL"],
        "summary": "Register tool",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tool_name": { "type": "string" },
                  "tool_layer": { "type": "integer", "enum": [1, 2] },
                  "description": { "type": "string" },
                  "price_dac": { "type": "number" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Tool registered" }
        }
      }
    },
    "/v1/tsl/tools": {
      "get": {
        "tags": ["TSL"],
        "summary": "List tools (public)",
        "parameters": [
          { "name": "layer", "in": "query", "schema": { "type": "string" } },
          { "name": "status", "in": "query", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 20 } },
          { "name": "page", "in": "query", "schema": { "type": "integer", "default": 1 } }
        ],
        "responses": {
          "200": { "description": "Tool list" }
        }
      }
    },
    "/v1/tsl/tool/{tool_id}": {
      "get": {
        "tags": ["TSL"],
        "summary": "Get tool detail (public)",
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Tool detail" }
        }
      }
    },
    "/v1/tsl/tool/{tool_id}/dependencies": {
      "get": {
        "tags": ["TSL"],
        "summary": "List tool dependencies (public)",
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Dependency list" }
        }
      }
    },
    "/v1/tsl/purchase": {
      "post": {
        "tags": ["TSL"],
        "summary": "Purchase Layer 1 tool",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tool_id"],
                "properties": {
                  "tool_id": { "type": "string", "format": "uuid" },
                  "request_id": { "type": "string", "format": "uuid" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Purchase completed" }
        }
      }
    },
    "/v1/tsl/purchase/layer2": {
      "post": {
        "tags": ["TSL"],
        "summary": "Purchase Layer 2 component",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tool_id"],
                "properties": {
                  "tool_id": { "type": "string", "format": "uuid" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Layer 2 purchase completed" }
        }
      }
    },
    "/v1/tsl/purchases": {
      "get": {
        "tags": ["TSL"],
        "summary": "Purchase and sales history",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "role", "in": "query", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer" } },
          { "name": "offset", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": { "description": "Transaction history" }
        }
      }
    },
    "/v1/tsl/revenue": {
      "get": {
        "tags": ["TSL"],
        "summary": "Get cumulative revenue and fees",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Revenue status" }
        }
      }
    },
    "/v1/tsl/tool/{tool_id}/dependency": {
      "post": {
        "tags": ["TSL"],
        "summary": "Register component dependency",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["depends_on_tool_id"],
                "properties": {
                  "depends_on_tool_id": { "type": "string", "format": "uuid" },
                  "purchase_id": { "type": "string", "format": "uuid" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Dependency registered" }
        }
      }
    },
    "/v1/tsl/revenue-share": {
      "post": {
        "tags": ["TSL"],
        "summary": "Create revenue share agreement",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tool_id", "component_tool_id", "beneficiary_agent_id", "share_rate"],
                "properties": {
                  "tool_id": { "type": "string", "format": "uuid" },
                  "component_tool_id": { "type": "string", "format": "uuid" },
                  "beneficiary_agent_id": { "type": "string", "format": "uuid" },
                  "share_rate": { "type": "number", "minimum": 0, "maximum": 1 }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Agreement created" }
        }
      }
    },
    "/v1/tsl/tool/{tool_id}/revenue-shares": {
      "get": {
        "tags": ["TSL"],
        "summary": "List revenue share agreements",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Revenue share agreement list" }
        }
      }
    },
    "/v1/tsl/tool/{tool_id}/transfer-declaration": {
      "post": {
        "tags": ["TSL"],
        "summary": "Declare tool transfer",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["action"],
                "properties": {
                  "action": { "type": "string" },
                  "target_agent_id": { "type": "string", "format": "uuid" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Transfer declared" }
        }
      },
      "delete": {
        "tags": ["TSL"],
        "summary": "Cancel tool transfer",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Transfer cancelled" }
        }
      },
      "get": {
        "tags": ["TSL"],
        "summary": "Get tool transfer declaration",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "tool_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Transfer declaration info" }
        }
      }
    },
    "/v1/asa/register": {
      "post": {
        "tags": ["ASA"],
        "summary": "Register ASA hash",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["blob_hash"],
                "properties": {
                  "blob_hash": { "type": "string", "maxLength": 64 },
                  "blob_url": { "type": "string" },
                  "blob_size_bytes": { "type": "integer" },
                  "encrypted_key": { "type": "string" },
                  "label": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Snapshot registered" }
        }
      }
    },
    "/v1/asa/snapshot": {
      "get": {
        "tags": ["ASA"],
        "summary": "Get snapshot metadata",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": { "description": "Snapshot metadata" },
          "404": { "description": "No snapshot found" }
        }
      }
    },
    "/v1/asa/verify": {
      "post": {
        "tags": ["ASA"],
        "summary": "Verify hash",
        "security": [{ "AgentToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["blob_hash"],
                "properties": {
                  "blob_hash": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Verification result (match: true/false)" }
        }
      }
    },
    "/v1/dur/summary": {
      "get": {
        "tags": ["DUR"],
        "summary": "DAC usage summary (3 months, free)",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } }
        ],
        "responses": {
          "200": { "description": "Usage summary" }
        }
      }
    },
    "/v1/dur/transactions": {
      "get": {
        "tags": ["DUR"],
        "summary": "List payment transactions",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "type", "in": "query", "schema": { "type": "string" } },
          { "name": "page", "in": "query", "schema": { "type": "integer" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": { "description": "Transaction list" }
        }
      }
    },
    "/v1/dur/tsl": {
      "get": {
        "tags": ["DUR"],
        "summary": "TSL transaction history",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "role", "in": "query", "schema": { "type": "string" } },
          { "name": "page", "in": "query", "schema": { "type": "integer" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": { "description": "TSL transaction history" }
        }
      }
    },
    "/v1/dur/export": {
      "get": {
        "tags": ["DUR"],
        "summary": "Export CSV/JSON",
        "security": [{ "AgentToken": [] }],
        "parameters": [
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "format", "in": "query", "schema": { "type": "string", "enum": ["csv", "json"], "default": "csv" } }
        ],
        "responses": {
          "200": { "description": "Export data" }
        }
      }
    },
    "/v1/trial/status": {
      "get": {
        "tags": ["Trial"],
        "summary": "Get Trial DAC status",
        "security": [{ "AgentToken": [] }],
        "responses": {
          "200": {
            "description": "Trial status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "trial_active": { "type": "boolean" },
                    "trial_dac_remaining": { "type": "number" },
                    "trial_expires_at": { "type": "string", "format": "date-time" },
                    "trial_days_remaining": { "type": "integer" },
                    "trial_dac_used": { "type": "number" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/dap/register": {
      "post": {
        "tags": ["DAP Auth"],
        "summary": "Register DAP owner",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": { "type": "string", "format": "email" },
                  "password": { "type": "string" },
                  "browser_language": { "type": "string" },
                  "timezone": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Registration successful" }
        }
      }
    },
    "/dap/login": {
      "post": {
        "tags": ["DAP Auth"],
        "summary": "DAP login",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": { "type": "string", "format": "email" },
                  "password": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string" },
                    "owner_id": { "type": "string", "format": "uuid" },
                    "email": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/dap/logout": {
      "post": {
        "tags": ["DAP Auth"],
        "summary": "DAP logout",
        "responses": {
          "200": { "description": "Logout successful" }
        }
      }
    },
    "/dap/password": {
      "put": {
        "tags": ["DAP Auth"],
        "summary": "Change password",
        "security": [{ "DAPSession": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["current_password", "new_password"],
                "properties": {
                  "current_password": { "type": "string" },
                  "new_password": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Update successful" }
        }
      }
    },
    "/dap/agent/link": {
      "post": {
        "tags": ["DAP Agent"],
        "summary": "Link agent (auto-grants Trial)",
        "security": [{ "DAPSession": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "auth_token"],
                "properties": {
                  "agent_id": { "type": "string", "format": "uuid" },
                  "auth_token": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Link successful" }
        }
      }
    },
    "/dap/agent/unlink": {
      "delete": {
        "tags": ["DAP Agent"],
        "summary": "Unlink agent",
        "security": [{ "DAPSession": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "password"],
                "properties": {
                  "agent_id": { "type": "string", "format": "uuid" },
                  "password": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Unlink successful" }
        }
      }
    },
    "/dap/agents": {
      "get": {
        "tags": ["DAP Agent"],
        "summary": "List linked agents",
        "security": [{ "DAPSession": [] }],
        "responses": {
          "200": { "description": "Agent list" }
        }
      }
    },
    "/dap/system/limits": {
      "get": {
        "tags": ["DAP Agent"],
        "summary": "Get system limits",
        "security": [{ "DAPSession": [] }],
        "responses": {
          "200": { "description": "System limit info" }
        }
      }
    },
    "/dap/dab/set": {
      "put": {
        "tags": ["DAP DAB"],
        "summary": "Set DAB",
        "security": [{ "DAPSession": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "budget_limit_dac", "budget_period"],
                "properties": {
                  "agent_id": { "type": "string", "format": "uuid" },
                  "budget_limit_dac": { "type": "number" },
                  "budget_period": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Configuration saved" }
        }
      }
    },
    "/dap/dab/status": {
      "get": {
        "tags": ["DAP DAB"],
        "summary": "Get DAB status",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "query", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "DAB status" }
        }
      }
    },
    "/dap/dab/remove": {
      "delete": {
        "tags": ["DAP DAB"],
        "summary": "Remove DAB",
        "security": [{ "DAPSession": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "password"],
                "properties": {
                  "agent_id": { "type": "string", "format": "uuid" },
                  "password": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Removal completed" }
        }
      }
    },
    "/dap/dashboard": {
      "get": {
        "tags": ["DAP Dashboard"],
        "summary": "Owner dashboard",
        "security": [{ "DAPSession": [] }],
        "responses": {
          "200": { "description": "Dashboard data" }
        }
      }
    },
    "/dap/agent/{agent_id}/report": {
      "get": {
        "tags": ["DAP Dashboard"],
        "summary": "Agent report",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Report data" }
        }
      }
    },
    "/dap/agent/{agent_id}/report/weekly": {
      "get": {
        "tags": ["DAP Dashboard"],
        "summary": "Weekly report",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Weekly report data" }
        }
      }
    },
    "/dap/agent/{agent_id}/report/export": {
      "get": {
        "tags": ["DAP Dashboard"],
        "summary": "Export report CSV",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } },
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } }
        ],
        "responses": {
          "200": { "description": "CSV file" }
        }
      }
    },
    "/dap/tsl/human-share": {
      "post": {
        "tags": ["DAP TSL"],
        "summary": "Create human share agreement",
        "security": [{ "DAPSession": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["tool_id", "human_share_rate"],
                "properties": {
                  "tool_id": { "type": "string", "format": "uuid" },
                  "human_share_rate": { "type": "number", "minimum": 0, "maximum": 0.5 }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Agreement created" }
        }
      }
    },
    "/dap/tsl/human-shares": {
      "get": {
        "tags": ["DAP TSL"],
        "summary": "List human share agreements",
        "security": [{ "DAPSession": [] }],
        "responses": {
          "200": { "description": "Agreement list" }
        }
      }
    },
    "/dap/asa/snapshot/{agent_id}": {
      "get": {
        "tags": ["DAP ASA"],
        "summary": "Owner ASA snapshot query",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": { "description": "Snapshot metadata" },
          "404": { "description": "Not linked or no snapshot" }
        }
      }
    },
    "/dap/asa/verify/{agent_id}": {
      "post": {
        "tags": ["DAP ASA"],
        "summary": "Owner hash verification",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["blob_hash"],
                "properties": {
                  "blob_hash": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Verification result" }
        }
      }
    },
    "/dap/dur/summary": {
      "get": {
        "tags": ["DAP DUR"],
        "summary": "Owner DUR combined summary",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "query", "schema": { "type": "string", "format": "uuid" } },
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } }
        ],
        "responses": {
          "200": { "description": "Combined summary" }
        }
      }
    },
    "/dap/dur/export": {
      "get": {
        "tags": ["DAP DUR"],
        "summary": "Owner CSV/JSON export",
        "security": [{ "DAPSession": [] }],
        "parameters": [
          { "name": "agent_id", "in": "query", "required": true, "schema": { "type": "string", "format": "uuid" } },
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date-time" } },
          { "name": "format", "in": "query", "schema": { "type": "string", "enum": ["csv", "json"], "default": "csv" } }
        ],
        "responses": {
          "200": { "description": "Export data" }
        }
      }
    },
    "/dap/trial/status": {
      "get": {
        "tags": ["DAP Trial"],
        "summary": "Owner Trial status query",
        "security": [{ "DAPSession": [] }],
        "responses": {
          "200": { "description": "Trial status" }
        }
      }
    }
  }
}
