openapi: 3.0.3

info:
title: Page2Doc API
version: 1.0.0
description: Converts public webpages into downloadable documents. Supports PDF, DOCX, XLSX, CSV, JSON, HTML, and Markdown.

servers:
- url: https://page2doc.com

security:
- ApiKeyAuth: []

paths:

/api/chatgpt/convert:
post:
operationId: createConversion
summary: Submit a URL for conversion
description: Submit a public URL and output format to start a conversion job. Poll getConversionStatus with the returned jobId until status is completed or failed.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ConvertRequest'
example:
url: https://en.wikipedia.org/wiki/Artificial_intelligence
format: pdf
responses:
'202':
description: Job accepted and queued.
content:
application/json:
schema:
$ref: '#/components/schemas/ConversionResponse'
example:
jobId: job_7f3a1c9e2b
status: queued
'400':
description: Invalid request.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'429':
description: Daily limit reached or rate limited.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'

/api/chatgpt/jobs/{jobId}:
get:
operationId: getConversionStatus
summary: Get conversion job status
description: Returns the current status of a conversion job. When status is completed, downloadUrl is present. Poll every few seconds until status is completed or failed.
parameters:
- name: jobId
in: path
required: true
description: Job identifier returned by createConversion.
schema:
type: string
example: job_7f3a1c9e2b
responses:
'200':
description: Current job status.
content:
application/json:
schema:
$ref: '#/components/schemas/JobStatusResponse'
example:
jobId: job_7f3a1c9e2b
status: completed
downloadUrl: https://cdn.page2doc.com/files/job_7f3a1c9e2b/output.pdf
'401':
description: Unauthorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Job not found.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'

/api/chatgpt/formats:
get:
operationId: getFormats
summary: List supported output formats
description: Returns the list of supported output formats and their availability by plan.
responses:
'200':
description: List of supported formats.
content:
application/json:
schema:
type: object
properties:
formats:
type: array
items:
type: string
example:
formats:
- pdf
- docx
- xlsx
- csv
- json
- html
- markdown
'500':
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'

/api/chatgpt/account:
get:
operationId: getAccount
summary: Get account status and usage
description: Returns the current plan, daily conversion limit, and remaining conversions for today.
responses:
'200':
description: Account status.
content:
application/json:
schema:
$ref: '#/components/schemas/AccountResponse'
example:
plan: free
remainingToday: 2
dailyLimit: 3
'401':
description: Unauthorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'

components:

securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: Authorization

schemas:

ConvertRequest:
type: object
required:
- url
- format
properties:
url:
type: string
description: Public HTTPS URL of the webpage to convert.
example: https://en.wikipedia.org/wiki/Artificial_intelligence
format:
type: string
description: Output document format.
enum:
- pdf
- docx
- xlsx
- csv
- json
- html
- markdown
example: pdf

ConversionResponse:
type: object
properties:
jobId:
type: string
description: Unique job identifier. Use this to poll getConversionStatus.
example: job_7f3a1c9e2b
status:
type: string
description: Initial job status.
enum:
- queued
- processing
example: queued

JobStatusResponse:
type: object
properties:
jobId:
type: string
description: Unique job identifier.
example: job_7f3a1c9e2b
status:
type: string
description: Current job status. Poll until completed or failed.
enum:
- queued
- processing
- completed
- failed
example: completed
downloadUrl:
type: string
description: Download URL. Present only when status is completed.
example: https://cdn.page2doc.com/files/job_7f3a1c9e2b/output.pdf

AccountResponse:
type: object
properties:
plan:
type: string
description: Current subscription plan.
example: free
remainingToday:
type: integer
description: Conversions remaining today.
example: 2
dailyLimit:
type: integer
description: Maximum conversions allowed per day on the current plan.
example: 3

ErrorResponse:
type: object
properties:
error:
type: string
description: Machine-readable error category.
example: bad_request
message:
type: string
description: Human-readable error description.
example: url is required