{
  "openapi": "3.1.0",
  "info": {
    "title": "Postii API",
    "version": "0.4.0-workspace",
    "description": "Signed-in workspace API. Independent hosting verifies Postii OAuth sessions; forged identity headers are ignored. Social posts and auto-DM rules are user-scoped sandbox records; workspace_demo is a request alias, not shared storage. Writes require a same-origin browser request. The separate beehiiv posts API creates drafts, publishes, and schedules through each user’s saved API connection, subject to beehiiv Send API access. Public developer tokens and remote MCP are not available.",
    "x-source-revision": "0f629ce21450"
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "paths": {
    "/channels/capabilities": {
      "get": {
        "operationId": "listChannelCapabilities",
        "summary": "List channel capabilities",
        "responses": {
          "200": {
            "description": "Capability documents for supported providers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChannelCapability"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/posts": {
      "get": {
        "operationId": "listPosts",
        "summary": "List workspace posts and publications",
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "workspace_demo"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Posts with per-channel publication state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Post"
                      }
                    },
                    "meta": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Workspace unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "schedulePost",
        "summary": "Validate or schedule a post",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePostRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validated without saving or replayed an existing request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/ValidationResult"
                        },
                        {
                          "$ref": "#/components/schemas/ScheduleResult"
                        }
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Post, publications, and pending automation rules saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ScheduleResult"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or idempotency key",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Workspace unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Channel validation failed",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/connections/beehiiv": {
      "get": {
        "operationId": "getBeehiivConnection",
        "summary": "Read your connected beehiiv publications",
        "description": "Returns saved, previously verified connection metadata for the signed-in user. Does not contact beehiiv or return the key.",
        "responses": {
          "200": {
            "description": "Connection metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "publications": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "verified_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "verified_at"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "publication": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ],
                          "additionalProperties": false,
                          "description": "Legacy alias, only present with exactly one connected publication."
                        },
                        "verified_at": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Legacy single-publication alias."
                        }
                      },
                      "required": [
                        "connected",
                        "publications"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "404": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "413": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "415": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "422": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "502": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "manageBeehiivConnection",
        "summary": "Discover, add, or manage a beehiiv publication",
        "description": "Requires a signed-in user and a same-origin browser request. verify lists publications without saving; discover lists them using an owned saved key. connect verifies target access and upserts only that user/publication pair, preserving others. It accepts a new key or source_publication_id to reuse an owned key. recheck targets one publication. Missing publication_id on recheck/discover works only with exactly one connection. No posts are created or published.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "const": "verify"
                      },
                      "api_key": {
                        "type": "string",
                        "minLength": 8,
                        "maxLength": 4096,
                        "writeOnly": true,
                        "description": "beehiiv API key. Never put it in a URL or browser storage."
                      }
                    },
                    "required": [
                      "action",
                      "api_key"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "const": "connect"
                      },
                      "api_key": {
                        "type": "string",
                        "minLength": 8,
                        "maxLength": 4096,
                        "writeOnly": true,
                        "description": "beehiiv API key. Never put it in a URL or browser storage."
                      },
                      "publication_id": {
                        "type": "string",
                        "pattern": "^pub_[a-fA-F0-9-]{1,100}$"
                      }
                    },
                    "required": [
                      "action",
                      "api_key",
                      "publication_id"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "const": "connect"
                      },
                      "source_publication_id": {
                        "type": "string"
                      },
                      "publication_id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "action",
                      "source_publication_id",
                      "publication_id"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "enum": [
                          "recheck",
                          "discover"
                        ]
                      },
                      "publication_id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "action"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accessible publications for verify/discover; aggregate saved connection metadata for connect/recheck.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "name"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "data"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "connected": {
                              "type": "boolean"
                            },
                            "publications": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "verified_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "verified_at"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "publication": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name"
                              ],
                              "additionalProperties": false,
                              "description": "Legacy alias, only present with exactly one connected publication."
                            },
                            "verified_at": {
                              "type": "string",
                              "format": "date-time",
                              "description": "Legacy single-publication alias."
                            }
                          },
                          "required": [
                            "connected",
                            "publications"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "data"
                      ],
                      "additionalProperties": false
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "404": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "413": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "415": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "422": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "502": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "disconnectBeehiiv",
        "summary": "Disconnect one beehiiv publication",
        "description": "Same-origin request. Deletes only this user’s targeted publication connection and key. Other publications and beehiiv content remain unchanged. Omit publication_id only when exactly one publication is connected; multiple connections require an explicit ID.",
        "parameters": [
          {
            "name": "publication_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disconnected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "publications": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "verified_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "verified_at"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "publication": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ],
                          "additionalProperties": false,
                          "description": "Legacy alias, only present with exactly one connected publication."
                        },
                        "verified_at": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Legacy single-publication alias."
                        }
                      },
                      "required": [
                        "connected",
                        "publications"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "404": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "413": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "415": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "422": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "502": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Connection error; display error text. No credentials are returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/beehiiv/posts": {
      "get": {
        "operationId": "listBeehiivDeliveries",
        "summary": "Read your beehiiv delivery activity or refresh one post",
        "description": "Signed-in user only. Without operation_id returns the latest 50 locally recorded deliveries. With operation_id contacts beehiiv to refresh that post using the same saved publication connection. Does not create or send content.",
        "parameters": [
          {
            "in": "query",
            "name": "operation_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery activity or refreshed status. accepted means processing, not published.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "operation_id": {
                                "type": "string"
                              },
                              "publication_id": {
                                "type": "string"
                              },
                              "publication_name": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "action": {
                                "enum": [
                                  "draft",
                                  "publish",
                                  "schedule"
                                ]
                              },
                              "state": {
                                "enum": [
                                  "submitting",
                                  "accepted",
                                  "draft",
                                  "scheduled",
                                  "published",
                                  "failed",
                                  "uncertain",
                                  "archived"
                                ]
                              },
                              "scheduled_at": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "provider_post_id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "error": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "url": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "created_at": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "operation_id",
                              "publication_id",
                              "publication_name",
                              "title",
                              "action",
                              "state",
                              "scheduled_at",
                              "provider_post_id",
                              "error",
                              "url",
                              "created_at"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "data"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "operation_id": {
                              "type": "string"
                            },
                            "publication_id": {
                              "type": "string"
                            },
                            "publication_name": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "action": {
                              "enum": [
                                "draft",
                                "publish",
                                "schedule"
                              ]
                            },
                            "state": {
                              "enum": [
                                "submitting",
                                "accepted",
                                "draft",
                                "scheduled",
                                "published",
                                "failed",
                                "uncertain",
                                "archived"
                              ]
                            },
                            "scheduled_at": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "provider_post_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "error": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "url": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "operation_id",
                            "publication_id",
                            "publication_name",
                            "title",
                            "action",
                            "state",
                            "scheduled_at",
                            "provider_post_id",
                            "error",
                            "url",
                            "created_at"
                          ],
                          "additionalProperties": false
                        },
                        "replayed": {
                          "type": "boolean"
                        },
                        "retry_after": {
                          "type": "number"
                        },
                        "refresh_error": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "data"
                      ],
                      "additionalProperties": false
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "404": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "413": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "415": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "422": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createBeehiivPost",
        "summary": "Create a beehiiv draft, publish, or schedule",
        "description": "Uses this signed-in user’s encrypted API connection, never a shared key. Requires same Origin and beehiiv Max/Enterprise Send API permissions. Text-only paragraphs, default template, website plus email to free subscribers. confirm:true must represent explicit approval. Reuse operation_id with identical input on retry; an uncertain send is never automatically repeated. HTTP 202 is an operation result, not proof of publication: inspect data.state and refresh status.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operation_id": {
                    "type": "string",
                    "pattern": "^[a-zA-Z0-9_-]{16,100}$"
                  },
                  "publication_id": {
                    "type": "string",
                    "pattern": "^pub_[a-fA-F0-9-]{1,100}$"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50000
                  },
                  "action": {
                    "enum": [
                      "draft",
                      "publish",
                      "schedule"
                    ]
                  },
                  "scheduled_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Required only for schedule; at least one minute in the future."
                  },
                  "confirm": {
                    "const": true
                  }
                },
                "required": [
                  "operation_id",
                  "publication_id",
                  "title",
                  "content",
                  "action",
                  "confirm"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing operation returned, no second send",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "operation_id": {
                          "type": "string"
                        },
                        "publication_id": {
                          "type": "string"
                        },
                        "publication_name": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "action": {
                          "enum": [
                            "draft",
                            "publish",
                            "schedule"
                          ]
                        },
                        "state": {
                          "enum": [
                            "submitting",
                            "accepted",
                            "draft",
                            "scheduled",
                            "published",
                            "failed",
                            "uncertain",
                            "archived"
                          ]
                        },
                        "scheduled_at": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "provider_post_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "error": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "created_at": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "operation_id",
                        "publication_id",
                        "publication_name",
                        "title",
                        "action",
                        "state",
                        "scheduled_at",
                        "provider_post_id",
                        "error",
                        "url",
                        "created_at"
                      ],
                      "additionalProperties": false
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "retry_after": {
                      "type": "number"
                    },
                    "refresh_error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "202": {
            "description": "Attempt recorded; inspect accepted/failed/uncertain state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "operation_id": {
                          "type": "string"
                        },
                        "publication_id": {
                          "type": "string"
                        },
                        "publication_name": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "action": {
                          "enum": [
                            "draft",
                            "publish",
                            "schedule"
                          ]
                        },
                        "state": {
                          "enum": [
                            "submitting",
                            "accepted",
                            "draft",
                            "scheduled",
                            "published",
                            "failed",
                            "uncertain",
                            "archived"
                          ]
                        },
                        "scheduled_at": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "provider_post_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "error": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "created_at": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "operation_id",
                        "publication_id",
                        "publication_name",
                        "title",
                        "action",
                        "state",
                        "scheduled_at",
                        "provider_post_id",
                        "error",
                        "url",
                        "created_at"
                      ],
                      "additionalProperties": false
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "retry_after": {
                      "type": "number"
                    },
                    "refresh_error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "404": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "413": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "415": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "422": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Request rejected; inspect error. For ambiguous outcomes, reuse the operation ID and check Activity before any new send.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreatePostRequest": {
        "type": "object",
        "properties": {
          "workspace_id": {
            "type": "string"
          },
          "title": {
            "type": "string",
            "maxLength": 96
          },
          "content": {
            "type": "string",
            "minLength": 1,
            "maxLength": 5000
          },
          "channels": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/Provider"
            }
          },
          "scheduled_at": {
            "type": "string",
            "format": "date-time"
          },
          "schedule_timezone": {
            "type": "string",
            "default": "America/Toronto"
          },
          "dry_run": {
            "type": "boolean",
            "default": false
          },
          "auto_dm_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AutoDmRuleInput"
            },
            "maxItems": 8
          }
        },
        "required": [
          "content",
          "channels",
          "scheduled_at"
        ],
        "additionalProperties": false
      },
      "ChannelCapability": {
        "type": "object",
        "properties": {
          "provider": {
            "$ref": "#/components/schemas/Provider"
          },
          "target_type": {
            "type": "string"
          },
          "features": {
            "type": "object",
            "additionalProperties": {
              "type": "boolean"
            }
          },
          "limits": {
            "type": "object"
          },
          "provider_option_schema": {
            "type": "object"
          },
          "preview_kind": {
            "type": "string",
            "enum": [
              "feed",
              "visual",
              "vertical_video",
              "pin"
            ]
          },
          "auto_dm_triggers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "comment_keyword",
                "comment_any",
                "like"
              ]
            }
          },
          "availability": {
            "type": "object",
            "properties": {
              "mode": {
                "const": "sandbox"
              },
              "connected": {
                "const": false
              },
              "note": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "provider",
          "features",
          "limits"
        ]
      },
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "field_errors": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "request_id": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "code",
          "request_id",
          "retryable"
        ]
      },
      "Provider": {
        "type": "string",
        "enum": [
          "x",
          "threads",
          "facebook",
          "instagram",
          "tiktok",
          "linkedin",
          "pinterest",
          "bluesky"
        ]
      },
      "AutoDmRuleInput": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "x",
              "threads",
              "facebook",
              "instagram",
              "tiktok",
              "linkedin",
              "pinterest",
              "bluesky"
            ]
          },
          "trigger": {
            "type": "string",
            "enum": [
              "comment_keyword",
              "comment_any",
              "like"
            ]
          },
          "keyword": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "public_reply": {
            "type": "string",
            "maxLength": 500
          }
        },
        "required": [
          "provider",
          "trigger",
          "message"
        ],
        "additionalProperties": false,
        "allOf": [
          {
            "if": {
              "properties": {
                "trigger": {
                  "const": "comment_keyword"
                }
              }
            },
            "then": {
              "required": [
                "keyword"
              ]
            },
            "else": {
              "properties": {
                "keyword": {
                  "maxLength": 0
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "trigger": {
                  "const": "like"
                }
              }
            },
            "then": {
              "properties": {
                "public_reply": {
                  "maxLength": 0
                }
              }
            }
          }
        ]
      },
      "AutoDmRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "publication_id": {
            "type": "string"
          },
          "provider": {
            "$ref": "#/components/schemas/Provider"
          },
          "trigger": {
            "type": "string"
          },
          "keyword": {
            "type": [
              "string",
              "null"
            ]
          },
          "message": {
            "type": "string"
          },
          "public_reply": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "paused",
              "disabled"
            ]
          }
        },
        "required": [
          "id",
          "publication_id",
          "provider",
          "trigger",
          "message",
          "state"
        ]
      },
      "Publication": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "provider": {
            "$ref": "#/components/schemas/Provider"
          },
          "target_id": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "schedule_timezone": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "provider",
          "target_id",
          "state"
        ]
      },
      "Post": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "editorial_state": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "publications": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Publication"
            }
          },
          "auto_dm_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AutoDmRule"
            }
          }
        },
        "required": [
          "id",
          "title",
          "content",
          "publications",
          "auto_dm_rules"
        ]
      },
      "ScheduleResult": {
        "type": "object",
        "properties": {
          "post_id": {
            "type": "string"
          },
          "publication_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "auto_dm_rule_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "state": {
            "const": "scheduled"
          },
          "scheduled_at": {
            "type": "string",
            "format": "date-time"
          },
          "schedule_timezone": {
            "type": "string"
          },
          "idempotent_replay": {
            "type": "boolean"
          }
        },
        "required": [
          "post_id",
          "publication_ids",
          "auto_dm_rule_ids",
          "state",
          "scheduled_at"
        ]
      },
      "ValidationResult": {
        "type": "object",
        "properties": {
          "valid": {
            "const": true
          },
          "publication_count": {
            "type": "integer"
          },
          "auto_dm_count": {
            "type": "integer"
          },
          "scheduled_at": {
            "type": "string",
            "format": "date-time"
          },
          "schedule_timezone": {
            "type": "string"
          }
        },
        "required": [
          "valid",
          "publication_count",
          "auto_dm_count"
        ]
      }
    }
  },
  "x-authentication": "Platform-managed signed-in Site session. No Postii developer tokens or external client authentication flow are available. Examples run from the same-origin signed-in browser; do not construct or copy session headers."
}
