{
  "openapi": "3.0.3",
  "info": {
    "title": "VGNW personal ticket API — action contract",
    "version": "2.5.0",
    "description": "Action extension. Full read/files/drafts/browser-management contract: docs/TICKET-AGENT-API.md. Every action is user/server scoped, private/no-store. Same source_id and body safely returns an existing successful receipt, not a repeated mutation."
  },
  "servers": [
    {
      "url": "https://minecraftturkiye.com/wp-json/vgnw-tickets/v1/agent"
    }
  ],
  "security": [
    {
      "TicketKey": []
    }
  ],
  "paths": {
    "/tickets/{id}/replies": {
      "post": {
        "summary": "Send a reply; close_ticket:true additionally requires allow_close",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Durable action receipt; inspect action/status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid/expired key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope or account denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Ticket/action outside scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Stale snapshot, conflict or uncertain delivery",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate/daily limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Storage/Auth unavailable or partial completion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Reply"
              }
            }
          }
        }
      }
    },
    "/tickets/{id}/close": {
      "post": {
        "summary": "Close without a message; requires allow_close and current context_hash",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Durable action receipt; inspect action/status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid/expired key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope or account denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Ticket/action outside scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Stale snapshot, conflict or uncertain delivery",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate/daily limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Storage/Auth unavailable or partial completion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Close"
              }
            }
          }
        }
      }
    },
    "/actions/{id}": {
      "get": {
        "summary": "Read an action receipt belonging to this key",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Durable action receipt; inspect action/status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid/expired key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope or account denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Ticket/action outside scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Stale snapshot, conflict or uncertain delivery",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate/daily limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Storage/Auth unavailable or partial completion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/me": {
      "get": {
        "summary": "Read account, server and separate reply/close permissions",
        "responses": {
          "200": {
            "description": "Current caller capabilities",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "can_publish": {
                      "type": "boolean"
                    },
                    "can_close": {
                      "type": "boolean"
                    },
                    "key": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid/expired key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope or account denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Ticket/action outside scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Stale snapshot, conflict or uncertain delivery",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate/daily limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Storage/Auth unavailable or partial completion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tickets/{id}": {
      "get": {
        "summary": "Read current ticket and snapshot; read all message pages before writing",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Private ticket, opening, messages, pagination and context_hash"
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid/expired key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope or account denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Ticket/action outside scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Stale snapshot, conflict or uncertain delivery",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate/daily limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Storage/Auth unavailable or partial completion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "TicketKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-VGNW-Ticket-Key"
      }
    },
    "schemas": {
      "Close": {
        "type": "object",
        "required": [
          "source_id",
          "context_hash"
        ],
        "properties": {
          "source_id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{8,80}$"
          },
          "context_hash": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      },
      "Reply": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Close"
          },
          {
            "type": "object",
            "required": [
              "message"
            ],
            "properties": {
              "message": {
                "type": "string",
                "minLength": 3,
                "description": "At most 30000 UTF-8 bytes; sanitized using existing support rules."
              },
              "close_ticket": {
                "type": "boolean",
                "default": false
              }
            }
          }
        ]
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "ticket_id": {
            "type": "integer"
          },
          "action": {
            "type": "string",
            "enum": [
              "reply",
              "reply_close",
              "close"
            ]
          },
          "delivery_mode": {
            "type": "string",
            "enum": [
              "direct",
              "review"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "sent",
              "closed",
              "partial",
              "failed",
              "approved",
              "rejected"
            ]
          },
          "comment_id": {
            "type": "integer",
            "description": "0 for close-only; actual message ID for replies."
          },
          "author_id": {
            "type": "integer"
          },
          "reviewer_id": {
            "type": "integer"
          },
          "review_url": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer"
              },
              "delivery_id": {
                "type": "integer"
              },
              "delivery_status": {
                "type": "string"
              },
              "comment_id": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Birleşik API rehberi: bağlantı, izinler, örnekler ve AI iş akışı",
    "url": "https://minecraftturkiye.com/api-dokumani/"
  }
}
