{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/post-mesh-com/json-schema/post-mesh-com-post-detail-schema.json",
  "title": "PostDetail",
  "description": "投稿の詳細",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/post-mesh-com-openapi.json#/components/schemas/PostDetail",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "投稿 ID"
    },
    "status": {
      "$ref": "#/$defs/PostDetailStatus"
    },
    "category": {
      "$ref": "#/$defs/PostCategory"
    },
    "media_ids": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "関連するメディア ID の配列（API 経由で作成した投稿の場合。動画は最大 1 件、画像は複数件。Web UI から作成した投稿は空配列）"
    },
    "tree_cards": {
      "type": "array",
      "description": "ツリー投稿のカードの配列（`category: tree`の場合のみ。それ以外のカテゴリでは常に空配列）。\nリクエストの`tree_cards`と同じ順序で、先頭が起点の投稿、以降がぶら下がる返信です。\n",
      "items": {
        "$ref": "#/$defs/TreeCard"
      }
    },
    "scheduled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "予約投稿日時。即時投稿と、予約日時のない下書きの場合は null。"
    },
    "can_cancel": {
      "type": "boolean",
      "description": "キャンセル可能かどうか。配信処理が始まっておらず、下書き、または予約日時が未来の予約投稿の場合に true。"
    },
    "platforms": {
      "type": "array",
      "description": "プラットフォームごとの詳細ステータス",
      "items": {
        "$ref": "#/$defs/PlatformPostDetail"
      }
    },
    "display_at": {
      "type": "string",
      "format": "date-time",
      "description": "表示日時。一覧の並び順に使う日時です。予約済みの投稿と予約日時つきの下書きでは予約日時、予約日時のない下書きでは最後に保存した日時になります。"
    }
  },
  "required": [
    "id",
    "status",
    "category",
    "media_ids",
    "tree_cards",
    "scheduled_at",
    "can_cancel",
    "platforms",
    "display_at"
  ],
  "$defs": {
    "Platform": {
      "type": "string",
      "enum": [
        "youtube",
        "tiktok",
        "instagram",
        "threads",
        "x",
        "facebook"
      ],
      "description": "SNS プラットフォーム"
    },
    "PlatformPostDetail": {
      "type": "object",
      "description": "プラットフォームごとの投稿ステータス",
      "properties": {
        "platform": {
          "$ref": "#/$defs/Platform"
        },
        "connection_id": {
          "type": "string",
          "description": "連携 ID（連携が存在しない場合は空文字列）"
        },
        "account_name": {
          "type": "string",
          "description": "アカウント名（取得できない場合は空文字列）"
        },
        "status": {
          "$ref": "#/$defs/PlatformPostDetailStatus"
        },
        "caption": {
          "type": "string",
          "description": "プラットフォームごとのキャプション"
        },
        "youtube_title": {
          "type": [
            "string",
            "null"
          ],
          "description": "YouTube 投稿のタイトル。YouTube 以外のプラットフォームでは null。"
        },
        "tiktok_settings": {
          "allOf": [
            {
              "$ref": "#/$defs/TikTokPostSettings"
            }
          ],
          "nullable": true,
          "description": "投稿のときに保存した TikTok の設定。TikTok 以外のプラットフォームでは null。"
        },
        "external_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "プラットフォーム上の投稿 URL"
        },
        "error_message": {
          "type": [
            "string",
            "null"
          ],
          "description": "投稿失敗時のエラーメッセージ"
        }
      },
      "required": [
        "platform",
        "connection_id",
        "account_name",
        "status",
        "caption",
        "youtube_title",
        "tiktok_settings",
        "external_url",
        "error_message"
      ]
    },
    "PlatformPostDetailStatus": {
      "type": "string",
      "enum": [
        "posted",
        "scheduled",
        "processing",
        "failed",
        "draft",
        "cancelled"
      ],
      "description": "プラットフォームごとの投稿ステータス: draft（下書き）/ cancelled（キャンセル済み）を含む"
    },
    "PostCategory": {
      "type": "string",
      "enum": [
        "video",
        "image",
        "text",
        "tree"
      ],
      "description": "投稿のコンテンツ種別: video（動画）/ image（画像）/ text（テキスト）/ tree（ツリー投稿）"
    },
    "PostDetailStatus": {
      "type": "string",
      "enum": [
        "posted",
        "scheduled",
        "processing",
        "failed",
        "draft",
        "cancelled"
      ],
      "description": "投稿ステータス（詳細）: draft（下書き）/ cancelled（キャンセル済み）を含む"
    },
    "TikTokPostSettings": {
      "type": "object",
      "description": "投稿のときに保存した TikTok の設定。作成時の `targets[]` の同名の指定（`tiktok_` を除いた名前）に対応します。\n下書き送信（`draft: true`）では公開時の設定を持たないため、`draft` 以外は null です。\n",
      "properties": {
        "draft": {
          "type": "boolean",
          "description": "公開せず TikTok アプリの受信箱へ下書きとして送るかどうか（`tiktok_draft`）"
        },
        "privacy_level": {
          "type": [
            "string",
            "null"
          ],
          "description": "この投稿を見せる相手（`tiktok_privacy_level`）。下書きでは null。"
        },
        "allow_comment": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "コメントを許可するかどうか（`tiktok_allow_comment`）。下書きでは null。"
        },
        "allow_duet": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "デュエットを許可するかどうか（`tiktok_allow_duet`）。動画以外と下書きでは null。"
        },
        "allow_stitch": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "ステッチを許可するかどうか（`tiktok_allow_stitch`）。動画以外と下書きでは null。"
        },
        "auto_add_music": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "おすすめの音楽を自動で付けるかどうか（`tiktok_auto_add_music`）。画像以外と下書きでは null。"
        },
        "is_ai_generated": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "AI 生成ラベルを付けるかどうか（`is_ai_generated`）。下書きでは null。"
        }
      },
      "required": [
        "draft",
        "privacy_level",
        "allow_comment",
        "allow_duet",
        "allow_stitch",
        "auto_add_music",
        "is_ai_generated"
      ]
    },
    "TreeCard": {
      "type": "object",
      "description": "ツリー投稿のカード（レスポンス）",
      "properties": {
        "caption": {
          "type": [
            "string",
            "null"
          ],
          "description": "カードの本文。本文なしのカードでは null。"
        },
        "media_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "カードに添えたメディア ID の配列（メディアなしの場合は空配列）"
        }
      },
      "required": [
        "caption",
        "media_ids"
      ]
    }
  }
}