{
  "openapi": "3.1.0",
  "info": {
    "title": "Posview Agent API v2",
    "summary": "AI-safe social media operations API for reading Posview context and creating human-reviewed post proposals.",
    "version": "2026-06-06"
  },
  "servers": [
    {
      "url": "/",
      "description": "Current origin. Use the origin that served this OpenAPI document, such as production or staging."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "x-posview-ai-safety": {
    "directPublishing": false,
    "requiresHumanConfirmation": true,
    "exposesOAuthTokens": false,
    "exposesBillingDetails": false,
    "initialOAuthScopes": [
      "agent:read",
      "agent:draft",
      "agent:schedule:prepare",
      "agent:confirm:create"
    ],
    "initialOAuthScopesExclude": [
      "agent:publish:request"
    ]
  },
  "paths": {
    "/api/agent/v2/capabilities": {
      "get": {
        "operationId": "get_agent_capabilities",
        "summary": "Get Agent API v2 capabilities for the current key",
        "x-posview-required-scopes": [],
        "x-posview-safety": "read_only",
        "responses": {
          "200": {
            "description": "Capabilities for the authenticated agent key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilitiesResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/agent/v2/workspace/context": {
      "get": {
        "operationId": "get_workspace_context",
        "summary": "Get workspace plan, feature, and SNS capability context",
        "x-posview-required-scopes": [
          "agent:read"
        ],
        "x-posview-safety": "read_only",
        "responses": {
          "200": {
            "description": "Workspace context visible to the authenticated agent key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceContextResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "x-posview-action-id": "workspace.getContext",
        "x-posview-action-label": "Get workspace context",
        "x-posview-action-description": "Read plan, AI availability, registered platforms, and publishing capability constraints for the authenticated workspace.",
        "x-posview-execution-mode": "read",
        "x-posview-required-scope-mode": "all",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "viewer",
        "x-posview-safety-flags": {
          "readOnly": true,
          "destructive": false,
          "openWorld": false,
          "idempotent": true,
          "requiresHumanConfirmation": false,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "workspace",
          "allowCurrentPostFallback": false,
          "ambiguity": "never_guess"
        },
        "x-posview-schema-refs": {
          "input": "none",
          "output": "AgentWorkspaceContext"
        },
        "x-posview-mcp-tool": "posview_get_workspace_context",
        "x-posview-action-category": "workspace",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-C-001"
        ],
        "x-posview-output-schema-ref": "#/components/schemas/WorkspaceContextResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/WorkspaceContextResponse",
        "x-posview-structured-content-root": "root"
      }
    },
    "/api/agent/v2/posts": {
      "get": {
        "operationId": "list_posts",
        "summary": "List posts visible to the authenticated agent key",
        "x-posview-required-scopes": [
          "agent:read"
        ],
        "x-posview-safety": "read_only",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Post summaries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostSearchResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "x-posview-action-id": "post.search",
        "x-posview-action-label": "Search posts",
        "x-posview-action-description": "Search post candidates inside the authenticated workspace by status, date, platform, and deletion mode.",
        "x-posview-execution-mode": "read",
        "x-posview-required-scope-mode": "all",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "viewer",
        "x-posview-safety-flags": {
          "readOnly": true,
          "destructive": false,
          "openWorld": false,
          "idempotent": true,
          "requiresHumanConfirmation": false,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "workspace",
          "deletedMode": "exclude",
          "allowCurrentPostFallback": false,
          "ambiguity": "return_candidates"
        },
        "x-posview-schema-refs": {
          "input": "AgentPostSearchInput",
          "output": "AgentPostSearchResult"
        },
        "x-posview-mcp-tool": "posview_search_posts",
        "x-posview-action-category": "post",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-D-008",
          "GP-A-001",
          "GP-C-001"
        ],
        "x-posview-input-schema-ref": "#/components/schemas/PostSearchRequest",
        "x-posview-output-schema-ref": "#/components/schemas/PostSearchResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/PostSearchResponse",
        "x-posview-structured-content-root": "posts"
      }
    },
    "/api/agent/v2/posts/draft": {
      "post": {
        "operationId": "create_post_draft",
        "summary": "Create a new draft post",
        "description": "Creates a draft post and optional platform captions, schedule candidates, or explicit same-workspace media-copy references. It does not approve, schedule, publish, expose storage keys, upload media, or create publishing jobs.",
        "x-posview-required-scopes": [
          "agent:draft"
        ],
        "x-posview-safety": "draft_only",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDraftRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created draft post",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateDraftResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "x-posview-action-id": "post.draft.create",
        "x-posview-action-label": "Create draft post",
        "x-posview-action-description": "Create a new draft post. It does not approve, schedule, or publish and always requires human review.",
        "x-posview-execution-mode": "draft_create",
        "x-posview-required-scope-mode": "all",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "edit",
        "x-posview-safety-flags": {
          "readOnly": false,
          "destructive": false,
          "openWorld": false,
          "idempotent": false,
          "requiresHumanConfirmation": true,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "workspace",
          "allowCurrentPostFallback": false,
          "ambiguity": "ask"
        },
        "x-posview-schema-refs": {
          "input": "CreateDraftPostInput",
          "output": "CreateDraftPostResult"
        },
        "x-posview-mcp-tool": "posview_create_draft_post",
        "x-posview-action-category": "post",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-D-003",
          "GP-D-010",
          "GP-C-002"
        ],
        "x-posview-input-schema-ref": "#/components/schemas/CreateDraftRequest",
        "x-posview-output-schema-ref": "#/components/schemas/CreateDraftResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/CreateDraftResponse",
        "x-posview-structured-content-root": "post"
      }
    },
    "/api/agent/v2/posts/{postId}": {
      "get": {
        "operationId": "get_post",
        "summary": "Get a post with platform captions, constraints, media, and preview image references",
        "x-posview-required-scopes": [
          "agent:read"
        ],
        "x-posview-safety": "read_only",
        "parameters": [
          {
            "name": "postId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Post detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostDetailResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-posview-action-id": "post.get",
        "x-posview-action-label": "Get post",
        "x-posview-action-description": "Read post details, platform captions, schedules, media references, and preview state without returning secrets.",
        "x-posview-execution-mode": "read",
        "x-posview-required-scope-mode": "all",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "viewer",
        "x-posview-safety-flags": {
          "readOnly": true,
          "destructive": false,
          "openWorld": false,
          "idempotent": true,
          "requiresHumanConfirmation": false,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "post",
          "deletedMode": "exclude",
          "allowCurrentPostFallback": true,
          "ambiguity": "ask"
        },
        "x-posview-schema-refs": {
          "input": "AgentPostIdInput",
          "output": "AgentPostDetail"
        },
        "x-posview-mcp-tool": "posview_get_post",
        "x-posview-action-category": "post",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-D-007",
          "GP-C-003",
          "GP-C-004"
        ],
        "x-posview-input-schema-ref": "#/components/schemas/PostIdRequest",
        "x-posview-output-schema-ref": "#/components/schemas/PostDetailResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/PostDetailResponse",
        "x-posview-structured-content-root": "post"
      }
    },
    "/api/agent/v2/posts/{postId}/preview": {
      "get": {
        "operationId": "get_post_preview",
        "summary": "Get safe preview URL availability for a post",
        "description": "Returns whether the authenticated agent may reference the post preview URL. Passcodes are never returned and agents should not share preview URLs unless the user explicitly asks.",
        "x-posview-required-scopes": [
          "agent:read"
        ],
        "x-posview-safety": "read_only",
        "parameters": [
          {
            "name": "postId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe preview availability",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostPreviewResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-posview-action-id": "post.preview.get",
        "x-posview-action-label": "Get post preview",
        "x-posview-action-description": "Read safe preview URL availability. Passcodes are never returned, and agents should share URLs only when asked.",
        "x-posview-execution-mode": "read",
        "x-posview-required-scope-mode": "all",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "viewer",
        "x-posview-safety-flags": {
          "readOnly": true,
          "destructive": false,
          "openWorld": false,
          "idempotent": true,
          "requiresHumanConfirmation": false,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "post",
          "deletedMode": "exclude",
          "allowCurrentPostFallback": true,
          "ambiguity": "ask"
        },
        "x-posview-schema-refs": {
          "input": "AgentPostIdInput",
          "output": "AgentPostPreview"
        },
        "x-posview-mcp-tool": "posview_get_post_preview",
        "x-posview-action-category": "preview",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-D-006",
          "GP-N-002",
          "GP-C-006"
        ],
        "x-posview-input-schema-ref": "#/components/schemas/PostIdRequest",
        "x-posview-output-schema-ref": "#/components/schemas/PostPreviewResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/PostPreviewResponse",
        "x-posview-structured-content-root": "preview"
      }
    },
    "/api/agent/v2/posts/{postId}/proposals": {
      "post": {
        "operationId": "create_post_proposal",
        "summary": "Create a pending post proposal for human review",
        "description": "This endpoint stores a proposal only. It does not directly change captions, approval state, schedules, or publishing jobs.",
        "x-posview-required-scope-mode": "any",
        "x-posview-required-scopes": [
          "agent:draft",
          "agent:schedule:prepare"
        ],
        "x-posview-safety": "proposal_only",
        "parameters": [
          {
            "name": "postId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateProposalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created pending proposal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateProposalResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-posview-action-id": "post.proposal.create",
        "x-posview-action-label": "Create post proposal",
        "x-posview-action-description": "Save a caption or schedule proposal for an existing post without directly changing captions or schedules.",
        "x-posview-execution-mode": "proposal",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "edit",
        "x-posview-safety-flags": {
          "readOnly": false,
          "destructive": false,
          "openWorld": false,
          "idempotent": false,
          "requiresHumanConfirmation": true,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "post",
          "deletedMode": "exclude",
          "allowCurrentPostFallback": true,
          "ambiguity": "ask"
        },
        "x-posview-schema-refs": {
          "input": "CreatePostProposalInput",
          "output": "AiProposal"
        },
        "x-posview-mcp-tool": "posview_create_post_proposal",
        "x-posview-action-category": "proposal",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-D-004",
          "GP-D-005",
          "GP-C-003"
        ],
        "x-posview-input-schema-ref": "#/components/schemas/CreateProposalRequest",
        "x-posview-output-schema-ref": "#/components/schemas/CreateProposalResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/CreateProposalResponse",
        "x-posview-structured-content-root": "proposal"
      }
    },
    "/api/agent/v2/posts/{postId}/confirmation-requests": {
      "post": {
        "operationId": "create_confirmation_request",
        "summary": "Create a pending human confirmation request",
        "description": "This endpoint stores a request for a human editor to review. It does not approve, apply, schedule, or publish the post. publish_request requires agent:publish:request and is not included in the initial ChatGPT/OpenAI OAuth preset.",
        "x-posview-required-scopes": [
          "agent:confirm:create"
        ],
        "x-posview-intent-scopes": {
          "post_draft_update": [
            "agent:draft"
          ],
          "schedule_update": [
            "agent:schedule:prepare"
          ],
          "publish_request": [
            "agent:publish:request"
          ]
        },
        "x-posview-safety": "pending_confirmation_only",
        "parameters": [
          {
            "name": "postId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateConfirmationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created pending confirmation request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateConfirmationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "x-posview-action-id": "confirmationRequest.create",
        "x-posview-action-label": "Create confirmation request",
        "x-posview-action-description": "Create a pending human confirmation request in Posview. This never approves or publishes by itself.",
        "x-posview-execution-mode": "confirmation_request",
        "x-posview-required-scope-mode": "all",
        "x-posview-required-plan": "any_paid",
        "x-posview-required-role": "edit",
        "x-posview-safety-flags": {
          "readOnly": false,
          "destructive": false,
          "openWorld": false,
          "idempotent": false,
          "requiresHumanConfirmation": true,
          "exposesSecrets": false
        },
        "x-posview-target": {
          "resource": "post",
          "deletedMode": "exclude",
          "allowCurrentPostFallback": true,
          "ambiguity": "ask"
        },
        "x-posview-schema-refs": {
          "input": "CreateConfirmationRequestInput",
          "output": "ConfirmationRequest"
        },
        "x-posview-mcp-tool": "posview_create_confirmation_request",
        "x-posview-action-category": "confirmation",
        "x-posview-action-status": "implemented",
        "x-posview-golden-prompt-ids": [
          "GP-D-009",
          "GP-C-004",
          "GP-C-005"
        ],
        "x-posview-input-schema-ref": "#/components/schemas/CreateConfirmationRequest",
        "x-posview-output-schema-ref": "#/components/schemas/CreateConfirmationResponse",
        "x-posview-apps-sdk-output-schema-ref": "#/components/schemas/CreateConfirmationResponse",
        "x-posview-structured-content-root": "confirmationRequest"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Posview AI OAuth access token. Existing approved advanced Agent API key clients may use a pre-issued bearer credential."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request"
      },
      "Unauthorized": {
        "description": "Missing or invalid bearer token"
      },
      "Forbidden": {
        "description": "The agent key does not have the required scope or platform permission"
      },
      "NotFound": {
        "description": "Resource not found"
      }
    },
    "schemas": {
      "CapabilitiesResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "workspaceId",
          "agent",
          "capabilities",
          "endpoints",
          "safety",
          "dataHandling",
          "runtimeAvailability",
          "errorHandling"
        ],
        "properties": {
          "version": {
            "type": "string"
          },
          "workspaceId": {
            "type": "integer"
          },
          "agent": {
            "$ref": "#/components/schemas/Agent"
          },
          "capabilities": {
            "$ref": "#/components/schemas/AgentCapabilities"
          },
          "endpoints": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "safety": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "directPublishing",
              "requiresHumanConfirmation",
              "exposesOAuthTokens",
              "exposesBillingDetails"
            ],
            "properties": {
              "directPublishing": {
                "type": "boolean"
              },
              "requiresHumanConfirmation": {
                "type": "boolean"
              },
              "exposesOAuthTokens": {
                "type": "boolean"
              },
              "exposesBillingDetails": {
                "type": "boolean"
              }
            }
          },
          "dataHandling": {
            "$ref": "#/components/schemas/AiAgentDataHandlingPolicy"
          },
          "runtimeAvailability": {
            "$ref": "#/components/schemas/AiAgentRuntimeAvailabilityPolicy"
          },
          "errorHandling": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiAgentErrorHandlingEntry"
            }
          }
        }
      },
      "AiAgentDataHandlingPolicy": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "workspaceScoped",
          "leastPrivilegeScopes",
          "storesPlaintextTokens",
          "storesRefreshTokenHashes",
          "sendsToAiClient",
          "neverSendsToAiClient",
          "responseFieldDenylist",
          "minimizationRules",
          "logRetention",
          "retentionDeletion",
          "retentionSummary"
        ],
        "properties": {
          "version": {
            "type": "string"
          },
          "workspaceScoped": {
            "type": "boolean"
          },
          "leastPrivilegeScopes": {
            "type": "boolean"
          },
          "storesPlaintextTokens": {
            "type": "boolean"
          },
          "storesRefreshTokenHashes": {
            "type": "boolean"
          },
          "sendsToAiClient": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "neverSendsToAiClient": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "responseFieldDenylist": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "minimizationRules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "logRetention": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "promptResponseTranscriptsVisibleToServiceAdmins",
              "retainedRecords",
              "summary"
            ],
            "properties": {
              "promptResponseTranscriptsVisibleToServiceAdmins": {
                "type": "boolean",
                "const": false
              },
              "retainedRecords": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "summary": {
                "type": "string"
              }
            }
          },
          "retentionDeletion": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "summary",
              "items"
            ],
            "properties": {
              "summary": {
                "type": "string"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "dataCategory",
                    "retainedRecords",
                    "retentionPurpose",
                    "deletionTrigger",
                    "deletionBehavior",
                    "publicPolicySurface",
                    "reviewerChecks"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "dataCategory": {
                      "type": "string"
                    },
                    "retainedRecords": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "retentionPurpose": {
                      "type": "string"
                    },
                    "deletionTrigger": {
                      "type": "string"
                    },
                    "deletionBehavior": {
                      "type": "string"
                    },
                    "publicPolicySurface": {
                      "type": "string"
                    },
                    "reviewerChecks": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "retentionSummary": {
            "type": "string"
          }
        }
      },
      "AiAgentRuntimeAvailabilityPolicy": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "summary",
          "allowedPlans",
          "checkedOn",
          "blocks"
        ],
        "properties": {
          "version": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "allowedPlans": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "checkedOn": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiAgentRuntimeAvailabilityBlock"
            }
          }
        }
      },
      "AiAgentRuntimeAvailabilityBlock": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "condition",
          "recovery"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "condition": {
            "type": "string"
          },
          "recovery": {
            "type": "string"
          }
        }
      },
      "AiAgentErrorHandlingEntry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "title",
          "hint",
          "recovery",
          "docsPath"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          },
          "recovery": {
            "type": "string"
          },
          "docsPath": {
            "type": "string"
          },
          "requiredScopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "WorkspaceContextResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "workspaceId",
          "billing",
          "features",
          "platforms"
        ],
        "properties": {
          "workspaceId": {
            "type": "integer"
          },
          "billing": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "plan",
              "effectivePlan",
              "status",
              "aiAvailable"
            ],
            "properties": {
              "plan": {
                "$ref": "#/components/schemas/Plan"
              },
              "effectivePlan": {
                "$ref": "#/components/schemas/Plan"
              },
              "status": {
                "type": "string"
              },
              "aiAvailable": {
                "type": "boolean"
              }
            }
          },
          "features": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "publishAddon",
              "maxPublishAddonConnections"
            ],
            "properties": {
              "publishAddon": {
                "type": "boolean"
              },
              "maxPublishAddonConnections": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "platforms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlatformContext"
            }
          }
        }
      },
      "Agent": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label",
          "provider",
          "scopes",
          "allowedPlatforms"
        ],
        "properties": {
          "label": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowedPlatforms": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "AgentCapabilities": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "readPosts",
          "claimPublishingJobs",
          "reportPublishingResults",
          "createDrafts",
          "createPostProposals",
          "createScheduleProposals",
          "createConfirmationRequests",
          "requestPublishing"
        ],
        "properties": {
          "readPosts": {
            "type": "boolean"
          },
          "claimPublishingJobs": {
            "type": "boolean"
          },
          "reportPublishingResults": {
            "type": "boolean"
          },
          "createDrafts": {
            "type": "boolean"
          },
          "createPostProposals": {
            "type": "boolean"
          },
          "createScheduleProposals": {
            "type": "boolean"
          },
          "createConfirmationRequests": {
            "type": "boolean"
          },
          "requestPublishing": {
            "type": "boolean"
          }
        }
      },
      "PlatformContext": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "platformKey",
          "label",
          "group",
          "maxCaptionLength",
          "autoPublishingStatus",
          "manualManagement",
          "comingSoon",
          "noteJa"
        ],
        "properties": {
          "platformKey": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "group": {
            "type": [
              "string",
              "null"
            ]
          },
          "maxCaptionLength": {
            "type": [
              "integer",
              "null"
            ]
          },
          "autoPublishingStatus": {
            "type": "string",
            "enum": [
              "supported",
              "provider_dependent",
              "manual_only",
              "unsupported"
            ]
          },
          "manualManagement": {
            "type": "boolean"
          },
          "comingSoon": {
            "type": "boolean"
          },
          "noteJa": {
            "type": "string"
          }
        }
      },
      "PostSearchRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 50,
            "description": "Maximum posts to return."
          }
        }
      },
      "PostIdRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "postId"
        ],
        "properties": {
          "postId": {
            "type": "integer",
            "minimum": 1,
            "description": "Target Posview post id."
          }
        }
      },
      "PostSearchResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "posts"
        ],
        "properties": {
          "posts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostSummary"
            }
          }
        }
      },
      "PostSummary": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "title",
          "status",
          "approvalStatus",
          "postDate",
          "previewEnabled",
          "platforms"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "approvalStatus": {
            "type": "string"
          },
          "postDate": {
            "type": "string",
            "format": "date-time"
          },
          "previewEnabled": {
            "type": "boolean"
          },
          "platforms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostPlatformSummary"
            }
          }
        }
      },
      "PostDetail": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "title",
          "status",
          "approvalStatus",
          "postDate",
          "previewEnabled",
          "platforms"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "approvalStatus": {
            "type": "string"
          },
          "postDate": {
            "type": "string",
            "format": "date-time"
          },
          "previewEnabled": {
            "type": "boolean"
          },
          "platforms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostPlatformDetail"
            }
          },
          "mediaCopy": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "requested",
              "sourcePostId",
              "copiedCount",
              "warnings"
            ],
            "properties": {
              "requested": {
                "type": "boolean",
                "const": true
              },
              "sourcePostId": {
                "type": "integer"
              },
              "copiedCount": {
                "type": "integer"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "description": "Present only when same-workspace media copy was explicitly requested. Summarizes the copy result without storage keys or media URLs."
          }
        }
      },
      "PostDetailResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "post"
        ],
        "properties": {
          "post": {
            "$ref": "#/components/schemas/PostDetail"
          }
        }
      },
      "PostPlatformSummary": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "platformKey",
          "label",
          "group",
          "scheduledAt",
          "constraints"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "platformKey": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "group": {
            "type": [
              "string",
              "null"
            ]
          },
          "scheduledAt": {
            "type": "string",
            "format": "date-time"
          },
          "constraints": {
            "$ref": "#/components/schemas/PlatformConstraints"
          }
        }
      },
      "PostPlatformDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PostPlatformSummary"
          },
          {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "caption",
              "media",
              "previewImages"
            ],
            "properties": {
              "caption": {
                "type": "string"
              },
              "media": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "previewImages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        ]
      },
      "PlatformConstraints": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "maxCaptionLength": {
            "type": [
              "integer",
              "null"
            ]
          },
          "aspectRatio": {
            "type": [
              "string",
              "null"
            ]
          },
          "recommendedSize": {
            "type": [
              "string",
              "null"
            ]
          },
          "previewType": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PostPreviewResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "post",
          "preview"
        ],
        "properties": {
          "post": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "title",
              "status",
              "approvalStatus",
              "previewEnabled"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "title": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "approvalStatus": {
                "type": "string"
              },
              "previewEnabled": {
                "type": "boolean"
              }
            }
          },
          "preview": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "postId",
              "available",
              "accessStatus",
              "previewEnabled",
              "requiresPasscode",
              "passcodeIncluded",
              "path",
              "url",
              "note"
            ],
            "properties": {
              "postId": {
                "type": "integer"
              },
              "available": {
                "type": "boolean"
              },
              "accessStatus": {
                "type": "string",
                "enum": [
                  "available",
                  "requires_passcode",
                  "disabled",
                  "missing_slug",
                  "plan_locked",
                  "not_available"
                ]
              },
              "previewEnabled": {
                "type": "boolean"
              },
              "requiresPasscode": {
                "type": "boolean"
              },
              "passcodeIncluded": {
                "type": "boolean",
                "const": false
              },
              "path": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "note": {
                "type": "string"
              }
            }
          }
        }
      },
      "CreateDraftRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "postDate",
          "platforms"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Short draft post title. Use an empty string when no title is ready."
          },
          "postDate": {
            "type": "string",
            "description": "ISO datetime or YYYY-MM-DD date for the draft post."
          },
          "sourcePostId": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Existing same-workspace Posview post id to copy media from when copyMediaFromSource is true."
          },
          "copyMediaFromSource": {
            "type": "boolean",
            "default": false,
            "description": "Set true only when the user explicitly asks to duplicate or copy media from sourcePostId. The server copies safe media references from matching source platforms and does not accept raw media URLs or file keys."
          },
          "platforms": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/CreateDraftPlatform"
            }
          }
        }
      },
      "CreateDraftPlatform": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "platformKey"
        ],
        "properties": {
          "platformKey": {
            "type": "string"
          },
          "caption": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 12000
          },
          "scheduledAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional ISO datetime or YYYY-MM-DD date/time candidate for this platform."
          }
        }
      },
      "CreateDraftResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "post",
          "safety"
        ],
        "properties": {
          "post": {
            "$ref": "#/components/schemas/PostDetail"
          },
          "safety": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "directPublishing",
              "approvalStatus",
              "publishingJobsCreated",
              "requiresHumanReview"
            ],
            "properties": {
              "directPublishing": {
                "type": "boolean",
                "const": false
              },
              "approvalStatus": {
                "type": "string",
                "enum": [
                  "draft"
                ]
              },
              "publishingJobsCreated": {
                "type": "integer",
                "const": 0
              },
              "requiresHumanReview": {
                "type": "boolean",
                "const": true
              }
            }
          }
        }
      },
      "CreateDraftsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "drafts"
        ],
        "properties": {
          "drafts": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "description": "One to ten new draft-only Posview posts to create in a single user-approved batch. Use this instead of calling posview_create_draft_post repeatedly when the user asks for multiple drafts.",
            "items": {
              "$ref": "#/components/schemas/CreateDraftRequest"
            }
          }
        }
      },
      "CreateDraftsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "drafts",
          "skippedDrafts",
          "safety"
        ],
        "properties": {
          "drafts": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/PostDetail"
                },
                {
                  "type": "object",
                  "properties": {
                    "batchIndex": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              ]
            }
          },
          "skippedDrafts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "batchIndex",
                "title",
                "code",
                "message"
              ],
              "properties": {
                "batchIndex": {
                  "type": "integer",
                  "minimum": 0
                },
                "title": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "safety": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "recordsCreated",
              "directPublishing",
              "approvalStatus",
              "publishingJobsCreated",
              "requiresHumanReview"
            ],
            "properties": {
              "recordsCreated": {
                "type": "integer",
                "minimum": 0
              },
              "directPublishing": {
                "type": "boolean",
                "const": false
              },
              "approvalStatus": {
                "type": "string",
                "enum": [
                  "draft"
                ]
              },
              "publishingJobsCreated": {
                "type": "integer",
                "const": 0
              },
              "requiresHumanReview": {
                "type": "boolean",
                "const": true
              }
            }
          }
        }
      },
      "UpdateDraftPostsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "updates"
        ],
        "properties": {
          "updates": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "description": "One to ten explicitly selected unapproved draft posts to update directly. Each post must still have status=draft and approvalStatus=draft.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "postId"
              ],
              "properties": {
                "postId": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "Target Posview draft post id selected by the user."
                },
                "title": {
                  "type": "string",
                  "maxLength": 255,
                  "description": "Optional replacement draft title."
                },
                "postDate": {
                  "type": "string",
                  "description": "Optional ISO datetime or YYYY-MM-DD draft date."
                },
                "platforms": {
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 20,
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "platformKey"
                    ],
                    "properties": {
                      "platformKey": {
                        "type": "string",
                        "description": "Platform key already present on the selected draft."
                      },
                      "caption": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "maxLength": 12000,
                        "description": "Optional replacement draft caption. Null clears the caption."
                      },
                      "scheduledAt": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "Optional draft schedule candidate. Null clears the draft schedule candidate. This does not create a publishing job."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "UpdateDraftPostsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "updatedPosts",
          "skippedPosts",
          "safety"
        ],
        "properties": {
          "updatedPosts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "required": [
                "id",
                "title",
                "status",
                "approvalStatus",
                "postDate",
                "changedFields",
                "platformUpdates"
              ],
              "properties": {
                "id": {
                  "type": "integer"
                },
                "title": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "draft"
                  ]
                },
                "approvalStatus": {
                  "type": "string",
                  "enum": [
                    "draft"
                  ]
                },
                "postDate": {
                  "type": "string",
                  "format": "date-time"
                },
                "changedFields": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "platformUpdates": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true,
                    "required": [
                      "platformKey",
                      "captionChanged",
                      "scheduledAtChanged"
                    ],
                    "properties": {
                      "platformKey": {
                        "type": "string"
                      },
                      "captionChanged": {
                        "type": "boolean"
                      },
                      "scheduledAtChanged": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          },
          "skippedPosts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "required": [
                "postId",
                "code",
                "message"
              ],
              "properties": {
                "postId": {
                  "type": "integer"
                },
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "safety": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "directPublishing",
              "approvalStatus",
              "approvedOrPostedContentChanged",
              "publishingJobsCreated",
              "providerSideEffects",
              "requiresHumanReviewBeforePublish"
            ],
            "properties": {
              "directPublishing": {
                "type": "boolean",
                "const": false
              },
              "approvalStatus": {
                "type": "string",
                "enum": [
                  "draft"
                ]
              },
              "approvedOrPostedContentChanged": {
                "type": "boolean",
                "const": false
              },
              "publishingJobsCreated": {
                "type": "integer",
                "const": 0
              },
              "providerSideEffects": {
                "type": "boolean",
                "const": false
              },
              "requiresHumanReviewBeforePublish": {
                "type": "boolean",
                "const": true
              }
            }
          }
        }
      },
      "MoveDraftPostsToTrashRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "postIds"
        ],
        "properties": {
          "postIds": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "description": "Explicitly selected Posview post ids to move to the reversible trash. Each post must still be an unapproved draft.",
            "items": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      },
      "MoveDraftPostsToTrashResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "movedPosts",
          "skippedPosts",
          "safety"
        ],
        "properties": {
          "movedPosts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "required": [
                "id",
                "title",
                "previousStatus",
                "previousApprovalStatus",
                "postDate",
                "trashedAt",
                "reversible"
              ],
              "properties": {
                "id": {
                  "type": "integer"
                },
                "title": {
                  "type": "string"
                },
                "previousStatus": {
                  "type": "string"
                },
                "previousApprovalStatus": {
                  "type": "string"
                },
                "postDate": {
                  "type": "string",
                  "format": "date-time"
                },
                "trashedAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "reversible": {
                  "type": "boolean",
                  "const": true
                }
              }
            }
          },
          "skippedPosts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "required": [
                "postId",
                "code",
                "message"
              ],
              "properties": {
                "postId": {
                  "type": "integer"
                },
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "safety": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "permanentDeletion",
              "providerPostsDeleted",
              "mediaDeleted",
              "reversibleInPosview",
              "publishingJobsCreated"
            ],
            "properties": {
              "permanentDeletion": {
                "type": "boolean",
                "const": false
              },
              "providerPostsDeleted": {
                "type": "boolean",
                "const": false
              },
              "mediaDeleted": {
                "type": "boolean",
                "const": false
              },
              "reversibleInPosview": {
                "type": "boolean",
                "const": true
              },
              "publishingJobsCreated": {
                "type": "integer",
                "const": 0
              }
            }
          }
        }
      },
      "CreateProposalRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "proposal"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "post_draft_update",
              "schedule_update",
              "publish_request"
            ],
            "default": "post_draft_update",
            "description": "publish_request requires agent:publish:request and is not included in the initial ChatGPT/OpenAI OAuth preset."
          },
          "targetPlatformKey": {
            "type": [
              "string",
              "null"
            ]
          },
          "proposal": {
            "$ref": "#/components/schemas/PostDraftProposal"
          },
          "diff": {
            "description": "Optional diff metadata for the human review UI"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateProposalResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "proposal"
        ],
        "properties": {
          "proposal": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "postId",
              "type",
              "status",
              "payload",
              "expiresAt"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "postId": {
                "type": "integer"
              },
              "type": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending"
                ]
              },
              "payload": {
                "$ref": "#/components/schemas/PostDraftProposal"
              },
              "expiresAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      },
      "CreateProposalsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "proposals"
        ],
        "properties": {
          "proposals": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "description": "One to ten pending proposal records to create in a single user-approved batch.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "postId",
                "proposal"
              ],
              "properties": {
                "postId": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "Target Posview post id."
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "post_draft_update",
                    "schedule_update",
                    "publish_request"
                  ],
                  "default": "post_draft_update",
                  "description": "publish_request requires agent:publish:request and is not included in the initial ChatGPT/OpenAI OAuth preset."
                },
                "targetPlatformKey": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "proposal": {
                  "$ref": "#/components/schemas/PostDraftProposal"
                },
                "diff": {
                  "description": "Optional diff metadata for the human review UI"
                },
                "expiresAt": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                }
              }
            }
          }
        }
      },
      "CreateProposalsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "proposals",
          "safety"
        ],
        "properties": {
          "proposals": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "postId",
                "type",
                "status",
                "payload",
                "expiresAt"
              ],
              "properties": {
                "id": {
                  "type": "integer"
                },
                "postId": {
                  "type": "integer"
                },
                "type": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending"
                  ]
                },
                "payload": {
                  "$ref": "#/components/schemas/PostDraftProposal"
                },
                "expiresAt": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                }
              }
            }
          },
          "safety": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "recordsCreated",
              "existingPostsChanged",
              "publishingJobsCreated",
              "requiresHumanReview"
            ],
            "properties": {
              "recordsCreated": {
                "type": "integer",
                "minimum": 0
              },
              "existingPostsChanged": {
                "type": "boolean",
                "const": false
              },
              "publishingJobsCreated": {
                "type": "integer",
                "const": 0
              },
              "requiresHumanReview": {
                "type": "boolean",
                "const": true
              }
            }
          }
        }
      },
      "CreateConfirmationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "payload"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "post_draft_update",
              "schedule_update",
              "publish_request"
            ],
            "default": "post_draft_update",
            "description": "publish_request requires agent:publish:request and is not included in the initial ChatGPT/OpenAI OAuth preset."
          },
          "payload": {
            "type": "object",
            "additionalProperties": true,
            "description": "The proposed action for a human editor to review. Include platform keys, captions, schedule candidates, and warnings where relevant."
          },
          "diff": {
            "description": "Optional diff metadata for the human review UI"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateConfirmationResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirmationRequest"
        ],
        "properties": {
          "confirmationRequest": {
            "$ref": "#/components/schemas/ConfirmationRequest"
          }
        }
      },
      "CreateConfirmationRequestItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "postId"
        ],
        "properties": {
          "postId": {
            "type": "integer",
            "minimum": 1,
            "description": "Target Posview post id selected by the user or a prior read/search result."
          },
          "type": {
            "type": "string",
            "enum": [
              "post_draft_update",
              "schedule_update",
              "publish_request"
            ],
            "default": "post_draft_update",
            "description": "publish_request requires agent:publish:request and is not included in the initial ChatGPT/OpenAI OAuth preset."
          },
          "payload": {
            "type": "object",
            "additionalProperties": true,
            "description": "The proposed action for a human editor to review. It is not applied by the batch tool call."
          },
          "diff": {
            "description": "Optional diff metadata for the human review UI"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateConfirmationRequestsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "requests"
        ],
        "properties": {
          "requests": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "description": "One to ten pending confirmation requests to create in a single user-approved batch.",
            "items": {
              "$ref": "#/components/schemas/CreateConfirmationRequestItem"
            }
          }
        }
      },
      "CreateConfirmationRequestsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "confirmationRequests",
          "safety"
        ],
        "properties": {
          "confirmationRequests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConfirmationRequest"
            }
          },
          "safety": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "recordsCreated",
              "requestsRemainPending",
              "appliedImmediately",
              "publishingJobsCreated",
              "providerSideEffects",
              "requiresHumanReview"
            ],
            "properties": {
              "recordsCreated": {
                "type": "integer",
                "minimum": 0
              },
              "requestsRemainPending": {
                "type": "boolean",
                "const": true
              },
              "appliedImmediately": {
                "type": "boolean",
                "const": false
              },
              "publishingJobsCreated": {
                "type": "integer",
                "const": 0
              },
              "providerSideEffects": {
                "type": "boolean",
                "const": false
              },
              "requiresHumanReview": {
                "type": "boolean",
                "const": true
              }
            }
          }
        }
      },
      "ConfirmationRequest": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "id",
          "workspaceId",
          "postId",
          "type",
          "status",
          "payload",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "workspaceId": {
            "type": "integer"
          },
          "postId": {
            "type": [
              "integer",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "post_draft_update",
              "schedule_update",
              "publish_request"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "rejected",
              "expired",
              "applied"
            ]
          },
          "payload": {
            "type": "object",
            "additionalProperties": true
          },
          "diff": {
            "type": [
              "object",
              "string",
              "null"
            ],
            "additionalProperties": true
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PostDraftProposal": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "title",
          "summary",
          "platforms",
          "globalWarnings",
          "requiresHumanConfirmation"
        ],
        "properties": {
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": "string"
          },
          "platforms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostDraftProposalPlatform"
            }
          },
          "globalWarnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requiresHumanConfirmation": {
            "type": "boolean"
          }
        }
      },
      "PostDraftProposalPlatform": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "platformKey",
          "caption",
          "scheduledAt",
          "warnings"
        ],
        "properties": {
          "platformKey": {
            "type": "string"
          },
          "caption": {
            "type": "string"
          },
          "scheduledAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Plan": {
        "type": "string",
        "enum": [
          "free",
          "pro",
          "agency"
        ]
      }
    }
  },
  "x-posview-data-handling": {
    "version": "2026-06-07",
    "workspaceScoped": true,
    "leastPrivilegeScopes": true,
    "storesPlaintextTokens": false,
    "storesRefreshTokenHashes": true,
    "sendsToAiClient": [
      "workspace context",
      "post metadata",
      "post captions and scheduled times",
      "preview-safe post details",
      "draft/proposal/confirmation request results"
    ],
    "neverSendsToAiClient": [
      "SNS OAuth tokens",
      "Agent API keys",
      "preview passcodes",
      "Stripe billing secrets",
      "other workspaces"
    ],
    "responseFieldDenylist": [
      "accessToken",
      "refreshToken",
      "tokenHash",
      "apiKey",
      "secret",
      "password",
      "mfaSecret",
      "totpSecret",
      "passcode",
      "previewPasscode",
      "billingAccountId",
      "stripeCustomerId",
      "stripeSubscriptionId",
      "paymentMethodId",
      "cardNumber",
      "cvv",
      "ssn",
      "taxId",
      "medicalRecord"
    ],
    "minimizationRules": [
      "Return only the workspace, post, platform, preview-safe, draft, proposal, and confirmation fields needed for the requested action.",
      "Do not return credentials, OAuth tokens, API keys, preview passcodes, payment identifiers, MFA secrets, or unrelated workspace data.",
      "Use stable post/workspace identifiers only when the AI client needs them for the next authorized Agent API or MCP call."
    ],
    "logRetention": {
      "promptResponseTranscriptsVisibleToServiceAdmins": false,
      "retainedRecords": [
        "OAuth grant status",
        "refresh token hashes",
        "connected editor attribution",
        "OAuth client attribution",
        "Agent API/MCP operation metadata",
        "post history and audit summaries for write-side actions"
      ],
      "summary": "External Agent API and MCP tool prompt/response transcripts are not exposed to service admins as raw transcript logs. Posview retains the minimal connection, token hash, attribution, operation, post history, and audit records needed for revoke, security, usage, and workspace audit flows."
    },
    "retentionDeletion": {
      "summary": "AI connector data retention is scoped to the minimum records needed for revoke, security, usage, and workspace audit flows. Posview does not keep a separate AI-owned copy of workspace content; post, draft, proposal, and confirmation data remain governed by the normal workspace, post, account deletion, and legal retention processes.",
      "items": [
        {
          "id": "tool_payloads_and_raw_transcripts",
          "dataCategory": "Raw AI prompt/response transcripts and transient tool payloads",
          "retainedRecords": [
            "No Service Admin raw prompt/response transcript view for external Agent API / MCP tool activity",
            "No repository-stored ChatGPT screenshot or transcript evidence"
          ],
          "retentionPurpose": "Avoid retaining more prompt or response content than the current authorized request and external review evidence process require.",
          "deletionTrigger": "Normal request completion, approved evidence cleanup, or legal/support review of externally stored evidence.",
          "deletionBehavior": "Do not treat raw AI transcripts as a retained Posview admin log. External review evidence is kept outside the repository and removed or redacted through the approved evidence process.",
          "publicPolicySurface": "/en/privacy, /jp/privacy, /en/apps/ai-agents, /jp/apps/ai-agents, /llms.txt",
          "reviewerChecks": [
            "Confirm public pages say raw external Agent API / MCP prompt-response transcripts are not exposed as Service Admin raw log views.",
            "Confirm generated review packets contain placeholders and policy text only, not screenshots or raw transcript dumps."
          ]
        },
        {
          "id": "oauth_grants_and_refresh_hashes",
          "dataCategory": "AI OAuth grants, grant status, and refresh token hashes",
          "retainedRecords": [
            "OAuth grant status",
            "refresh token hashes",
            "connected editor attribution",
            "OAuth client attribution"
          ],
          "retentionPurpose": "Support reconnect, revoke, stale-token rejection, scope enforcement, security investigation, and workspace audit trails without storing plaintext tokens.",
          "deletionTrigger": "Connected AI Apps revoke, token expiry or rotation, account deletion request, workspace closure, or security/legal retention review.",
          "deletionBehavior": "Deactivate or revoke the grant, invalidate token hashes, reject stale access, and retain only token-free audit summaries when needed for security or legal obligations.",
          "publicPolicySurface": "/ai-connector.json data_handling, /mcp-tools.json dataHandling, /openapi.json x-posview-data-handling",
          "reviewerChecks": [
            "Confirm the revoke-and-stale-token recovery flow rejects old access tokens.",
            "Confirm dataHandling storesPlaintextTokens is false and storesRefreshTokenHashes is true."
          ]
        },
        {
          "id": "operation_metadata_audit",
          "dataCategory": "Agent API / MCP operation metadata and audit summaries",
          "retainedRecords": [
            "tool name or action id",
            "timestamp and status",
            "workspace and actor attribution",
            "post history and audit summaries for write-side actions"
          ],
          "retentionPurpose": "Provide security, usage, support, and workspace auditability while avoiding raw prompt text and restricted credential fields.",
          "deletionTrigger": "Account deletion request, workspace closure, support/legal retention review, or end of the operational need for the audit record.",
          "deletionBehavior": "Delete or anonymize records that are no longer needed, while preserving legally required, security-critical, or aggregated audit records without credential material.",
          "publicPolicySurface": "/en/privacy, /jp/privacy, /llms.txt, /openapi.json x-posview-data-handling",
          "reviewerChecks": [
            "Confirm Response Data Inventory excludes restricted credentials and billing identifiers.",
            "Confirm operation metadata is described as minimal audit data rather than raw transcript logging."
          ]
        },
        {
          "id": "workspace_content_drafts_proposals_confirmations",
          "dataCategory": "Workspace posts, drafts, proposals, and confirmation requests",
          "retainedRecords": [
            "canonical workspace posts",
            "draft posts created by authorized AI calls",
            "pending proposals",
            "pending confirmation requests"
          ],
          "retentionPurpose": "Keep Posview as the canonical workspace source of truth while ensuring AI-created items remain drafts, proposals, or pending human confirmation.",
          "deletionTrigger": "Post deletion, proposal cleanup, confirmation resolution, workspace closure, account deletion request, or normal workspace data lifecycle.",
          "deletionBehavior": "Use the normal Posview workspace/post deletion and anonymization flows. The AI connector does not keep a separate workspace-content copy outside those records.",
          "publicPolicySurface": "/en/privacy, /jp/privacy, /en/terms, /jp/terms, /en/apps/ai-agents, /jp/apps/ai-agents",
          "reviewerChecks": [
            "Confirm draft/proposal/confirmation tools do not directly approve, schedule, publish, or delete posts.",
            "Confirm the review packet maps these records to human confirmation and workspace deletion processes."
          ]
        },
        {
          "id": "reviewer_credentials_external_evidence",
          "dataCategory": "OpenAI review credentials and ChatGPT screenshot evidence",
          "retainedRecords": [
            "no review account credentials in generated packets",
            "no OAuth tokens, OTP codes, preview passcodes, or SNS provider tokens in repository evidence",
            "external screenshots or notes only in the approved evidence location"
          ],
          "retentionPurpose": "Let OpenAI reviewers reproduce the connector safely without committing secrets or private review workspace data.",
          "deletionTrigger": "Post-review credential rotation, evidence retention review, reviewer account cleanup, or failed credential-safety preflight.",
          "deletionBehavior": "Keep credentials in the approved secure channel only, rotate or revoke review access after review, and redact or remove external screenshots according to the approved evidence process.",
          "publicPolicySurface": "docs/ai-app-submission-review-packet.md, docs/ai-app-submission-evidence.md, todo.md manual evidence markers",
          "reviewerChecks": [
            "Confirm static preflight rejects credential-like material in generated and handoff docs.",
            "Confirm Screenshot Evidence Matrix redaction rules are followed before storing external review evidence."
          ]
        }
      ]
    },
    "retentionSummary": "External Agent API and MCP tool prompt/response transcripts are not exposed to service admins as raw transcript logs. Posview retains the minimal connection, token hash, attribution, operation, post history, and audit records needed for revoke, security, usage, and workspace audit flows."
  },
  "x-posview-runtime-availability": {
    "version": "2026-06-07",
    "summary": "AI OAuth and Agent API access is rechecked on every token exchange and runtime request. Posview blocks AI access for Free workspaces, global or workspace emergency mode, closed workspaces, inactive grants or memberships, unavailable connected editors, and insufficient OAuth scopes.",
    "allowedPlans": [
      "pro",
      "agency"
    ],
    "checkedOn": [
      "OAuth authorization code exchange",
      "OAuth refresh token rotation",
      "Agent API bearer authentication",
      "MCP bearer authentication",
      "MCP runtime tool calls"
    ],
    "blocks": [
      {
        "code": "oauth_plan_required",
        "condition": "The workspace effective plan is Free.",
        "recovery": "Move the workspace to Pro or Agency, then reconnect or retry the AI app."
      },
      {
        "code": "emergency_mode",
        "condition": "Global or workspace emergency mode is active.",
        "recovery": "Resolve emergency mode in Posview before retrying the AI operation."
      },
      {
        "code": "workspace_closed",
        "condition": "The workspace is closed or scheduled for deletion.",
        "recovery": "Use an active workspace or reopen the workspace before connecting AI clients."
      },
      {
        "code": "oauth_grant_inactive",
        "condition": "The OAuth grant, OAuth client, workspace membership, or connected editor is no longer active.",
        "recovery": "Reconnect Posview from the AI client and confirm the workspace membership is active."
      },
      {
        "code": "insufficient_scope",
        "condition": "The OAuth access token is missing the scope required by a tool.",
        "recovery": "Re-authorize Posview with the required scope, then retry the same operation."
      }
    ]
  }
}
