{
  "openapi": "3.0.1",
  "info": {
    "title": "markdown2pdf",
    "version": "2025-06-10T15:55:31Z"
  },
  "servers": [
    {
      "url": "https://api.markdown2pdf.ai"
    }
  ],
  "paths": {
    "/payment-request": {
      "post": {
        "summary": "Get payment details for generation.",
        "description": "Get payment details for generation. This will include a lightning invoice, and follows the L402 standard for payment requests.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobPaymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "If the request body is invalid or missing required fields.",
            "content": {}
          },
          "404": {
            "description": "If the payment request cannot be found or is invalid.",
            "content": {}
          },
          "200": {
            "description": "Payment request details including offer ID, payment request, and QR code SVG.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobPaymentRequestResponse"
                }
              }
            }
          }
        }
      }
    },
    "/job/{job_id}/output": {
      "get": {
        "summary": "Get Document Output",
        "description": "Retrieve the output of a document generation job. This endpoint provides the final output of the document generation process, which may include a URL to download the generated document.",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "404": {
            "description": "The provided job_id was not found or the user does not have access to the job.",
            "content": {}
          },
          "200": {
            "description": "The output of the document generation job, which may include a URL to download the generated document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentGenerationJobOutput"
                }
              }
            }
          }
        }
      }
    },
    "/markdown": {
      "post": {
        "summary": "Generate a PDF document from Markdown input",
        "description": "This endpoint allows you to generate a PDF document from Markdown input. It requires payment before processing the request. The request body should include the Markdown content and metadata.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/L402DocumentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "200": {
            "description": "Once paid, a 200 OK response will be returned with the job status, and details on how to poll for updates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatus"
                }
              }
            }
          },
          "402": {
            "description": "Payment required to generate the document. The response will include a request for payment, with details on how to fetch the invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobPaymentRequiredStatus"
                }
              }
            }
          }
        }
      }
    },
    "/job/{job_id}/status": {
      "get": {
        "summary": "Poll document generation job status",
        "description": "Poll the status of a document generation job. This endpoint allows you to check the current status of a job using its job ID. It will return the job status, including progress and any associated metadata.",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "404": {
            "description": "The provided job_id was not found or the user does not have access to the job.",
            "content": {}
          },
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatus"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Status": {
        "title": "Status",
        "type": "string",
        "enum": [
          "Not Started",
          "Processing",
          "Done",
          "Error"
        ]
      },
      "L402DocumentRequest": {
        "title": "L402DocumentRequest",
        "required": [
          "data",
          "options"
        ],
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/GeneralDocumentRequestData"
          },
          "options": {
            "$ref": "#/components/schemas/L402DocumentRequestOptions"
          }
        }
      },
      "GeneralDocumentRequestData": {
        "title": "GeneralDocumentRequestData",
        "required": [
          "text_body"
        ],
        "type": "object",
        "properties": {
          "text_body": {
            "title": "Text Body",
            "type": "string"
          },
          "meta": {
            "$ref": "#/components/schemas/GeneralDocumentRequestDataMeta"
          }
        }
      },
      "DocumentGenerationJobOutput": {
        "title": "DocumentGenerationJobOutput",
        "type": "object",
        "properties": {
          "url": {
            "title": "Url",
            "type": "string",
            "nullable": true
          }
        }
      },
      "JobPaymentRequestResponse": {
        "title": "JobPaymentRequestResponse",
        "required": [
          "payment_request"
        ],
        "type": "object",
        "properties": {
          "version": {
            "title": "Version",
            "type": "string",
            "description": "Version of the payment request response schema"
          },
          "payment_request": {
            "title": "Payment Request",
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Payment request details"
          },
          "expires_at": {
            "title": "Expires At",
            "description": "Expiration time for the payment request",
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "JobStatus": {
        "title": "JobStatus",
        "required": [
          "id",
          "status"
        ],
        "type": "object",
        "properties": {
          "id": {
            "title": "Id",
            "type": "string",
            "format": "uuid"
          },
          "description": {
            "title": "Description",
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/Status"
          },
          "status_meta": {
            "title": "Status Meta",
            "type": "string",
            "nullable": true
          },
          "progress": {
            "title": "Progress",
            "maximum": 1.0,
            "minimum": 0.0,
            "type": "number"
          },
          "path": {
            "title": "Path",
            "type": "string",
            "nullable": true
          }
        }
      },
      "GeneralDocumentRequestDataMeta": {
        "title": "GeneralDocumentRequestDataMeta",
        "type": "object",
        "properties": {
          "author": {
            "title": "Author",
            "description": "The author of the document which gets presented on the first page of the document. This may also be taken from the auth header if the authorization was issued by FWS.",
            "type": "string",
            "nullable": true
          },
          "title": {
            "title": "Title",
            "description": "The title of the document which gets presented on the first page of the document and in the footer. If not provided, the first #h1 header will be taken from the text_body field",
            "type": "string",
            "nullable": true
          },
          "subtitle": {
            "title": "Subtitle",
            "description": "The subtitle of the document which gets presented on the first page of the document",
            "type": "string",
            "nullable": true
          },
          "disclaimer": {
            "title": "Disclaimer",
            "description": "The disclaimer text of the document.",
            "type": "string",
            "nullable": true
          },
          "date": {
            "title": "Date",
            "description": "The date of the document.",
            "type": "string",
            "nullable": true
          }
        }
      },
      "Empty": {
        "title": "Empty Schema",
        "type": "object"
      },
      "JobPaymentRequest": {
        "title": "JobPaymentRequest",
        "required": [
          "offer_id",
          "payment_context_token"
        ],
        "type": "object",
        "properties": {
          "offer_id": {
            "title": "Offer Id",
            "type": "string",
            "description": "Unique identifier for the payment offer"
          },
          "payment_methods": {
            "title": "Payment Methods",
            "description": "Payment method to be used",
            "type": "string",
            "nullable": true
          },
          "payment_context_token": {
            "title": "Payment Context Token",
            "type": "string",
            "description": "Token to identify the payment context"
          }
        }
      },
      "L402DocumentRequestOptions": {
        "title": "L402DocumentRequestOptions",
        "type": "object",
        "properties": {
          "document_name": {
            "title": "Document Name",
            "type": "string",
            "nullable": true
          }
        }
      },
      "Offer": {
        "title": "Offer",
        "required": [
          "id"
        ],
        "type": "object",
        "properties": {
          "id": {
            "title": "Id",
            "type": "string"
          },
          "title": {
            "title": "Title",
            "type": "string"
          },
          "description": {
            "title": "Description",
            "type": "string"
          },
          "amount": {
            "title": "Amount",
            "type": "integer",
            "format": "int32"
          },
          "currency": {
            "title": "Currency",
            "type": "string"
          },
          "payment_methods": {
            "title": "Payment Methods",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "type": {
            "title": "Type",
            "type": "string",
            "nullable": true
          }
        }
      },
      "HTTPValidationError": {
        "title": "HTTPValidationError",
        "type": "object",
        "properties": {
          "detail": {
            "title": "Detail",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            }
          }
        }
      },
      "ValidationError": {
        "title": "ValidationError",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "type": "object",
        "properties": {
          "loc": {
            "title": "Location",
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer",
                  "format": "int32"
                }
              ]
            }
          },
          "msg": {
            "title": "Message",
            "type": "string"
          },
          "type": {
            "title": "Error Type",
            "type": "string"
          }
        }
      },
      "JobPaymentRequiredStatus": {
        "title": "JobPaymentRequiredStatus",
        "required": [
          "offers",
          "payment_context_token",
          "payment_request_url",
          "version"
        ],
        "type": "object",
        "properties": {
          "version": {
            "title": "Version",
            "type": "string"
          },
          "payment_request_url": {
            "title": "Payment Request Url",
            "type": "string"
          },
          "payment_context_token": {
            "title": "Payment Context Token",
            "type": "string"
          },
          "offers": {
            "title": "Offers",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Offer"
            }
          },
          "terms_url": {
            "title": "Terms Url",
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "title": "Metadata",
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true
          }
        }
      }
    }
  }
}