# Islamify.ai Platform — Complete AI & Developer Reference (`v1.0.1`)

> Operated by non-profit EMAD gUG (haftungsbeschränkt), Munich, Germany.
> Portal: https://platform.islamify.ai | REST API: https://api.islamify.ai | MCP Server: https://mcp.islamify.ai/mcp

## 1. Quick Orientation for AI Agents & Developers

Islamify.ai provides verified Islamic primary sources and grounded educational answers through two unified interfaces sharing the exact same account, subscription allowance, free daily lookups, and prepaid Euro balance:
1. **Official Remote MCP Server:** `https://mcp.islamify.ai/mcp` (Streamable HTTP `2026-07-28` & `2025-11-25`, OAuth 2.1 with PKCE `S256`, CIMD, DCR `RFC 7591`, plus static API Key Bearer auth).
2. **REST API v1:** `https://api.islamify.ai/v1` (OpenAI-SDK compatible `/v1/chat/completions`, deterministic Qur'an/Mushaf/Hifz/Hadith/Quote endpoints, scholarly library search, and full AI self-service key/cost management).

### Billing Waterfall (Zero Surprise Bills)
1. **Free Daily Tier (0 €):** First 25 local calls/day across `/v1/quran/lookup`, `/v1/quran/mushaf`, `/v1/hadith/search`, `/v1/quotes/verify` (Stage 1), and `/v1/quran/hifz` (`deterministic_only: true`).
2. **Active Islamify.ai Chat Subscription (Sāʾil / Ṭālib / Muʿallim):** Automatically covers both MCP (ChatGPT, Google Gemini, Claude, Cursor) and personal API calls within the shared monthly allowance (strictly capped, zero overage risk). Keys for public third-party apps can set `allow_abo: false` to use Prepaid only.
3. **Prepaid Credits (Stripe & PayPal, €5–€250):** Seamlessly covers apps, organizations, and usage beyond the monthly subscription allowance. Stops cleanly at €0.00 (HTTP `402` on REST; JSON-RPC `200` with `isError: true` + `topup_url` on MCP).

### Pricing per Operation
| Operation | Endpoint / MCP Tool | Price |
|---|---|---|
| Qur'an Lookup (up to 8 Uthmani verses + translation) | `POST /v1/quran/lookup` / `islamify_quran_lookup` | 25/day free, then €0.002 (0.2 ct) |
| Medina Mushaf Page (1–604) & Quarter Split | `POST /v1/quran/mushaf` / `islamify_quran_mushaf` | 25/day free, then €0.002 (0.2 ct) |
| Hadith Search (10 classical collections) | `POST /v1/hadith/search` / `islamify_hadith_search` | 25/day free, then €0.002 (0.2 ct) |
| Quote Verification (Stage 1 / Deep Stage 2) | `POST /v1/quotes/verify` / `islamify_verify_quotes` | 25/day free (0.2 ct) / Deep €0.01 (1.0 ct) |
| Hifz & Mutashabihat Helper (Deterministic / 3-Card AI) | `POST /v1/quran/hifz` / `islamify_hifz_helper` | Deterministic free (0.2 ct) / AI Cards €0.08 (8.0 ct) |
| Scholarly Sources Search (4,900+ verified works) | `POST /v1/sources/search` / `islamify_scholarly_sources` | €0.03 (3.0 ct) |
| Working Translation of Arabic Excerpt | `POST /v1/sources/translate` / `islamify_translate_source` | €0.05 (5.0 ct) · Cached €0.01 (1.0 ct) |
| Fast Structured Islamify Chat | `POST /v1/chat/completions` (`model: "islamify-fast"`) | €0.04 (4.0 ct) |
| Full Verified Islamify Answer / Chat | `POST /v1/answer` & `/v1/chat/completions` (`model: "islamify-verified"`) | €0.12 (12.0 ct) |
| Account Status, Usage, Key Management & Top-up Links | `/v1/account`, `/v1/usage`, `/v1/keys`, `/v1/billing/topup` & MCP tools | €0.00 (Free) |

---

## 2. Authentication & Security Scopes

Send Bearer auth on every API or MCP request:
```http
Authorization: Bearer islm_live_...
```
- **Standard App Keys (`sources:read`, `answer:run`, `mcp:use`):** Safe to deploy inside backend apps. Cannot create, modify, or revoke other API keys (`403 Forbidden` on `/v1/keys`).
- **OAuth 2.1 Sessions & Management Keys (`+ keys:manage`):** Authorized AI assistants can manage keys, rename them, adjust spending limits, inspect live costs, and generate Stripe/PayPal top-up links.

---

## 3. REST API v1 — Complete Endpoint Reference

### A. OpenAI-SDK Drop-In Chat (`POST https://api.islamify.ai/v1/chat/completions`)
Drop Islamify.ai directly into any app using the official `openai` Python/TypeScript/Dart/Swift SDK by pointing `base_url` to `https://api.islamify.ai/v1`:
- `model`: `"islamify-verified"` (12 ct, scholarly sources + Mushaf auto-grounding + quote verification) or `"islamify-fast"` (4 ct, fast structured app responses + Mushaf auto-grounding).
- `messages`: Standard array of `{"role": "system"|"user"|"assistant", "content": "..."}`. Developer `system` instructions customize structure/UI formatting (e.g., Habit-Tracker JSON or study cards) while Islamify's core Sunni scholarly, copyright, and non-fatwa safeguards remain non-overridable.
- Automatic Medina Mushaf Grounding: Asking e.g. *"erste Seite Fussilat in vier Viertel"* automatically resolves Medina Mushaf Page 477 (`41:1–11`, split into 4 quarters) so the AI never hallucinates Ayah boundaries!

Example (Habit Tracker — Surah Fussilat Page 1 in 4 Quarters):
```bash
curl -X POST "https://api.islamify.ai/v1/chat/completions" \
  -H "Authorization: Bearer $ISLAMIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "islamify-verified",
    "language": "de",
    "messages": [
      {"role": "user", "content": "Stell dir vor, die erste Seite Fussilat ist unterteilt in vier Viertel. Welche Ayat wären das? Nenne für jedes Viertel drei einfache Lehren für einen Habit Tracker im Alltag in Deutschland."}
    ]
  }'
```

### B. Medina Mushaf Page & Quarter Split (`POST https://api.islamify.ai/v1/quran/mushaf`)
Deterministic 604-page Medina Mushaf lookup (0 ms hallucination risk):
```json
{
  "surah": 41,
  "page_offset": 1,
  "divide_into": 4,
  "language": "de"
}
```
Returns Medina Mushaf **Page 477** (`41:1–11`), partitioned cleanly into 4 quarters (`41:1–3`, `41:4–6`, `41:7–9`, `41:10–11`) with exact Uthmani Arabic, verified German translation, and Tanzil + QuranEnc attributions.

### C. Hifz & Mutashabihat Assistant (`POST https://api.islamify.ai/v1/quran/hifz`)
Designed for 2-tap Quran memorization apps (Mutashabihat, Rabt al-Ayat, Word Precision, Fawasil):
```json
{
  "surah_number": 7,
  "ayah_number": 51,
  "selected_words": "لَهْوًا وَلَعِبًا",
  "error_category": "mutashabihat_word_order",
  "preferred_mnemonic_style": "both",
  "known_surahs": [1, 2, 3, 4, 5, 6, 7],
  "language": "de"
}
```
Deterministically identifies twin verse **6:70** (`لَعِبًا وَلَهْوًا` vs. 7:51 `لَهْوًا وَلَعِبًا`) from the Uthmani corpus plus surrounding context (`7:50`, `7:52`) and returns structured flashcard JSON (`cards.twin_verse_comparison`, `cards.meaning_bridge`, `cards.visual_mnemonic`, `cards.flashcard_one_liner`). Set `"deterministic_only": true` for zero-LLM-cost lookup inside the 25/day free tier.

### D. Qur'an Lookup (`POST https://api.islamify.ai/v1/quran/lookup`)
Parameters: `surah` (1–114), `ayah_start`, `ayah_end` (max 8 verses per call) OR `query`, plus `language` (`de, en, ar, tr, bs, fr, id, ur, bn, fa`).

### E. Hadith Search (`POST https://api.islamify.ai/v1/hadith/search`)
Parameters: `collection` (`bukhari, muslim, abudawud, tirmidhi, nasai, ibnmajah, malik, riyad, nawawi, qudsi`), `hadith_number` OR `query`, `language`, `limit` (1–5).

### F. Scholarly Sources (`POST https://api.islamify.ai/v1/sources/search`) & Translation (`POST https://api.islamify.ai/v1/sources/translate`)
- Search: `query`, optional `queries_ar` (up to 4 Arabic terms), `limit` (1–5), optional `public_domain_only` (`true` restricts strictly to public-domain classics).
- Translate: `arabic_text` (4–1500 chars), `target_language`, optional `context`. Always returns the unaltered Arabic original alongside the working translation and mandatory notice.

### G. Quote Verifier (`POST https://api.islamify.ai/v1/quotes/verify`)
Parameters: `text` (up to 8,000 chars), `language`, `deep_check` (`false` = deterministic Stage 1; `true` = semantic translation check, 1.0 ct).

### H. Verified Answer (`POST https://api.islamify.ai/v1/answer`)
Parameters: `question`, `language`, optional `madhhab`, optional `output_instructions`, optional `public_domain_only`.

### I. AI Self-Service Account, Keys, Teams & Top-Up Management (0 Cent)
- `GET https://api.islamify.ai/v1/account`: Balance, workspace type (`personal` or `team`), active Islamify.ai subscription allowance, daily free quota, spending caps, available payment providers (`stripe`, `paypal`).
- `GET https://api.islamify.ai/v1/teams`: List API Teams the authenticated account belongs to, including role, granular permissions, and shared team prepaid balance.
- `GET https://api.islamify.ai/v1/usage?limit=30`: Real-time usage log and immutable ledger entries.
- `PATCH https://api.islamify.ai/v1/account/settings` (`keys:manage`): Update `daily_cap_eur`, `monthly_cap_eur`, `public_domain_only`.
- `GET https://api.islamify.ai/v1/keys` (`keys:manage`): List all keys (`id`, `name`, `key_prefix`, `allow_abo`, caps, `status`).
- `POST https://api.islamify.ai/v1/keys` (`keys:manage`): Create named key (`name`, `daily_cap_eur`, `monthly_cap_eur`, `allow_abo`, `allow_manage`). Returns `secret_once` once.
- `PATCH https://api.islamify.ai/v1/keys/{key_id}` (`keys:manage`): Rename key or update caps / `allow_abo`.
- `DELETE https://api.islamify.ai/v1/keys/{key_id}` (`keys:manage`): Immediately revoke key.
- `POST https://api.islamify.ai/v1/billing/topup`: Body `{"amount_eur": 10, "provider": "stripe"|"paypal", "widerruf_waiver_accepted": true|false}`. Returns direct Stripe Checkout or PayPal approval URL (or prefilled `https://platform.islamify.ai/billing` confirmation URL if waiver not yet confirmed).

---

## 4. Official MCP Server — Setup for ChatGPT, Google Gemini, Claude & Other AIs

Endpoint: `https://mcp.islamify.ai/mcp` (Icons, display title `Islamify.ai`, prompts, and instructions are automatically returned in `initialize.serverInfo`).

- **1. ChatGPT (Web, Desktop & App):** Open Settings → Apps & Connectors → Advanced → enable Developer Mode → Add custom MCP server → Name `Islamify.ai`, URL `https://mcp.islamify.ai/mcp`, Auth `OAuth`. (Codex CLI: `codex mcp add islamify --url https://mcp.islamify.ai/mcp`)
- **2. Google Gemini:** Gemini CLI: `gemini mcp add --transport http islamify https://mcp.islamify.ai/mcp` (Consumer Gemini App via Google Connected Apps `@Islamify.ai`).
- **3. Claude (Web, iPhone, Android & Code):** 1-Click Prefill: `https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=Islamify.ai&connectorUrl=https%3A%2F%2Fmcp.islamify.ai%2Fmcp` · Claude Code: `claude mcp add --transport http islamify https://mcp.islamify.ai/mcp`
- **4. Other AIs (Cursor, VS Code, Local STDIO):** Remote Streamable HTTP `https://mcp.islamify.ai/mcp` or `npx -y @islamify/mcp` with `ISLAMIFY_API_KEY`.

### Available MCP Tools (14 Tools, Full Safety Annotations)
1. `islamify_quran_lookup` (`readOnlyHint: true`)
2. `islamify_quran_mushaf` (`readOnlyHint: true`)
3. `islamify_hifz_helper` (`readOnlyHint: true`)
4. `islamify_hadith_search` (`readOnlyHint: true`)
5. `islamify_scholarly_sources` (`readOnlyHint: true`)
6. `islamify_translate_source` (`readOnlyHint: true`)
7. `islamify_verify_quotes` (`readOnlyHint: true`)
8. `islamify_ask_verified` (`readOnlyHint: true`)
9. `search` (`readOnlyHint: true`, Deep Research & Knowledge Connectors)
10. `fetch` (`readOnlyHint: true`, Deep Research & Knowledge Connectors)
11. `islamify_account_status` (`readOnlyHint: true`, 0 ct)
12. `islamify_manage_api_key` (`readOnlyHint: false, destructiveHint: false`, 0 ct, `keys:manage`)
13. `islamify_revoke_api_key` (`readOnlyHint: false, destructiveHint: true`, 0 ct, `keys:manage`)
14. `islamify_create_topup_link` (`readOnlyHint: false, openWorldHint: true`, 0 ct)

---

## 5. Mandatory Attribution & Copyright Rules
- Never alter Arabic Qur'an, Hadith, or scholarly excerpts returned by the API/MCP.
- Preserve all `attribution` and `rights` fields (Tanzil CC BY 3.0, QuranEnc/HadeethEnc version & translator, foundation URLs like `binbaz.org.sa` / `qurancomplex.gov.sa`, and working-translation disclaimers).
- Educational information only — never present outputs as a binding personal religious ruling (fatwa).
- Bulk scraping, full-book reconstruction, and AI model training on returned texts are strictly prohibited.
