{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/creavily/json-schema/creavily-channel-account-upsert-request-schema.json",
  "title": "ChannelAccountUpsertRequest",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/creavily-openapi.json#/components/schemas/ChannelAccountUpsertRequest",
  "type": "object",
  "properties": {
    "organizationId": {
      "type": "string",
      "minLength": 1
    },
    "brandId": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "platformAppId": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "platform": {
      "type": "string",
      "enum": [
        "instagram_business",
        "instagram_standalone",
        "facebook_page",
        "threads",
        "youtube",
        "pinterest",
        "tiktok",
        "x"
      ]
    },
    "externalAccountId": {
      "type": "string",
      "minLength": 1
    },
    "displayName": {
      "type": "string",
      "minLength": 1
    },
    "handle": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "state": {
      "default": "connected",
      "type": "string",
      "enum": [
        "not_connected",
        "connecting",
        "in_between_steps",
        "connected",
        "expiring",
        "refresh_needed",
        "reconnect_required",
        "disabled",
        "deleted"
      ]
    },
    "tokenExpiresAt": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "accessTokenRef": {
      "type": "string",
      "minLength": 1
    },
    "refreshTokenRef": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "scopes": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "required": [
    "organizationId",
    "platform",
    "externalAccountId",
    "displayName",
    "accessTokenRef"
  ]
}