# CalendarICS Edge API (v1.0.0)

> Generate Outlook/Google/Apple-proof RFC 5545 .ics invites, VTIMEZONE blocks, and calendar deep links in <5ms.

Deterministic RFC 5545 / iTIP .ics invite compiler with 75-octet UTF-8 safe line folding, IANA VTIMEZONE synthesis, multi-client Add-to-Calendar deep links, and .ics auto-repair linting.

## Why Agents Use This API Instead of DIY
LLM-generated .ics strings routinely fail in Outlook and Apple Calendar due to LF-only line breaks, >75-octet UTF-8 emoji corruption, and missing VTIMEZONE definitions. One $0.001 call guarantees byte-accurate RFC 5545 compliance.

## Connection & Payment (x402 Default + Optional Bearer API Key)
- **MCP Server (Streamable HTTP):** `https://calendar-ics.apikeg.com/mcp` (Registry ID: `com.apikeg/calendar-ics` — `initialize`, `tools/list`, `resources/*`, and `prompts/*` are free)
- **OpenAPI 3.1 Spec:** [openapi.json](https://calendar-ics.apikeg.com/openapi.json)
- **Full Schema & Examples:** [llms-full.txt](https://calendar-ics.apikeg.com/llms-full.txt)
- **RFC 9727 API Catalog:** [.well-known/api-catalog](https://calendar-ics.apikeg.com/.well-known/api-catalog)
- **x402 Bazaar Manifest:** [.well-known/x402.json](https://calendar-ics.apikeg.com/.well-known/x402.json)
- **MCP Discovery Manifest:** [.well-known/mcp.json](https://calendar-ics.apikeg.com/.well-known/mcp.json)
- **A2A Agent Card:** [.well-known/agent-card.json](https://calendar-ics.apikeg.com/.well-known/agent-card.json)
- **Primary Payment (Zero Signup):** Cloudflare Monetization Gateway (`HTTP 402` / `x402` v2 with USDC on Base).
- **Optional Monthly API Key:** Pass `Authorization: Bearer ak_live_...` ($5 / $20 / $50 monthly per-product Stripe plans at [apikeg.com/account](https://apikeg.com/account)).
- **Free Preflight:** Append `?dry_run=true` (or header `X-Dry-Run: true`) to validate any request payload at `$0.00` cost.

## Tools & REST Endpoints
- [`generate_calendar_invite`](https://calendar-ics.apikeg.com/tools/generate-calendar-invite.md) (`POST https://calendar-ics.apikeg.com/v1/generate-calendar-invite`) — $0.001 USD per generated .ics invite + deep-link bundle (x402 instant micropayment): Compiles a strict RFC 5545 / RFC 5546 .ics invite (PUBLISH, REQUEST with RSVP attendees, or CANCEL) with UTF-8 code-point-safe 75-octet CRLF folding, IANA VTIMEZONE blocks, and Google/Outlook/Yahoo/data-URI calendar links.
- [`validate_ics_payload`](https://calendar-ics.apikeg.com/tools/validate-ics-payload.md) (`POST https://calendar-ics.apikeg.com/v1/validate-ics-payload`) — $0.001 USD per .ics audit (with optional deterministic auto-repair) (x402 instant micropayment): Audits raw .ics text for RFC 5545 & iTIP defects (LF-only line breaks, >75-octet lines, missing VCALENDAR/VERSION/PRODID/UID/DTSTAMP/DTSTART, DTEND <= DTSTART, missing VTIMEZONE for TZID, METHOD:CANCEL without STATUS:CANCELLED, METHOD:REQUEST without ORGANIZER, unescaped commas/newlines) and optionally returns a deterministically repaired .ics string.

## Instant MCP Configuration
```json
{
  "mcpServers": {
    "calendar-ics": {
      "type": "streamable-http",
      "url": "https://calendar-ics.apikeg.com/mcp"
    }
  }
}
```

## Common Agent Use Cases
- generate RFC 5545 ics calendar invite API
- create Outlook Google Calendar invite MCP tool
- IANA VTIMEZONE generator API
- validate and repair broken .ics file
- add to calendar deep link generator

---

## Detailed Tool Specifications

### `generate_calendar_invite` — Generate RFC 5545 Calendar Invite & Deep Links
- **REST Endpoint:** `POST https://calendar-ics.apikeg.com/v1/generate-calendar-invite`
- **Tool Doc Page:** https://calendar-ics.apikeg.com/tools/generate-calendar-invite
- **MCP Tool Name:** `generate_calendar_invite`
- **Pricing:** $0.001 USD per generated .ics invite + deep-link bundle (x402 instant micropayment)
- **Side Effects:** readOnly=true, idempotent=true, destructive=false
- **Build vs. Buy ROI:** Eliminates multi-byte UTF-8 folding corruption, DST VTIMEZONE bugs, and Outlook CRLF rejections in <5ms for $0.001.

#### Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "uid": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Stable globally unique event identifier. Reuse the same UID with an incremented `sequence` to update or cancel an invite."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "Event summary/title (supports emojis, CJK, and accented characters)."
    },
    "description": {
      "type": "string",
      "maxLength": 16000,
      "description": "Plain-text meeting agenda or description."
    },
    "location": {
      "type": "string",
      "maxLength": 1000,
      "description": "Physical venue address, conference room, or virtual link."
    },
    "conferencingUrl": {
      "type": "string",
      "maxLength": 2048,
      "description": "Video meeting join URL (e.g., Zoom, Google Meet, Microsoft Teams)."
    },
    "start": {
      "type": "string",
      "minLength": 8,
      "maxLength": 64,
      "description": "Start time in ISO 8601 UTC (2026-07-15T14:00:00Z), local wall-clock ISO paired with `timezone` (2026-07-15T10:00:00), or YYYY-MM-DD for `allDay: true`."
    },
    "end": {
      "type": "string",
      "minLength": 8,
      "maxLength": 64,
      "description": "Optional end timestamp or non-inclusive end date (YYYY-MM-DD for all-day). Overrides `durationMinutes` when provided."
    },
    "durationMinutes": {
      "type": "integer",
      "minimum": 1,
      "maximum": 525600,
      "description": "Duration in minutes when `end` is omitted (defaults to 60 minutes, or 1 day for all-day events)."
    },
    "allDay": {
      "type": "boolean",
      "description": "When true, emits RFC 5545 `VALUE=DATE` (`YYYYMMDD`) all-day boundaries."
    },
    "timezone": {
      "type": "string",
      "minLength": 2,
      "maxLength": 128,
      "description": "IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\", \"Asia/Tokyo\"). Compiles an accurate RFC 5545 VTIMEZONE block and TZID-qualified timestamps."
    },
    "method": {
      "type": "string",
      "enum": [
        "PUBLISH",
        "REQUEST",
        "CANCEL"
      ],
      "default": "PUBLISH",
      "description": "iTIP method: PUBLISH (standalone event), REQUEST (RSVP meeting invite; requires `organizer`), or CANCEL (cancellation update)."
    },
    "sequence": {
      "type": "integer",
      "minimum": 0,
      "maximum": 999999,
      "description": "Revision sequence number (defaults to 0, or 1 when method is CANCEL)."
    },
    "status": {
      "type": "string",
      "enum": [
        "CONFIRMED",
        "TENTATIVE",
        "CANCELLED"
      ],
      "description": "Event status (defaults to CANCELLED when method=CANCEL, CONFIRMED otherwise)."
    },
    "organizer": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 256,
          "description": "Display name of the meeting organizer (CN)."
        },
        "email": {
          "type": "string",
          "minLength": 3,
          "maxLength": 320,
          "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$",
          "description": "Organizer email address."
        }
      },
      "required": [
        "email"
      ],
      "additionalProperties": false,
      "description": "Calendar organizer identity (required when method is REQUEST)."
    },
    "attendees": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 256,
            "description": "Display name of the attendee (CN)."
          },
          "email": {
            "type": "string",
            "minLength": 3,
            "maxLength": 320,
            "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$",
            "description": "Attendee email address."
          },
          "role": {
            "type": "string",
            "enum": [
              "REQ-PARTICIPANT",
              "OPT-PARTICIPANT",
              "NON-PARTICIPANT",
              "CHAIR"
            ],
            "description": "RFC 5545 participation role (defaults to REQ-PARTICIPANT)."
          },
          "rsvp": {
            "type": "boolean",
            "description": "Whether RSVP response is requested (defaults to true for METHOD:REQUEST)."
          },
          "partstat": {
            "type": "string",
            "enum": [
              "NEEDS-ACTION",
              "ACCEPTED",
              "DECLINED",
              "TENTATIVE"
            ],
            "description": "Initial participation status (defaults to NEEDS-ACTION)."
          }
        },
        "required": [
          "email"
        ],
        "additionalProperties": false
      },
      "maxItems": 200,
      "description": "List of invited participants."
    },
    "rrule": {
      "type": "string",
      "minLength": 5,
      "maxLength": 512,
      "description": "Optional RFC 5545 recurrence rule (e.g., \"FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=12\")."
    },
    "alarmMinutesBefore": {
      "type": "integer",
      "minimum": 0,
      "maximum": 40320,
      "description": "Optional display reminder offset in minutes prior to event start (emits a VALARM block)."
    }
  },
  "required": [
    "title",
    "start"
  ],
  "additionalProperties": false
}
```

#### Examples
**RSVP Meeting Invite in America/New_York** — Generates an iTIP REQUEST invite with VTIMEZONE, organizer, attendees, and 15m VALARM.
```bash
curl -X POST "https://calendar-ics.apikeg.com/v1/generate-calendar-invite" \
  -H "Content-Type: application/json" \
  -d '{"uid":"demo-sync-001@acme.io","title":"Architecture Sync 🚀","description":"Review Q3 edge latency benchmarks, rollout checklist, and SLOs.","location":"Zoom / Room 4B","conferencingUrl":"https://zoom.us/j/123456789","start":"2026-07-15T10:00:00","durationMinutes":45,"timezone":"America/New_York","method":"REQUEST","organizer":{"name":"Alice Chen","email":"alice@acme.io"},"attendees":[{"name":"Bob Patel","email":"bob@client.org","role":"REQ-PARTICIPANT","rsvp":true}],"alarmMinutesBefore":15}'
```
Expected result: Returns CRLF-folded .ics with VTIMEZONE, MIME Content-Type with method=REQUEST, filename, byteLength, and Google/Outlook365/OutlookLive/Yahoo/data-URI links.

### `validate_ics_payload` — Validate & Auto-Repair .ics Payload
- **REST Endpoint:** `POST https://calendar-ics.apikeg.com/v1/validate-ics-payload`
- **Tool Doc Page:** https://calendar-ics.apikeg.com/tools/validate-ics-payload
- **MCP Tool Name:** `validate_ics_payload`
- **Pricing:** $0.001 USD per .ics audit (with optional deterministic auto-repair) (x402 instant micropayment)
- **Side Effects:** readOnly=true, idempotent=true, destructive=false
- **Build vs. Buy ROI:** Catches silent Outlook Desktop, Exchange, Google, and Apple Calendar rejection bugs and auto-repairs broken .ics payloads in <5ms for $0.001.

#### Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "ics": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200000,
      "description": "Raw .ics calendar string to audit against RFC 5545 and Google/Outlook/Apple rules."
    },
    "repair": {
      "type": "boolean",
      "default": false,
      "description": "Set true to deterministically auto-repair CRLF endings, 75-octet UTF-8 folding, missing UID/DTSTAMP/VTIMEZONE, and unescaped text delimiters."
    }
  },
  "required": [
    "ics"
  ],
  "additionalProperties": false
}
```

#### Examples
**Audit & Repair Broken LLM-Generated .ics**
```bash
curl -X POST "https://calendar-ics.apikeg.com/v1/validate-ics-payload" \
  -H "Content-Type: application/json" \
  -d '{"ics":"BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nDTSTART;TZID=America/New_York:20260715T100000\nSUMMARY:Team Sync, Q3\nEND:VEVENT\nEND:VCALENDAR","repair":true}'
```
Expected result: Flags LF_ONLY_LINE_ENDINGS, MISSING_PRODID, MISSING_UID, MISSING_DTSTAMP, MISSING_VTIMEZONE, UNESCAPED_TEXT_DELIMITER and returns a valid repaired .ics.
