{
  "components": {
    "schemas": {
      "Error": {
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "NewPost": {
        "properties": {
          "at": {
            "format": "date-time",
            "type": "string"
          },
          "caption": {
            "type": "string"
          },
          "captions": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "cover": {
            "type": "string"
          },
          "id": {
            "pattern": "^[a-z0-9-]{1,64}$",
            "type": "string"
          },
          "public_cover_url": {
            "type": "string"
          },
          "public_video_url": {
            "type": "string"
          },
          "settings": {
            "additionalProperties": {
              "type": "object"
            },
            "type": "object"
          },
          "targets": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          },
          "video": {
            "description": "a name from /v1/media",
            "type": "string"
          }
        },
        "required": [
          "id",
          "at",
          "title",
          "video",
          "targets",
          "caption"
        ],
        "type": "object"
      },
      "Post": {
        "properties": {
          "at": {
            "format": "date-time",
            "type": "string"
          },
          "cover": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "source": {
            "enum": [
              "config",
              "api"
            ]
          },
          "targets": {
            "items": {
              "$ref": "#/components/schemas/Target"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          },
          "video": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Target": {
        "properties": {
          "approval": {
            "enum": [
              "no",
              "ok",
              "changed"
            ]
          },
          "approved_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "network": {
            "type": "string"
          },
          "posted_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "enum": [
              "waiting",
              "due",
              "posting",
              "posted",
              "failed"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearer": {
        "description": "DebugInit ID access token for an account with API access",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "The posting API behind Pulse: queue videos, approve each post × network, publish through each network's official API. Write calls need write access. Guide: /docs",
    "title": "Pulse Publish",
    "version": "0.1.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/activity": {
      "get": {
        "parameters": [
          {
            "in": "query",
            "name": "lines",
            "schema": {
              "maximum": 500,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{lines}"
          }
        },
        "summary": "Latest log lines"
      }
    },
    "/v1/health": {
      "get": {
        "responses": {
          "200": {
            "description": "{ok, service, version}"
          }
        },
        "security": [],
        "summary": "Health (public)"
      }
    },
    "/v1/me": {
      "get": {
        "responses": {
          "200": {
            "description": "caller"
          }
        },
        "summary": "Who is calling; write on/off; schedule"
      }
    },
    "/v1/media": {
      "get": {
        "responses": {
          "200": {
            "description": "{media:[{name, bytes}]}"
          }
        },
        "summary": "Uploaded files"
      },
      "post": {
        "parameters": [
          {
            "in": "query",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/octet-stream": {}
          }
        },
        "responses": {
          "201": {
            "description": "{name, bytes}"
          },
          "409": {
            "description": "name taken"
          },
          "413": {
            "description": "too large"
          }
        },
        "summary": "Upload a video or cover (raw body)"
      }
    },
    "/v1/networks": {
      "get": {
        "responses": {
          "200": {
            "description": "networks"
          }
        },
        "summary": "Networks: connected, account, keys, redirect URL, expiry, limits"
      }
    },
    "/v1/networks/{network}": {
      "delete": {
        "parameters": [
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{disconnected}"
          }
        },
        "summary": "Forget this server's sign-in for a network"
      }
    },
    "/v1/networks/{network}/connect": {
      "post": {
        "parameters": [
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{connected, account}"
          }
        },
        "summary": "Connect a handle/password network (Bluesky, Mastodon) from server config"
      }
    },
    "/v1/networks/{network}/signin": {
      "post": {
        "parameters": [
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{open, redirect_url}"
          }
        },
        "summary": "Start a browser sign-in; open the returned URL"
      }
    },
    "/v1/posts": {
      "get": {
        "responses": {
          "200": {
            "description": "{posts:[Post]}"
          }
        },
        "summary": "The queue"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewPost"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Post"
          },
          "400": {
            "description": "what is wrong"
          }
        },
        "summary": "Create a post"
      }
    },
    "/v1/posts/{id}": {
      "delete": {
        "parameters": [
          {
            "description": "post id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{deleted}"
          }
        },
        "summary": "Delete a post made through the API (until something is posted)"
      },
      "get": {
        "parameters": [
          {
            "description": "post id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Post"
          }
        },
        "summary": "One post"
      }
    },
    "/v1/posts/{id}/{network}": {
      "get": {
        "parameters": [
          {
            "description": "post id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "preview"
          }
        },
        "summary": "Exact preview for one network"
      }
    },
    "/v1/posts/{id}/{network}/approve": {
      "post": {
        "parameters": [
          {
            "description": "post id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Post"
          }
        },
        "summary": "Approve exactly this content"
      }
    },
    "/v1/posts/{id}/{network}/publish": {
      "post": {
        "parameters": [
          {
            "description": "post id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "{publishing, check}"
          },
          "409": {
            "description": "not approved, changed, or already posted"
          }
        },
        "summary": "Publish now (must be approved)"
      }
    },
    "/v1/posts/{id}/{network}/unapprove": {
      "post": {
        "parameters": [
          {
            "description": "post id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "network id",
            "in": "path",
            "name": "network",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Post"
          }
        },
        "summary": "Withdraw approval"
      }
    }
  },
  "security": [
    {
      "bearer": []
    }
  ],
  "servers": [
    {
      "url": "https://publish.debuginit.com"
    }
  ]
}