{
  "openapi": "3.1.0",
  "info": {
    "title": "x402 Parse Service",
    "version": "1.0.0",
    "description": "Multi-format document to non-PII structure extraction for AI agents. Pay USDC via x402. Raw content never stored."
  },
  "servers": [
    {
      "url": "https://parseapi.info"
    }
  ],
  "paths": {
    "/parse": {
      "post": {
        "summary": "Parse file bytes into structure JSON",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed structure",
            "content": {
              "application/json": {
                "examples": {
                  "pdf": {
                    "value": {
                      "ok": true,
                      "format": "pdf",
                      "doc_kind": "invoice_like",
                      "fields": [
                        "currency",
                        "invoice_terms",
                        "totals",
                        "dates"
                      ],
                      "tokens": 120,
                      "content": "Invoice #A-1042 Total: $1,250.00 Due: 2026-02-01",
                      "structure": {
                        "pages": 1,
                        "fields": [
                          "currency",
                          "totals",
                          "dates"
                        ]
                      },
                      "x402": {
                        "paid": true,
                        "format": "pdf",
                        "price": 0.001
                      }
                    }
                  },
                  "eml": {
                    "value": {
                      "ok": true,
                      "format": "eml",
                      "doc_kind": "invoice_like",
                      "fields": [
                        "currency",
                        "invoice_terms"
                      ],
                      "tokens": 19,
                      "content": "Hi Bob, please find attached the Q3 invoice totaling $1,250.00 due Feb 1.",
                      "structure": {
                        "subject": "Q3 invoice follow-up",
                        "from": "Alice <alice@example.com>",
                        "to": "Bob <bob@example.com>",
                        "cc": "Carol <carol@example.com>",
                        "date": "2026-10-06T09:12:00Z",
                        "messages": 2,
                        "attachments": []
                      },
                      "meta": {
                        "engine": "mailparser",
                        "has_attachments": false
                      },
                      "x402": {
                        "paid": true,
                        "format": "eml",
                        "price": 0.001
                      }
                    }
                  },
                  "audio": {
                    "value": {
                      "ok": true,
                      "format": "audio",
                      "doc_kind": "document_like",
                      "tokens": 9,
                      "content": "Your total for this billing period is one thousand two hundred fifty dollars.",
                      "structure": {
                        "segments": 8,
                        "duration": 143,
                        "timestamps": [
                          {
                            "start": 120,
                            "end": 122
                          }
                        ]
                      },
                      "meta": {
                        "engine": "faster-whisper",
                        "transcript": true
                      },
                      "x402": {
                        "paid": true,
                        "format": "audio",
                        "price": 0.015,
                        "duration_min": 3,
                        "duration_sec": 146
                      }
                    }
                  },
                  "video": {
                    "value": {
                      "ok": true,
                      "format": "video",
                      "doc_kind": "document_like",
                      "tokens": 6,
                      "content": "Welcome back to the quarterly earnings call.",
                      "structure": {
                        "segments": 1,
                        "duration": 38,
                        "timestamps": [
                          {
                            "start": 0,
                            "end": 38
                          }
                        ]
                      },
                      "meta": {
                        "engine": "faster-whisper",
                        "transcript": true
                      },
                      "x402": {
                        "paid": true,
                        "format": "video",
                        "price": 0.01,
                        "duration_min": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (x402). See the base64 PAYMENT-REQUIRED response header.",
            "content": {
              "application/json": {
                "examples": {
                  "payment_required": {
                    "value": {
                      "x402Version": 2,
                      "error": "Payment required",
                      "resource": {
                        "url": "https://parseapi.info/parse",
                        "description": "Parse document to structure"
                      },
                      "accepts": [
                        {
                          "scheme": "exact",
                          "network": "eip155:8453",
                          "amount": "1000",
                          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "payTo": "0x9952522E50C9cE639254939153595142b2024c2E",
                          "maxTimeoutSeconds": 300,
                          "extra": {
                            "name": "USDC",
                            "version": "2"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large (>200 MB)"
          },
          "422": {
            "description": "Parse failed or media undecodable"
          }
        }
      }
    },
    "/search": {
      "post": {
        "summary": "Parse file bytes and return top-5 similar stored structures",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked matches",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "matches": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (read tier $0.001)"
          }
        }
      }
    },
    "/memory": {
      "get": {
        "summary": "Recall the caller tenant last 20 stored structures",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "responses": {
          "200": {
            "description": "Items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "items": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (read tier $0.001)"
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Liveness + DB check",
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/parse/document": {
      "post": {
        "summary": "Parse a document (PDF, DOCX, PPTX, CSV/XLSX, HTML, EML, MSG, LOG) into token-compressed structure",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed structure",
            "content": {
              "application/json": {
                "examples": {
                  "document": {
                    "value": {
                      "ok": true,
                      "format": "pdf",
                      "doc_kind": "invoice_like",
                      "fields": [
                        "currency",
                        "invoice_terms",
                        "totals",
                        "dates"
                      ],
                      "tokens": 120,
                      "content": "Invoice #A-1042 Total: $1,250.00 Due: 2026-02-01",
                      "structure": {
                        "pages": 1,
                        "fields": [
                          "currency",
                          "totals",
                          "dates"
                        ]
                      },
                      "x402": {
                        "paid": true,
                        "format": "pdf",
                        "price": 0.001
                      }
                    }
                  },
                  "email": {
                    "value": {
                      "ok": true,
                      "format": "eml",
                      "doc_kind": "invoice_like",
                      "fields": [
                        "currency",
                        "invoice_terms"
                      ],
                      "tokens": 19,
                      "content": "Hi Bob, please find attached the Q3 invoice totaling $1,250.00 due Feb 1.",
                      "structure": {
                        "subject": "Q3 invoice follow-up",
                        "from": "Alice <alice@example.com>",
                        "to": "Bob <bob@example.com>",
                        "cc": "Carol <carol@example.com>",
                        "date": "2026-10-06T09:12:00Z",
                        "messages": 2,
                        "attachments": []
                      },
                      "meta": {
                        "engine": "mailparser",
                        "has_attachments": false
                      },
                      "x402": {
                        "paid": true,
                        "format": "eml",
                        "price": 0.001
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (x402). See the base64 PAYMENT-REQUIRED response header.",
            "content": {
              "application/json": {
                "examples": {
                  "payment_required": {
                    "value": {
                      "x402Version": 2,
                      "error": "Payment required",
                      "resource": {
                        "url": "https://parseapi.info/parse",
                        "description": "Parse document to structure"
                      },
                      "accepts": [
                        {
                          "scheme": "exact",
                          "network": "eip155:8453",
                          "amount": "1000",
                          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "payTo": "0x9952522E50C9cE639254939153595142b2024c2E",
                          "maxTimeoutSeconds": 300,
                          "extra": {
                            "name": "USDC",
                            "version": "2"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large (>200 MB)"
          },
          "422": {
            "description": "Parse failed or media undecodable"
          }
        }
      }
    },
    "/parse/image": {
      "post": {
        "summary": "OCR an image into words, confidence, blocks and coordinates",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed structure",
            "content": {
              "application/json": {
                "examples": {
                  "ocr": {
                    "value": {
                      "ok": true,
                      "format": "image",
                      "doc_kind": "document_like",
                      "tokens": 128,
                      "content": "RECEIPT TOTAL $42.99 THANK YOU",
                      "structure": {
                        "words": 128,
                        "confidence": 0.82,
                        "blocks": 7,
                        "coordinates": [
                          {
                            "t": "RECEIPT",
                            "x": 40,
                            "y": 12
                          },
                          {
                            "t": "TOTAL",
                            "x": 40,
                            "y": 210
                          }
                        ]
                      },
                      "meta": {
                        "engine": "tesseract",
                        "ocr": true
                      },
                      "x402": {
                        "paid": true,
                        "format": "image",
                        "price": 0.002
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (x402). See the base64 PAYMENT-REQUIRED response header.",
            "content": {
              "application/json": {
                "examples": {
                  "payment_required": {
                    "value": {
                      "x402Version": 2,
                      "error": "Payment required",
                      "resource": {
                        "url": "https://parseapi.info/parse",
                        "description": "Parse document to structure"
                      },
                      "accepts": [
                        {
                          "scheme": "exact",
                          "network": "eip155:8453",
                          "amount": "1000",
                          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "payTo": "0x9952522E50C9cE639254939153595142b2024c2E",
                          "maxTimeoutSeconds": 300,
                          "extra": {
                            "name": "USDC",
                            "version": "2"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large (>200 MB)"
          },
          "422": {
            "description": "Parse failed or media undecodable"
          }
        }
      }
    },
    "/parse/audio": {
      "post": {
        "summary": "Transcribe an audio file into timestamped segments (priced per minute)",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed structure",
            "content": {
              "application/json": {
                "examples": {
                  "audio": {
                    "value": {
                      "ok": true,
                      "format": "audio",
                      "doc_kind": "document_like",
                      "tokens": 9,
                      "content": "Your total for this billing period is one thousand two hundred fifty dollars.",
                      "structure": {
                        "segments": 8,
                        "duration": 143,
                        "timestamps": [
                          {
                            "start": 120,
                            "end": 122
                          }
                        ]
                      },
                      "meta": {
                        "engine": "faster-whisper",
                        "transcript": true
                      },
                      "x402": {
                        "paid": true,
                        "format": "audio",
                        "price": 0.015,
                        "duration_min": 3,
                        "duration_sec": 146
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (x402). See the base64 PAYMENT-REQUIRED response header.",
            "content": {
              "application/json": {
                "examples": {
                  "payment_required": {
                    "value": {
                      "x402Version": 2,
                      "error": "Payment required",
                      "resource": {
                        "url": "https://parseapi.info/parse",
                        "description": "Parse document to structure"
                      },
                      "accepts": [
                        {
                          "scheme": "exact",
                          "network": "eip155:8453",
                          "amount": "1000",
                          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "payTo": "0x9952522E50C9cE639254939153595142b2024c2E",
                          "maxTimeoutSeconds": 300,
                          "extra": {
                            "name": "USDC",
                            "version": "2"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large (>200 MB)"
          },
          "422": {
            "description": "Parse failed or media undecodable"
          }
        }
      }
    },
    "/parse/video": {
      "post": {
        "summary": "Transcribe the audio track of a video into timestamped segments (priced per minute)",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed structure",
            "content": {
              "application/json": {
                "examples": {
                  "video": {
                    "value": {
                      "ok": true,
                      "format": "video",
                      "doc_kind": "document_like",
                      "tokens": 6,
                      "content": "Welcome back to the quarterly earnings call.",
                      "structure": {
                        "segments": 1,
                        "duration": 38,
                        "timestamps": [
                          {
                            "start": 0,
                            "end": 38
                          }
                        ]
                      },
                      "meta": {
                        "engine": "faster-whisper",
                        "transcript": true
                      },
                      "x402": {
                        "paid": true,
                        "format": "video",
                        "price": 0.01,
                        "duration_min": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (x402). See the base64 PAYMENT-REQUIRED response header.",
            "content": {
              "application/json": {
                "examples": {
                  "payment_required": {
                    "value": {
                      "x402Version": 2,
                      "error": "Payment required",
                      "resource": {
                        "url": "https://parseapi.info/parse",
                        "description": "Parse document to structure"
                      },
                      "accepts": [
                        {
                          "scheme": "exact",
                          "network": "eip155:8453",
                          "amount": "1000",
                          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "payTo": "0x9952522E50C9cE639254939153595142b2024c2E",
                          "maxTimeoutSeconds": 300,
                          "extra": {
                            "name": "USDC",
                            "version": "2"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large (>200 MB)"
          },
          "422": {
            "description": "Parse failed or media undecodable"
          }
        }
      }
    },
    "/parse/archive": {
      "post": {
        "summary": "Recursively parse a ZIP archive into a file inventory and structures",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Bearer <tenant_secret> - required for tenant isolation; without it you get an isolated ephemeral tenant that cannot see anyone else data"
          },
          {
            "name": "X-Filename",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "original filename, drives format detection (magic bytes are the fallback)"
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 payment proof (omit to receive a 402 challenge)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Parsed structure",
            "content": {
              "application/json": {
                "examples": {
                  "archive": {
                    "value": {
                      "ok": true,
                      "format": "zip",
                      "doc_kind": "document_like",
                      "tokens": 340,
                      "content": "Invoice #A-1042 Total: $1,250.00",
                      "structure": {
                        "files": 12,
                        "total_bytes": 20480,
                        "inventory": [
                          "invoice.pdf",
                          "data.csv",
                          "notes.txt"
                        ],
                        "parsed": [
                          "invoice.pdf",
                          "data.csv"
                        ]
                      },
                      "meta": {
                        "engine": "adm-zip",
                        "recursive": true
                      },
                      "x402": {
                        "paid": true,
                        "format": "zip",
                        "price": 0.002
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key"
          },
          "402": {
            "description": "Payment required (x402). See the base64 PAYMENT-REQUIRED response header.",
            "content": {
              "application/json": {
                "examples": {
                  "payment_required": {
                    "value": {
                      "x402Version": 2,
                      "error": "Payment required",
                      "resource": {
                        "url": "https://parseapi.info/parse",
                        "description": "Parse document to structure"
                      },
                      "accepts": [
                        {
                          "scheme": "exact",
                          "network": "eip155:8453",
                          "amount": "1000",
                          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                          "payTo": "0x9952522E50C9cE639254939153595142b2024c2E",
                          "maxTimeoutSeconds": 300,
                          "extra": {
                            "name": "USDC",
                            "version": "2"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large (>200 MB)"
          },
          "422": {
            "description": "Parse failed or media undecodable"
          }
        }
      }
    }
  }
}