{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antwork-io/json-schema/antwork-io-account-detail-schema.json",
  "title": "AccountDetail",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antwork-io-openapi.json#/components/schemas/AccountDetail",
  "allOf": [
    {
      "$ref": "#/$defs/Account"
    },
    {
      "type": "object",
      "required": [
        "settings"
      ],
      "properties": {
        "settings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SettingField"
          }
        },
        "boards": {
          "type": [
            "array",
            "null"
          ],
          "description": "Pinterest only. Null when Pinterest refused the lookup.",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "boardsError": {
          "type": "string"
        },
        "reconnect": {
          "type": "boolean"
        },
        "dailyPostCap": {
          "type": [
            "object",
            "null"
          ],
          "description": "Posts this account may publish per rolling 24 hours on the owner's plan, and what is left. `remaining` subtracts both the posts published in the last 24 hours and those scheduled in the next 24, as the cap check does. `publishedLast24h` and `remaining` are absent when the count could not be read.",
          "properties": {
            "limit": {
              "type": "integer"
            },
            "windowHours": {
              "const": 24
            },
            "tier": {
              "type": "string",
              "enum": [
                "free",
                "paid"
              ]
            },
            "publishedLast24h": {
              "type": "integer"
            },
            "scheduledNext24h": {
              "type": "integer"
            },
            "remaining": {
              "type": "integer"
            },
            "platformLimit": {
              "type": "integer",
              "description": "The platform's maximum on the plan, when the owner set a lower `accountLimit`."
            },
            "accountLimit": {
              "type": "integer",
              "description": "The owner’s own daily maximum (`posting.maxPostsPerDay`); then it is `limit`."
            },
            "minGapMinutes": {
              "type": "integer",
              "description": "The owner’s minimum gap between this account’s posts."
            }
          }
        },
        "posting": {
          "oneOf": [
            {
              "$ref": "#/$defs/PostingSettings"
            },
            {
              "type": "null"
            }
          ]
        },
        "recentPosts": {
          "type": "array",
          "description": "With `include=recentPosts`: up to 15 of the account’s posts, its voice, text cut at 600 characters.",
          "items": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "publishedAt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "metrics": {
                "type": "object"
              }
            }
          }
        },
        "bestTimes": {
          "type": "object",
          "description": "With `include=bestTimes`: the suggested posting times the composer shows."
        }
      }
    }
  ],
  "$defs": {
    "Account": {
      "type": "object",
      "required": [
        "object",
        "id",
        "workspaceId",
        "platform",
        "name",
        "active",
        "tokenHealth"
      ],
      "properties": {
        "object": {
          "const": "account"
        },
        "id": {
          "type": "string"
        },
        "workspaceId": {
          "type": "string"
        },
        "platform": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "handle": {
          "type": [
            "string",
            "null"
          ]
        },
        "accountType": {
          "type": [
            "string",
            "null"
          ]
        },
        "active": {
          "type": "boolean"
        },
        "tokenHealth": {
          "type": "string"
        },
        "connectedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "PostingSettings": {
      "type": "object",
      "description": "The account owner’s own posting rules, enforced like the platform caps (`account_limit_reached`): a daily maximum under the platform’s, a minimum gap between posts, and weekly slots that `scheduledFor: \"next_slot\"` fills.",
      "properties": {
        "maxPostsPerDay": {
          "type": "integer",
          "minimum": 1,
          "description": "At most this many posts in any 24 hours, at most the platform’s cap."
        },
        "minGapMinutes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1440
        },
        "timezone": {
          "type": "string",
          "description": "IANA zone of `slots`; the workspace’s when absent, else UTC."
        },
        "slots": {
          "type": "array",
          "maxItems": 50,
          "items": {
            "type": "object",
            "required": [
              "day",
              "time"
            ],
            "properties": {
              "day": {
                "type": "integer",
                "minimum": 1,
                "maximum": 7,
                "description": "1 = Monday … 7 = Sunday."
              },
              "time": {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
                "description": "Local time, HH:MM."
              }
            }
          }
        }
      }
    },
    "SettingField": {
      "type": "object",
      "required": [
        "key",
        "label",
        "type"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "enum",
            "bool",
            "text",
            "url"
          ]
        },
        "options": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "value": {
                "type": "string"
              },
              "label": {
                "type": "string"
              }
            }
          }
        },
        "default": {},
        "maxLength": {
          "type": "integer"
        },
        "placeholder": {
          "type": "string"
        }
      }
    }
  }
}