openapi: 3.1.0
info:
  title: PressAPI
  version: 0.1.0
  description: Render HTML, URLs, or a built-in invoice template to PDF or PNG.
servers:
  - url: /
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /health:
    get:
      security: []
      summary: Liveness
      responses:
        "200":
          description: OK
  /v1/render:
    post:
      summary: Create a render
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                html: { type: string }
                url: { type: string, format: uri }
                template: { type: string, enum: [invoice] }
                data: { type: object }
                format: { type: string, enum: [pdf, png], default: pdf }
                paper: { type: string, enum: [a4, letter], default: a4 }
                landscape: { type: boolean }
                margin:
                  type: object
                  properties:
                    top: { type: string }
                    right: { type: string }
                    bottom: { type: string }
                    left: { type: string }
      responses:
        "201":
          description: Render created
        "400":
          description: Bad request
        "401":
          description: Missing key
  /v1/renders/{id}:
    get:
      summary: Get render status
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Render
  /v1/renders/{id}/file:
    get:
      summary: Download the file
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Binary PDF or PNG
  /v1/usage:
    get:
      summary: Usage for the current key
      responses:
        "200":
          description: Counts
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
