{
  "openapi": "3.1.0",
  "info": {
    "title": "DraftPop campaign connector — private trial",
    "version": "1.1.0",
    "description": "Bring draft text from any assistant. All campaigns require explicit owner approval in DraftPop. Connector keys cannot approve content. PATCH invalidates approval. Schedule only a returned, approved revision; never infer approval. Each destination uses one scheduling credit. No engagement analytics or video in campaigns. Keys expire after 90 days and can be revoked. Publishing credentials are never shared. Preserve sourceRefs when editing existing source-backed posts; DraftPop checks source approval, revision and UTC expiry at review and scheduling."
  },
  "servers": [
    {
      "url": "https://www.draftpop.ai/api/connector/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Dedicated dp_ access key created in DraftPop Assistant access."
      }
    },
    "schemas": {
      "CampaignContent": {
        "type": "object",
        "required": [
          "title",
          "weekOf",
          "timeZone",
          "posts"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1
          },
          "brief": {
            "type": "string",
            "maxLength": 3000
          },
          "weekOf": {
            "type": "string",
            "format": "date"
          },
          "timeZone": {
            "type": "string",
            "maxLength": 100,
            "description": "IANA zone, e.g. America/Chicago."
          },
          "posts": {
            "type": "array",
            "maxItems": 14,
            "items": {
              "$ref": "#/components/schemas/Post"
            }
          }
        }
      },
      "Post": {
        "type": "object",
        "required": [
          "id",
          "label",
          "caption",
          "scheduledAt",
          "targets"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "label": {
            "type": "string",
            "maxLength": 100
          },
          "caption": {
            "type": "string",
            "maxLength": 5000
          },
          "scheduledAt": {
            "type": "string",
            "description": "ISO 8601 datetime with Z or an explicit offset. Empty is allowed in a draft."
          },
          "draftOutputId": {
            "type": "string",
            "maxLength": 100,
            "description": "Owned draft ID from GET /drafts. DraftPop resolves its image."
          },
          "targets": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "object",
              "required": [
                "connectionId",
                "caption"
              ],
              "properties": {
                "connectionId": {
                  "type": "string",
                  "format": "uuid"
                },
                "caption": {
                  "type": "string",
                  "maxLength": 5000
                }
              }
            }
          },
          "sourceRefs": {
            "type": "array",
            "maxItems": 8,
            "description": "Optional provenance returned on posts created from saved business sources. Preserve these references when editing. Source content is private; do not invent source IDs.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "revision",
                "title",
                "expiresOn"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "revision": {
                  "type": "integer",
                  "minimum": 1
                },
                "title": {
                  "type": "string",
                  "maxLength": 120
                },
                "expiresOn": {
                  "type": "string",
                  "description": "YYYY-MM-DD in UTC, or empty when no expiry is supplied."
                }
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/accounts": {
      "get": {
        "operationId": "listAccounts",
        "summary": "List connected X, LinkedIn profile, Facebook Page and direct Instagram campaign destinations.",
        "responses": {
          "200": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        }
      }
    },
    "/drafts": {
      "get": {
        "operationId": "retrieveDrafts",
        "summary": "Retrieve up to 100 recent completed draft captions and owned draft IDs.",
        "responses": {
          "200": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        }
      }
    },
    "/campaigns": {
      "get": {
        "operationId": "listCampaigns",
        "summary": "List the 100 most recent campaigns.",
        "responses": {
          "200": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        }
      },
      "post": {
        "operationId": "createCampaign",
        "summary": "Create a campaign with assistant-supplied captions, or an empty draft. Return reviewPath to the user.",
        "responses": {
          "201": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignContent"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Use one stable unique key per create request. Reusing with different content returns 409."
          }
        ]
      }
    },
    "/campaigns/{id}": {
      "get": {
        "operationId": "getCampaignStatus",
        "summary": "Retrieve saved drafts, approval revision, review link and per-destination delivery status.",
        "responses": {
          "200": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "patch": {
        "operationId": "updateCampaign",
        "summary": "Replace draft content using its current revision. Any edit removes approval; scheduled campaigns are immutable.",
        "responses": {
          "200": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/CampaignContent"
                  },
                  {
                    "type": "object",
                    "required": [
                      "revision"
                    ],
                    "properties": {
                      "revision": {
                        "type": "integer",
                        "minimum": 1
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/campaigns/{id}/schedule": {
      "post": {
        "operationId": "scheduleApprovedCampaign",
        "summary": "Schedule only the version explicitly approved in DraftPop. Requires a key with scheduling permission. Safe to repeat for the same revision; retries only confirm unqueued destinations.",
        "responses": {
          "200": {
            "description": "Result; saved campaign includes id, revision, approvedRevision, scheduledRevision, posts and reviewPath when applicable. Delivery posts distinguish scheduled, processing, published, failed and cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Key expired, revoked, or missing"
          },
          "403": {
            "description": "Access not allowed for this key"
          },
          "404": {
            "description": "Not found"
          },
          "409": {
            "description": "Revision conflict or approval required"
          },
          "402": {
            "description": "Not enough scheduling credits"
          },
          "429": {
            "description": "Rate limited"
          },
          "500": {
            "description": "Request failed"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "revision"
                ],
                "properties": {
                  "revision": {
                    "type": "integer",
                    "minimum": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    }
  }
}
