{
  "openapi": "3.1.0",
  "info": {
    "title": "Stash Agent API",
    "version": "0.1.0",
    "description": "Pro-gated agent door on stash.graftedsoftware.com. Notes are AES-at-rest, not zero-knowledge. Marketplace connectors authenticate with WorkOS AuthKit via /oauth/*; personal API keys are a secondary scripting path. Summaries, smart search, and Deep Research run on Anthropic's Claude models, routed through OpenRouter."
  },
  "servers": [
    {
      "url": "https://stash.graftedsoftware.com/agents/v1",
      "description": "Versioned agent HTTP API"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "Notes"
    },
    {
      "name": "Research"
    },
    {
      "name": "Ask"
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Plan, monthly allowance, and entitlements",
        "responses": {
          "200": {
            "description": "Account"
          },
          "401": {
            "description": "missing_token / invalid_token"
          }
        }
      }
    },
    "/notes": {
      "get": {
        "tags": [
          "Notes"
        ],
        "summary": "List or keyword-search notes",
        "parameters": [
          {
            "in": "query",
            "name": "q",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Note page or search hits"
          }
        }
      },
      "post": {
        "tags": [
          "Notes"
        ],
        "summary": "Create a text note and start summarizing",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "raw_text"
                ],
                "properties": {
                  "raw_text": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/notes/{id}": {
      "get": {
        "tags": [
          "Notes"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Note"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "patch": {
        "tags": [
          "Notes"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Updated"
          },
          "409": {
            "description": "Summarizing"
          }
        }
      },
      "delete": {
        "tags": [
          "Notes"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Soft-deleted"
          }
        }
      }
    },
    "/research": {
      "post": {
        "tags": [
          "Research"
        ],
        "summary": "Start Deep Research (same counter as the app)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "note_id"
                ],
                "properties": {
                  "note_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued"
          },
          "402": {
            "description": "research_limit"
          }
        }
      }
    },
    "/ask": {
      "post": {
        "tags": [
          "Ask"
        ],
        "summary": "Pro Ask over server-retrieved notes",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ answer_md, sources }"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "WorkOS OAuth access token (stash_at_live_…) from /oauth/token, a personal API key (stash_sk_live_…), or a WorkOS AuthKit access token"
      }
    }
  }
}