---
title: "Utility & Edge AI Tools API"
description: "Reference specifications for QR code generation, web page markdown conversion, bulk import/export, and Cloudflare Workers AI inference."
---

> Documentation Index
> Fetch the complete documentation index at: https://shaf.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Utility & Edge AI Tools API

# Utility & Edge AI Tools API

The Tools API exposes specialized edge utilities: high-performance QR code rendering, automated markdown extraction, asynchronous bulk link imports/exports, and zero-latency AI metadata optimization.

---

## 1. QR Code Generation

Generate scannable vector SVG or PNG QR codes with customizable error correction and payload formats.

**POST** `/api/v1/tools/qr`

### Request Body Parameters

| Field | Type | Required | Description |
| :--- | :--- | :---: | :--- |
| `type` | `string` | **Yes** | Payload format: `'url'`, `'text'`, `'wifi'`, `'vcard'`, or `'email'`. |
| `content` | `string \| object` | **Yes** | Payload content. For `'url'` or `'text'`, pass a string. For specialized types, pass an options object. |
| `size` | `integer` | No | Dimension in pixels (min: 64, max: 1024, default: 246). |
| `ecc` | `string` | No | Error correction level: `'L'` (~7%), `'M'` (~15%, default), `'Q'` (~25%), `'H'` (~30%). |
| `format` | `string` | No | Render format: `'svg'` (default) or `'png'`. |

### Specialized Payload Formats

### Wi-Fi Network

```json
{
  "type": "wifi",
  "content": {
    "ssid": "Office-Guest",
    "password": "SecretPassword123",
    "encryption": "WPA",
    "hidden": false
  }
}
```

### Contact vCard

```json
{
  "type": "vcard",
  "content": {
    "firstName": "Sarah",
    "lastName": "Connor",
    "organization": "Cyberdyne Systems",
    "title": "Head of Security",
    "phone": "+1-555-0199",
    "email": "sarah@cyberdyne.com",
    "url": "https://shaf.is/sarah"
  }
}
```

### Direct Short Link

```json
{
  "type": "url",
  "content": "https://shaf.is/summer-promo",
  "size": 320,
  "ecc": "H",
  "format": "svg"
}
```

### Response (HTTP 200 OK)

```json
{
  "code": 0,
  "data": {
    "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 320\">...</svg>",
    "size": 320,
    "ecc": "H"
  }
}
```

---

## 2. Web Page Markdown Extractor

Scrapes a destination web page, eliminates navigation chrome, and produces clean markdown with estimated reading and token metrics for LLM ingestion.

**POST** `/api/v1/tools/markdown` (or **GET** `/api/v1/tools/markdown?url=...`)

### Request Body Parameters

Validated against `MarkdownToolRequestSchema` in `shared/schemas/tools.ts`.

| Field | Type | Default | Description |
| :--- | :--- | :---: | :--- |
| `url` | `string` | **Required** | Target HTTP/HTTPS URL to scrape and parse. |
| `includeFrontmatter` | `boolean` | `true` | Include YAML frontmatter containing title, description, and source URL. |
| `stripImages` | `boolean` | `false` | Remove image tags from rendered markdown. |
| `stripLinks` | `boolean` | `false` | Remove hyperlink wrappers from rendered markdown. |
| `mainContentOnly` | `boolean` | `true` | Exclude navigation headers, footers, and advertisement sidebars. |

### Response Example (HTTP 200 OK)

```json
{
  "code": 0,
  "data": {
    "url": "https://stripe.com/docs/billing",
    "title": "Stripe Billing Overview",
    "description": "Learn how recurring billing and subscriptions work.",
    "markdown": "# Stripe Billing Overview\n\nStripe Billing lets you bill and manage customers...",
    "renderedHtml": "<h1>Stripe Billing Overview</h1><p>...</p>",
    "stats": {
      "words": 842,
      "characters": 5420,
      "readingTimeMinutes": 4.2,
      "estimatedTokens": 1150
    },
    "scrapedAt": "2026-11-21T18:00:00.000Z"
  }
}
```

---

## 3. Bulk Link Import

Import up to 1,000 links in a single atomic transaction.

**POST** `/api/v1/tools/bulk-import` (or **POST** `/api/link/import`)

### Request Body Parameters

Validated against `ImportDataSchema` in `shared/schemas/import.ts`.

```json
{
  "version": "1.0",
  "links": [
    {
      "url": "https://example.com/page-1",
      "slug": "promo-01",
      "tags": ["batch-import"]
    },
    {
      "url": "https://example.com/page-2",
      "slug": "promo-02",
      "tags": ["batch-import"]
    }
  ]
}
```

### Response Example (HTTP 200 OK)

Returns structured `ImportResult` tracking successful and rejected entries:

```json
{
  "code": 0,
  "data": {
    "success": 2,
    "skipped": 0,
    "failed": 0,
    "successItems": [
      {
        "index": 0,
        "slug": "promo-01",
        "url": "https://example.com/page-1"
      },
      {
        "index": 1,
        "slug": "promo-02",
        "url": "https://example.com/page-2"
      }
    ],
    "skippedItems": [],
    "failedItems": []
  }
}
```

---

## 4. Bulk Link Export

Export all links registered to the active organization with pagination cursor support. Requires the `csvExport` feature capability.

**GET** `/api/v1/tools/export` (or **GET** `/api/link/export`)

### Query Parameters

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `cursor` | `string` | Opaque cursor token from previous response for sequential batch traversal. |
| `organizationId` | `string` | Optional workspace ID override when using an administrative service token. |

### Response Example (HTTP 200 OK)

Returns schema adhering to `ExportData` in `shared/schemas/link.ts`:

```json
{
  "version": "1.0",
  "exportedAt": "2026-11-21T18:00:00.000Z",
  "count": 50,
  "links": [
    {
      "id": "lnk_98fa01",
      "slug": "launch-event",
      "url": "https://brand.com/event",
      "createdAt": 1774180000,
      "updatedAt": 1774180000
    }
  ],
  "cursor": "eyJzbHVnIjoibGF1bmNoLWV2ZW50In0=",
  "list_complete": true
}
```

---

## 5. Cloudflare Workers AI Slug Recommendation

Analyzes destination page semantic content using Cloudflare Workers AI to recommend human-readable, brand-appropriate slugs.

**POST** `/api/v1/tools/ai-slug`

### Request Body

```json
{
  "url": "https://stripe.com/docs/billing/subscriptions/overview"
}
```

### Response Example (HTTP 200 OK)

```json
{
  "code": 0,
  "data": {
    "slug": "stripe-billing-subscriptions"
  }
}
```

---

## 6. Cloudflare Workers AI OpenGraph Card Extraction

Scrapes destination page markup and automatically crafts optimized title and description meta attributes for social media card previews.

**POST** `/api/v1/tools/ai-og`

### Request Body

```json
{
  "url": "https://acme.com/engineering/edge-routing"
}
```

### Response Example (HTTP 200 OK)

```json
{
  "code": 0,
  "data": {
    "title": "Edge-Native Link Infrastructure on Cloudflare Workers",
    "description": "Discover how sub-10ms Anycast routing and distributed D1/KV caching eliminate redirect latency globally."
  }
}
```

Source: https://shaf.app/docs/reference/rest-api/tools/index.mdx
