{
  "openapi": "3.1.0",
  "info": {
    "title": "ActUpon Public API",
    "version": "0.1.0",
    "description": "First public slice of the ActUpon API for bearer auth, item retrieval, inbox retrieval, and agent token management."
  },
  "servers": [
    {
      "url": "https://actupon.app"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT or personal agent token"
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/screenshotaction/items": {
      "get": {
        "summary": "List saved ActUpon items",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "event",
                "media",
                "reference"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tags",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated structured tags; all must match"
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved items returned"
          },
          "401": {
            "description": "Authentication required"
          }
        }
      }
    },
    "/api/screenshotaction/items/{id}": {
      "get": {
        "summary": "Fetch one ActUpon item",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Item returned"
          },
          "404": {
            "description": "Not found"
          }
        }
      },
      "patch": {
        "summary": "Update workflow status, claim state, or resolution note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workflow_status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "done"
                    ]
                  },
                  "resolution_note": {
                    "type": "string"
                  },
                  "claim_action": {
                    "type": "string",
                    "enum": [
                      "claim",
                      "release"
                    ]
                  },
                  "lease_seconds": {
                    "type": "integer"
                  },
                  "corrections": {
                    "type": "object",
                    "properties": {
                      "title": {
                        "type": "string"
                      },
                      "summary": {
                        "type": "string"
                      },
                      "action_note": {
                        "type": "string"
                      },
                      "tags": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Item updated"
          },
          "409": {
            "description": "Claim conflict or invalid workflow transition"
          }
        }
      }
    },
    "/api/screenshotaction/inbox": {
      "get": {
        "summary": "List workflow inbox items",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ]
            }
          },
          {
            "name": "workflow_status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "done"
              ]
            }
          },
          {
            "name": "requested_action",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "calendar",
                "reminder",
                "save",
                "workflow"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "event",
                "media",
                "reference"
              ]
            }
          },
          {
            "name": "destination_kind",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "destination_name",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tags",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated structured tags; all must match"
          },
          {
            "name": "claim_status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "available",
                "claimed",
                "mine"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inbox items returned"
          },
          "401": {
            "description": "Authentication required"
          }
        }
      }
    },
    "/api/screenshotaction/agent-tokens": {
      "get": {
        "summary": "List personal agent tokens for the signed-in user",
        "responses": {
          "200": {
            "description": "Token records returned"
          },
          "401": {
            "description": "Signed-in session required"
          }
        }
      },
      "post": {
        "summary": "Create a personal agent token for the signed-in user",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "scopes"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "read_items",
                        "update_workflow_status"
                      ]
                    }
                  },
                  "expires_in_days": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token created and raw secret returned once"
          },
          "401": {
            "description": "Signed-in session required"
          }
        }
      }
    }
  }
}