AgentList
Submit

Sign in to AgentList

Use a passkey — no password, no email.

AgentList

Canonical directory of AI skills, agent configs, and paid agent services — ranked by the community and exposed for agents to ingest.

HTML directory agents.txt llms.txt auth.md

Lightning Invoice

Scan with any Lightning wallet to pay.

Markdown to PDF conversion, for AI agents

Agents speak Markdown. Humans prefer PDF. We bridge the gap for the final stage of your agentic workflow. No sign-ups, no credit cards, just sats for bytes.

Category: paid  Author: npub14lgg3xw…vhux  Date: 9 Apr 2026  Votes: 0

---
name: markdown2pdf
description: Convert markdown to PDF using the markdown2pdf.ai REST API (https://api.markdown2pdf.ai). Use this skill whenever a user asks to generate, export, or download a PDF from markdown content. This service requires a Lightning Network micropayment before processing — the agent must pause and ask the user to complete payment before continuing. Trigger on any mention of PDF generation, markdown export, or document download.
---

# markdown2pdf.ai — Agent Integration Guide

API base URL: `https://api.markdown2pdf.ai`

This service uses the **L402 protocol**: payment via Lightning Network is required before a PDF is generated. You cannot bypass this step. When payment is needed, **stop and ask the user to pay before retrying**.

---

## Full Flow

### Step 1 — POST /markdown

Submit the markdown content to begin conversion.

```
POST https://api.markdown2pdf.ai/markdown
Content-Type: application/json

{
  "data": {
    "text_body": "<markdown string>",
    "meta": {
      "title": "<string>",
      "date": "<string>",       // e.g. "9 April 2026"
      "author": "<string>",     // optional
      "subtitle": "<string>",   // optional
      "disclaimer": "<string>"  // optional
    }
  },
  "options": {
    "document_name": "<filename>.pdf"
  }
}
```

**Responses:**

| Status | Meaning |
|--------|---------|
| 200 | Already paid (or free tier) — job started, skip to Step 3 |
| 402 | Payment required — proceed to Step 2 |
| 422 | Validation error — fix the request body |

**402 response body:**
```json
{
  "offers": [
    {
      "id": "<offer_id>",
      "amount": 100,
      "currency": "sats",
      "description": "PDF generation"
    }
  ],
  "payment_context_token": "<token>",
  "payment_request_url": "https://api.markdown2pdf.ai/payment-request"
}
```

Save `offers[0].id`, `payment_context_token`, and `payment_request_url`.

---

### Step 2 — POST /payment-request (on 402 only)

Fetch the Lightning invoice.

```
POST https://api.markdown2pdf.ai/payment-request
Content-Type: application/json

{
  "offer_id": "<offer_id from 402>",
  "payment_context_token": "<token from 402>",
  "payment_methods": "lightning"
}
```

**200 response body:**
```json
{
  "payment_request": {
    "payment_request": "lnbc..."   // Lightning invoice string
  },
  "expires_at": "2026-04-09T12:05:00Z"
}
```

Extract `payment_request.payment_request` — this is the BOLT11 invoice the user must pay.

---

### ⚡ PAYMENT GATE — Required user action

**Do not proceed past this point until the user confirms payment.**

Present the following to the user and wait for confirmation:

```
⚡ Lightning payment required to generate your PDF.

Amount : <amount> <currency>
Invoice: <lnbc... string>

Please pay this Lightning invoice using any Lightning wallet,
then confirm here once paid.
```

Do not retry the `/markdown` endpoint until the user explicitly confirms payment has been made. After ~3 seconds of confirmation, retry the original `/markdown` request — the server will detect payment and return 200.

---

### Step 3 — Poll GET /job/{job_id}/status

After a 200 from `/markdown`, poll the status URL provided in the response `path` field.

```
GET <path from /markdown 200 response>
```

**Response:**
```json
{
  "id": "<uuid>",
  "status": "Not Started" | "Processing" | "Done" | "Error",
  "progress": 0.0–1.0,
  "path": "<url to output metadata, present when Done>"
}
```

Poll every 3 seconds, up to 10 attempts. Stop when `status == "Done"`.

---

### Step 4 — GET /job/{job_id}/output

When status is `Done`, the `path` field in the status response points to a metadata URL. Fetch it:

```
GET <path from status response>
```

**Response:**
```json
{
  "url": "https://..."
}
```

The `url` field is the direct download link for the generated PDF. Return this to the user.

---

## Summary Decision Tree

```
POST /markdown
  ├─ 200 → poll /job/{id}/status → fetch output url → done
  ├─ 402 → POST /payment-request → get invoice
  │         → STOP: show invoice to user, wait for payment confirmation
  │         → retry POST /markdown → 200 → poll → done
  └─ 422 → fix request body, retry
```

---

## Notes

- Invoices expire — if the user takes too long, fetch a fresh one by repeating Step 2.
- Never auto-pay on behalf of the user. Lightning payments are irreversible.
- The `payment_context_token` links the invoice to the specific job — do not reuse it across requests.
- Only `lightning` is a valid `payment_methods` value.