{
  "openapi": "3.0.3",
  "info": {
    "title": "getpdf API",
    "description": "Template-to-PDF REST API. Send a template id, a Handlebars template, or HTML, plus JSON data, to `POST /v1/render` and receive a PDF. Rendered documents are streamed back and are not stored. Each render runs in a sandboxed Chromium context with JavaScript off by default and SSRF protections (localhost, private IPs, 169.254.169.254, and file:// are blocked). Failed renders do not count toward monthly quota.\n\nA free key includes 100 documents per month (no card). Paid plans: Starter $11/month (3,000 docs), Pro $39 (15,000), Scale $79 (50,000). Each paid plan has a 3-day free trial (card required) and then auto-renews until cancelled.\n\nA hosted remote MCP endpoint is live at https://getpdf.dev/mcp (Streamable HTTP; same API keys, quota, and sandbox). There is no published npm package.\n\nOperated by Right Skale. HQ: Pleasanton, CA.",
    "version": "1.0.0",
    "contact": {
      "name": "getpdf",
      "url": "https://getpdf.dev",
      "email": "hello@getpdf.dev"
    },
    "license": {
      "name": "Terms of Service",
      "url": "https://getpdf.dev/terms.html"
    },
    "termsOfService": "https://getpdf.dev/terms.html",
    "x-logo": {
      "url": "https://getpdf.dev/img/mark-192.png",
      "altText": "getpdf"
    }
  },
  "servers": [
    {
      "url": "https://getpdf.dev",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Render",
      "description": "Turn a template and JSON into a PDF."
    },
    {
      "name": "Templates",
      "description": "Built-in and custom Handlebars/HTML templates."
    },
    {
      "name": "Usage",
      "description": "Monthly quota for the authenticated key."
    },
    {
      "name": "Playground",
      "description": "No-key, rate-limited demo renders of three built-in templates."
    },
    {
      "name": "Meta",
      "description": "Service health."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Health check",
        "operationId": "getHealth",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "storage": {
                      "type": "boolean"
                    },
                    "browser": {
                      "type": "boolean"
                    },
                    "paid_plans": {
                      "type": "string",
                      "enum": [
                        "open",
                        "closed"
                      ]
                    },
                    "free_monthly_docs": {
                      "type": "integer",
                      "example": 100
                    },
                    "plans": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "integer"
                      },
                      "example": {
                        "free": 100,
                        "starter": 3000,
                        "pro": 15000,
                        "scale": 50000
                      }
                    },
                    "puppeteer": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/render": {
      "post": {
        "tags": [
          "Render"
        ],
        "summary": "Render a PDF",
        "description": "Renders a PDF from a built-in or custom `template_id`, or from inline Handlebars/HTML in `template` or `html`, plus JSON `data`. Returns `application/pdf`. Quota is incremented only after a successful render. Optional `Idempotency-Key` header replays a prior successful or error response for the same key.",
        "operationId": "renderPdf",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Optional. If reused with the same API key, the original PDF or error is replayed and the response includes `X-Docforge-Idempotent: replay`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderRequest"
              },
              "example": {
                "template_id": "invoice",
                "data": {
                  "number": "INV-1",
                  "currency": "$",
                  "items": [
                    {
                      "description": "Work",
                      "qty": 2,
                      "price": 50
                    }
                  ]
                },
                "options": {
                  "format": "A4",
                  "landscape": false
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PDF bytes. The document is not stored.",
            "headers": {
              "X-Docforge-Usage": {
                "description": "Documents used this calendar month and the plan limit, as `{used}/{limit}`.",
                "schema": {
                  "type": "string",
                  "example": "1/100"
                }
              },
              "X-Docforge-Stages": {
                "description": "Optional render timing stages.",
                "schema": {
                  "type": "string"
                }
              },
              "X-Docforge-Idempotent": {
                "description": "Set to `replay` when a stored idempotent response is returned.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "replay"
                  ]
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/QuotaExceeded"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "502": {
            "$ref": "#/components/responses/RendererFailed"
          },
          "504": {
            "$ref": "#/components/responses/Timeout"
          }
        }
      }
    },
    "/v1/templates": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "List templates",
        "description": "Built-in templates (invoice, receipt, certificate, report, letter) plus custom templates saved on the key. List items do not include template source.",
        "operationId": "listTemplates",
        "responses": {
          "200": {
            "description": "Template list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "templates"
                  ],
                  "properties": {
                    "templates": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TemplateListItem"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Create a custom template",
        "description": "Saves a private Handlebars/HTML template on the key. Maximum 50 custom templates per key. Source must be 262,144 bytes or less. Ids cannot collide with a built-in starter template.",
        "operationId": "createTemplate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Template created. The response does not echo the source.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "template"
                  ],
                  "properties": {
                    "template": {
                      "$ref": "#/components/schemas/TemplateListItem"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          }
        }
      }
    },
    "/v1/templates/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
          },
          "description": "Template id."
        }
      ],
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Get a template",
        "operationId": "getTemplate",
        "responses": {
          "200": {
            "description": "Template, including source for custom and built-in templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "template"
                  ],
                  "properties": {
                    "template": {
                      "$ref": "#/components/schemas/Template"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "tags": [
          "Templates"
        ],
        "summary": "Update a custom template",
        "description": "Built-in starter templates are read-only (403).",
        "operationId": "updateTemplate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated template metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "template"
                  ],
                  "properties": {
                    "template": {
                      "$ref": "#/components/schemas/TemplateListItem"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Delete a custom template",
        "description": "Built-in starter templates cannot be deleted (403).",
        "operationId": "deleteTemplate",
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "Usage"
        ],
        "summary": "Get monthly usage",
        "operationId": "getUsage",
        "responses": {
          "200": {
            "description": "Current calendar-month usage for the key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/playground/render": {
      "post": {
        "tags": [
          "Playground"
        ],
        "summary": "Render a playground sample (no API key)",
        "description": "No authentication. Accepts only a built-in `template_id` of `invoice`, `receipt`, or `certificate`, plus a JSON field map in `data`. Raw HTML, template source, and URLs are rejected. Limited to 5 renders per hour per network and a global daily cap. The PDF includes a \u201cMade with getpdf\u201d footer and is not stored. For ongoing use, get a free API key (100 documents/month).",
        "operationId": "renderPlaygroundPdf",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "template_id"
                ],
                "properties": {
                  "template_id": {
                    "type": "string",
                    "enum": [
                      "invoice",
                      "receipt",
                      "certificate"
                    ]
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "ref": {
                    "type": "string",
                    "description": "Optional aggregate attribution, e.g. `email`. Not tied to a person."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PDF bytes. The document is not stored.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "description": "Playground rate limit (5 per hour per network, or the daily cap).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "$ref": "#/components/responses/RendererFailed"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "df_\u2026",
        "description": "API key issued at https://getpdf.dev/#signup. Send as `Authorization: Bearer df_\u2026`."
      },
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Alternative to the Authorization header. Same `df_\u2026` key."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": true
      },
      "RenderRequest": {
        "type": "object",
        "description": "Provide `template_id`, or inline source in `template` or `html`. `data` is the Handlebars context.",
        "properties": {
          "template_id": {
            "type": "string",
            "description": "Built-in id (`invoice`, `receipt`, `certificate`, `report`, `letter`) or a custom template id on the key. If omitted, provide `template` or `html`."
          },
          "template": {
            "type": "string",
            "description": "Inline Handlebars/HTML source, used when `template_id` is omitted."
          },
          "html": {
            "type": "string",
            "description": "Alias of `template` for inline source."
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "JSON data bound into the template. If omitted and `template_id` is set, the template's sample data is used."
          },
          "options": {
            "$ref": "#/components/schemas/RenderOptions"
          }
        },
        "additionalProperties": true
      },
      "RenderOptions": {
        "type": "object",
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "A4",
              "Letter",
              "Legal"
            ],
            "default": "A4"
          },
          "landscape": {
            "type": "boolean",
            "default": false
          }
        },
        "additionalProperties": true
      },
      "TemplateListItem": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "sample": {
            "type": "object",
            "additionalProperties": true
          },
          "custom": {
            "type": "boolean",
            "description": "False for built-in starters."
          }
        },
        "additionalProperties": true
      },
      "Template": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TemplateListItem"
          },
          {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "description": "Handlebars/HTML source."
              }
            }
          }
        ]
      },
      "TemplateCreate": {
        "type": "object",
        "required": [
          "id",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
          },
          "name": {
            "type": "string",
            "maxLength": 120,
            "description": "Defaults to the id."
          },
          "description": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "description": "Handlebars/HTML. Max 262,144 bytes. `template` is accepted as an alias."
          },
          "template": {
            "type": "string",
            "description": "Alias of `source`."
          },
          "sample": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "TemplateUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "template": {
            "type": "string",
            "description": "Alias of `source`."
          },
          "sample": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Usage": {
        "type": "object",
        "required": [
          "plan",
          "used",
          "limit"
        ],
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "starter",
              "pro",
              "scale"
            ]
          },
          "used": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad input (invalid JSON, unknown format, missing source, template error, and similar).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Not allowed (starter templates are read-only, or the 50-template limit was reached).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Unknown template or path.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "Template id already exists or conflicts with a starter template.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "QuotaExceeded": {
        "description": "Monthly document quota exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Error"
                },
                {
                  "type": "object",
                  "properties": {
                    "used": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "upgrade": {
                      "type": "string"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "TooLarge": {
        "description": "Request body or template source is too large (JSON body max 2 MB; template source max 262,144 bytes; playground body max 32 KB).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "MethodNotAllowed": {
        "description": "HTTP method is not allowed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RendererFailed": {
        "description": "The renderer did not return a PDF. Nothing was counted toward quota.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Timeout": {
        "description": "Render timed out (20 seconds). Nothing was counted toward quota.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyHeader": []
    }
  ],
  "externalDocs": {
    "description": "Human-readable API and MCP docs",
    "url": "https://getpdf.dev/docs.html"
  }
}
