{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/autoposting-ai/json-schema/autoposting-ai-post-schema.json",
  "title": "Post",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/autoposting-ai-openapi.json#/components/schemas/Post",
  "type": "object",
  "required": [
    "id",
    "brandSlug",
    "text",
    "platforms",
    "status"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "brandSlug": {
      "type": "string"
    },
    "text": {
      "type": "string"
    },
    "platforms": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "x",
          "linkedin",
          "instagram",
          "threads",
          "youtube",
          "facebook"
        ]
      }
    },
    "status": {
      "$ref": "#/$defs/PostStatus"
    },
    "scheduledAt": {
      "type": "string",
      "format": "date-time"
    },
    "media": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MediaObject"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "facebookOptions": {
      "$ref": "#/$defs/FacebookOptions"
    },
    "targetAccountIds": {
      "$ref": "#/$defs/TargetAccountIds"
    },
    "platformTexts": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Platform captions. An empty Facebook string is intentional."
    },
    "platformMedia": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "$ref": "#/$defs/MediaObject"
        }
      },
      "description": "Platform media override; an empty Facebook array excludes shared media."
    },
    "facebookRecoveryPageIds": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Server-derived Pages eligible for explicit failed-Page recovery."
    },
    "platformResults": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/PlatformResult"
      }
    }
  },
  "$defs": {
    "FacebookOptions": {
      "type": "object",
      "required": [
        "format"
      ],
      "properties": {
        "format": {
          "type": "string",
          "enum": [
            "text",
            "link",
            "photo",
            "multi-photo",
            "video",
            "reel"
          ]
        },
        "link": {
          "type": "string",
          "format": "uri",
          "description": "Public HTTPS article URL; required for link format."
        }
      }
    },
    "MediaObject": {
      "type": "object",
      "required": [
        "url",
        "type"
      ],
      "properties": {
        "url": {
          "type": "string",
          "description": "URL of the media file."
        },
        "type": {
          "type": "string",
          "enum": [
            "image",
            "video"
          ],
          "description": "Media type."
        },
        "altText": {
          "type": "string",
          "description": "Alt text for the media (used for accessibility and LinkedIn)."
        }
      }
    },
    "PlatformResult": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "publishing",
            "published",
            "failed",
            "partial",
            "unknown"
          ]
        },
        "accounts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "platformUserId": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "published",
                  "failed",
                  "unknown"
                ]
              },
              "platformPostId": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "error": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "PostStatus": {
      "type": "string",
      "description": "Lifecycle status of a post.",
      "enum": [
        "draft",
        "scheduled",
        "validating",
        "validated",
        "publishing",
        "published",
        "partial",
        "failed",
        "archived",
        "render_pending",
        "billing_hold"
      ]
    },
    "TargetAccountIds": {
      "type": "object",
      "description": "Explicit selected connected account IDs by platform. Facebook requires a non-empty facebook Page ID array, even when only one Page is connected.",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "properties": {
        "facebook": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}