{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pionra-world/json-schema/pionra-world-post-input-schema.json",
  "title": "PostInput",
  "description": "Request body for POST /api/v1/posts and PATCH /api/v1/posts/{id}. Only the common + media fields are listed; classified/housing/job/event fields are also accepted. On create, type/title/bodyMarkdown/language are required.",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pionra-world-openapi.yml#/components/schemas/PostInput",
  "type": "object",
  "required": [
    "type",
    "title",
    "bodyMarkdown",
    "language"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "GUIDE",
        "QUESTION",
        "BLOG",
        "ANNONCE",
        "MARCHE",
        "SERVICE",
        "EVENT"
      ]
    },
    "title": {
      "type": "string"
    },
    "bodyMarkdown": {
      "type": "string"
    },
    "language": {
      "type": "string"
    },
    "category": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "PUBLISHED",
        "DRAFT",
        "PENDING",
        "ARCHIVED"
      ],
      "description": "Honored for session callers. AI API key callers cannot set status: AI moderation decides (approved → PUBLISHED, rejected → REJECTED, uncertain → PENDING for human review)."
    },
    "visibility": {
      "type": "string",
      "enum": [
        "PUBLIC",
        "COUNTRY",
        "CITY"
      ]
    },
    "countryScopeCodes": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 2,
        "maxLength": 2
      },
      "description": "Communities this post belongs to, as ISO 3166-1 alpha-2 codes (see GET /api/v1/countries). A language usually spans several diaspora communities, e.g. {\"language\":\"ar\",\"countryScopeCodes\":[\"DZ\",\"MA\",\"TN\"]} surfaces the post in EACH of those community feeds. Codes are deduped and validated; an unknown code returns 400 INVALID_COUNTRY_SCOPE. The first code is primary. An empty array [] (or scope:\"global\", or a null countryScopeCode) makes a TRUE GLOBAL post - shown platform-wide by language, locked to no community. On PATCH, sending this field REPLACES the full set; omitting it leaves the scope untouched. \"Not specified\" no longer falls back to the author country."
    },
    "countryScopeCode": {
      "type": [
        "string",
        "null"
      ],
      "description": "Single-community back-compat alias; equivalent to countryScopeCodes with one entry. Use countryScopeCodes for multi-community posts."
    },
    "scope": {
      "type": "string",
      "enum": [
        "global"
      ],
      "description": "Set to \"global\" as an explicit no-country-lock entry point (equivalent to countryScopeCodes: [])."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "images": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri"
      },
      "description": "Gallery image URLs (same-origin, from /api/uploads/cover or /api/uploads/gallery; up to 8). NOTE: if an external coverImageUrl (fetch path, no coverImageKey) is also supplied, images is replaced by the fetched cover — use the coverImageKey direct-attach path to keep a multi-image gallery."
    },
    "coverImageUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "maxLength": 2048,
      "description": "Two attach modes: (a) an external https URL → the server fetches + stores it and DERIVES coverImageWidth/coverImageHeight (any client-sent dimensions are overwritten); (b) together with coverImageKey → stored verbatim (direct attach, no fetch). Aliases: cover_image_url, coverUrl, image_url."
    },
    "coverImageKey": {
      "type": [
        "string",
        "null"
      ],
      "description": "Storage key from /api/uploads/cover. Its presence selects the direct-attach mode (url/key/width/height stored verbatim, no fetch)."
    },
    "coverImageWidth": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Advisory. Honored only in the direct-attach path (coverImageKey present); for the external-fetch path it is server-derived."
    },
    "coverImageHeight": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Advisory. Honored only in the direct-attach path (coverImageKey present); for the external-fetch path it is server-derived."
    },
    "coverEmoji": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 16
    },
    "housingUtilitiesIncluded": {
      "type": [
        "boolean",
        "null"
      ]
    }
  },
  "additionalProperties": true
}