Used by thousands of students worldwide - help us reach 150 members
Developers
Sharh API
The same REST API that powers sharhapp.com and the Sharh mobile app. Read classical texts line by line, manage your notes, flashcards and bookmarks, digitize documents with OCR, and more — 173 endpoints across 20 resource groups.
Base URL
All paths in this reference are relative to the API base URL. Requests and responses are JSON unless an endpoint says otherwise.
https://app.ummahspot.comMany read endpoints are public and need no credentials:
curl "https://app.ummahspot.com/books/search?q=ajrumiyyah"Authentication
Authenticated endpoints expect a bearer credential in the Authorization header. There are two kinds, and they are interchangeable on every endpoint in this reference except token management:
- API tokens (recommended for scripts and integrations) — long-lived tokens that start with
sharh_pat_, are attached to your account and act with your permissions. Create and revoke them on the API Tokens page or through the API Tokens endpoints. - Session tokens — the JWT returned by
POST /user/login,POST /user/signupor Google sign-in. This is what the web and mobile apps use. Session tokens do not expire.
export SHARH_TOKEN="sharh_pat_..."
curl "https://app.ummahspot.com/books/mybooks" \
-H "Authorization: Bearer $SHARH_TOKEN"curl -X POST "https://app.ummahspot.com/user/login" \
-H "Content-Type: application/json" \
-d '{"identifier": "you@example.com", "password": "••••••••"}'Treat API tokens like passwords. The full token is shown once when you create it; Sharh only stores a hash. You can hold up to 10 active tokens, give each an optional expiry of up to 365 days, and revoke any of them at any time. API tokens cannot create or revoke other tokens, and are rejected by admin-only endpoints.
Access levels
Each endpoint is labelled with what it needs:
- Public — no credentials needed.
- Auth optional — works anonymously, but returns more (your private items, personalised fields) when you send a token.
- Auth required — any signed-in account. Most of these only ever touch your own data.
- editor / admin only — content-management endpoints limited to accounts with the editor role.
- Subscription required — needs an active Sharh subscription (OCR uploads).
Errors
The API uses conventional HTTP status codes. Be prepared for error bodies to be either JSON ({ "message": "..." } or { "error": "..." }) or a plain-text string, depending on the endpoint — check the status code first.
| 400 | Missing or invalid parameters |
| 401 | No credential was sent on an endpoint that requires one |
| 402 | The content is gated behind a creator subscription |
| 403 | The token is invalid, expired or revoked, or your account lacks the required role or subscription |
| 404 | The resource does not exist, or is not visible to you |
| 500 | Something went wrong on our side. Malformed ids are also commonly reported as 500 |
Conventions
- Resource ids are 24-character MongoDB ObjectId strings. Timestamps are ISO 8601 in UTC.
- A book's lines live inside the book: each line has
Arabic,English,commentaryandrootwordsfields. - List endpoints that paginate take
pageandlimitquery parameters; each endpoint documents its own defaults and response envelope. - Audio, files and images are served through short-lived presigned URLs — request a fresh URL rather than storing one.
- File uploads use
multipart/form-data; everything else takes a JSON body.
API reference
Account
/userAccount creation, email/password login, Google sign-in (browser redirect flow and mobile ID-token flow), password reset, and the current user's profile and profile picture. Successful logins return a JWT that must be sent as `Authorization: Bearer <token>` on authenticated requests.
/user/api-tokensCreate, list and revoke personal API tokens. Tokens are attached to your user account and act with your permissions. These endpoints require a login session token (JWT) — an API token cannot be used to manage API tokens.
Library
/booksBrowse, search, create and edit books. A book is a classical text stored as an ordered array of bilingual lines (Arabic, English, commentary, root words) embedded in the book document. Most error responses in this group are plain-text bodies rather than JSON.
/bookmarksPer-user bookmarks on book lines, with an optional note. A bookmark points at a line by its zero-based position (lineId) within the book, and is unique per user, book and line. All routes require authentication and only ever touch the caller's own bookmarks.
/audioText-to-speech audio for book lines. Audio is generated per line field (arabic, english, commentary) with an OpenAI TTS voice, stored as MP3 in S3 under the key bookId/lineId/field/voice_contentHash.mp3, and handed to clients either as a time-limited S3 presigned URL or as an MP3 stream proxied by the API. The content hash covers all of the line text plus the voice, so editing a line invalidates its cached audio. Generating audio is restricted to editors and admins; anonymous callers and members can only fetch audio that has already been generated for the current line content, and the listing and URL endpoints apply the same read-access rules as GET /books/:bookId (private and subscriber-only books require a token).
/quizAI-generated multiple-choice quizzes for books. A quiz belongs to one book and holds a list of questions, each with exactly 4 options (one correct) and a rationale. Reading quizzes is public; generating, editing and deleting them is limited to editors and admins.
Study Tools
/notesPrivate, sectioned study notes that live inside folders. Section bodies are stored as strings (the Sharh editor stores BlockNote JSON in them). Also includes web clipping into a note and importing whole books from the usul.ai library as notes.
/foldersFolders organise a user's notes. Every note belongs to exactly one folder, and folders are private to their owner.
/cardsIndividual flashcards (front / back) that belong to a flashcard collection and are scheduled with an SM-2 style spaced-repetition algorithm. Cards are private to their owner.
/card-collectionsFlashcard decks. A collection groups cards, carries per-deck daily review settings, and exposes study queues (due cards, new cards) and statistics. Collections are private to their owner.
Documents
/ocrUpload PDFs or page images for asynchronous OCR, poll job status, and read, search, edit, import and export the resulting digitized books ("BookTexts"). The flow is: POST /ocr uploads the file to S3, creates a pending BookText and enqueues an SQS job; an OCR worker posts pages and the final result back through the /ocr/result callbacks; clients poll GET /ocr/status/:jobId and then fetch the text with GET /ocr/text/:jobId or GET /ocr/books/:bookTextId. Page credits are deducted (and overage billed at $0.02/page) only when a job is reported as completed.
/filesLibrary of uploaded documents and videos stored in S3, with metadata (title, author, tags, categories, visibility) kept in MongoDB. Files and videos share the same underlying File model. Authentication failures are answered by the auth middleware with plain-text bodies (401 no token, 403 invalid token or missing role, 404 when the token's user no longer exists).
Social
/communitySocial feed: posts with image/video media, one-level threaded comments, likes, content reports, user profiles and follows. Every route in this group requires a logged-in user. Authentication failures are answered by the auth middleware with plain-text bodies (401 no token, 403 invalid token or missing role, 404 when the token's user no longer exists).
/creatorsCreator monetization: applying to become a creator, managing the creator profile, Stripe Connect payouts onboarding, paid subscription tiers (1-3), gating books and notes behind a subscription tier, posting creator updates, subscribing to a creator via Stripe Checkout, and the public creator directory and creator pages.
/notificationsPush notification device registration and the in-app notification inbox (list, unread count, mark as read) for the authenticated user.
/announcementsSite-wide announcements published by the Sharh team. Clients can fetch the single currently active announcement; creating and managing announcements is restricted to administrators and is not part of the public API.
/feedbackSubmit suggestions, bug reports and content corrections to the Sharh team. Submission is open to everyone; reviewing and managing feedback is restricted to administrators and is not part of the public API.
Billing
/stripeStripe-backed subscription management (checkout, cancel, reactivate, plan changes), payment methods, invoices, and OCR page-credit usage tracking. Every call acts on the Stripe customer attached to the authenticated user. Plans: $5/month (1,000 OCR pages per billing period), $10/month (2,000 pages) and $50/month (10,000 pages); pages beyond the plan allowance are billed as overage at $0.02 per page. Most errors in this group are returned as plain text, not JSON.
/iapMobile in-app purchase entitlements. Lets the iOS app validate an App Store subscription with Apple and attach it to the signed-in Sharh account, and lets any client read the account's current mobile subscription state.
/affiliatesReferral program. Affiliates are created by administrators and identified by a unique referral code; a referral links one signed-up user to one affiliate, and the affiliate earns a percentage commission (`commissionRate`) on that user's subscription payments. These endpoints let a signup flow validate a referral code and record the referral, and let an affiliate view their own performance. Affiliate management endpoints are admin-only and not documented here.