# Citation styles (/docs/api/citation_styles) Everywhere the API returns citations (`citation_formats` on [create search](/docs/api/create_search), [verify](/docs/api/verify), [get paper](/docs/api/get_paper) and [format citation](/docs/api/format_citation)) you can name the five original styles, `apa7`, `mla9`, `ieee`, `harvard` and `bibtex`, or any style id from this list: `chicago-author-date`, `vancouver`, `nature`, `american-medical-association`, a journal's house style. The five original styles keep their own fields in `citations`; every other style is rendered through [Citation Style Language](https://citationstyles.org) and returned in `citations.styles` under its id. At most 10 styles per request. ```bash title="Find a style" curl "https://api.sourcely.net/citations/styles?q=chicago" ``` ```json title="Use it" { "doi": "10.1038/s41586-020-2649-2", "citation_formats": ["apa7", "chicago-author-date", "vancouver"] } ``` ```json title="Response (abridged)" { "citations": { "apa7": "Harris, C. R., Millman, K. J., & van der Walt, S. J. (2020). Array programming with NumPy. Nature, 585(7825), 357–362. https://doi.org/10.1038/s41586-020-2649-2", "mla9": null, "ieee": null, "harvard": null, "bibtex": null, "styles": { "chicago-author-date": "Harris, C. R., K. J. Millman, and S. J. van der Walt. 2020. “Array Programming with NumPy”. Nature 585 (7825): 357–62. https://doi.org/10.1038/s41586-020-2649-2.", "vancouver": "Harris CR, Millman KJ, van der Walt SJ. Array programming with NumPy. Nature. 2020;585(7825):357–62." } } } ``` A few spellings are accepted as aliases: `apa`, `mla`, `chicago`, `ama`, and the app's own keys such as `APA7` or `Vancouver`. An unknown name returns **422** with up to three suggestions. Numeric styles (IEEE, Vancouver, Nature) are returned as the bibliography entry without its number, since the number depends on the order of your reference list. The list is the Sourcely app's set of 793 CSL styles minus 35 the renderer cannot handle (footnote-only law styles and a few with unsupported text-case rules). Public, no API key, cached for an hour. # Create a search (/docs/api/create_search) Returns a `job_id` with status `queued`. Use it to [get your search results](/docs/api/get_search). Send `Authorization: Bearer` with a dashboard API key. A rejected key returns **401** `invalid_api_key` and does not create a search. See [API keys](/docs/authentication). The 202 body includes `usage.estimated_cost`, the maximum USD charge for these options after your subscription discount, and `usage.discount_percent`. `actual_cost` is null until the search finishes. If your credit balance cannot cover the estimate, the response is **402** `insufficient_balance` and no search is created. See [Credits and pricing](/docs/billing). Each API key can create 10 searches per minute and 100 per hour. Over that, the response is **429** `rate_limit_exceeded` with `Retry-After`, and no search is created. See [API keys](/docs/authentication#rate-limits). ## Request options [#request-options] * `mode` picks the search depth. `quick` searches one Google Scholar page per search phrase. `deep` searches widely, shortlists the 15 most promising sources, reads them in full and ranks them twice, which usually takes about three minutes. See [How search works](/docs/how_search_works). * Set `enrichment: "none"` to skip analysis. If omitted, quick search uses `medium` and deep search uses `high`. The levels mirror the Sourcely app: `low` analyzes the abstract (with quotes from it), `medium` reads the paper without quoting it (the app's free tier), `high` reads the paper and quotes 3–5 passages from the body (the app's paid tier). * There is no page-size field. A page is one provider results page per search phrase, so a quick search returns up to 20 sources, or 30 for texts over 3000 characters, and a deep search returns up to 15. * Use [filters](#filters) to narrow results by year, citations, keywords, domains and more. * Unknown request fields return **422**, including the removed `max_sources`. ## Filters [#filters] `filters` is an optional object. Omit it, send `null`, or send an empty object to search without additional filter constraints. Every field below is optional and defaults to `null`. Unknown filter names are rejected with HTTP **422**. Active filters are combined: a source must pass every local condition. Filters narrow the available results, so a successful search may return fewer than a full page, or none. Some filters also affect provider retrieval; the differences are explained below. ### year\_from [#year_from] **Type:** integer or `null`. **Example:** `2020`. Keep papers published **in 2020 or later**. The boundary is inclusive. Papers with an unknown publication year are excluded when this filter is active. Omit it or use `null` to leave the lower bound open. ### year\_to [#year_to] **Type:** integer or `null`. **Example:** `2024`. Keep papers published **in 2024 or earlier**, including 2024 itself. Unknown publication years are excluded when this filter is active. Omit it or use `null` to leave the upper bound open. Together, `"year_from": 2020` and `"year_to": 2024` select 2020–2024 inclusive. Set the lower bound no higher than the upper bound. The current model accepts integers without validating the order or imposing a calendar-year range; an inverted range cannot match a known publication year. ### min\_citations [#min_citations] **Type:** integer greater than or equal to `0`, or `null`. **Example:** `10`. Keep sources with **at least 10 citations** according to available provider metadata. This is a citation-count threshold, not a relevance score or a guarantee of quality. Unknown counts are treated as zero during filtering: they pass `0`, but fail any positive threshold. Omit the field or use `null` for no citation-count restriction. Negative values return HTTP **422**. ### open\_access [#open_access] **Type:** boolean or `null`. **Example:** `true`. With `true`, keep only sources whose metadata contains a non-empty `pdf_url`. The API does not verify that the PDF is downloadable or confirm its license, so this currently indicates PDF availability in the metadata. `false`, `null` and omission all disable this filter. **`false` does not select closed-access papers.** ### paper\_types [#paper_types] **Type:** array of `"research"` and/or `"review"`, or `null`. **Example:** `["review"]`. | Value | Current behavior | | ------------------------ | ------------------------------------------------------------------------------------------------------------ | | `["review"]` | Keep sources whose title, abstract or venue text looks like a review, survey or meta-analysis. | | `["research"]` | Exclude sources identified by that review heuristic. | | `["research", "review"]` | Allow either in local filtering; upstream retrieval can still favor reviews whenever `"review"` is included. | | `[]`, `null`, or omitted | No paper-type restriction. Use this when you want both types without a review-specific provider hint. | Values are case-sensitive; unsupported values return HTTP **422**. Classification uses text heuristics and provider hints. It does not independently verify the publication type or peer-review status, and it is separate from the returned enrichment classification. ### venue [#venue] **Type:** string or `null`. **Example:** `"Nature"`. Ask supporting providers to restrict retrieval to a journal or publication venue. Use a venue name, not an article title or a URL. Currently, this hint is sent to Semantic Scholar and providers using Scholar search URLs. The Serper adapter does not forward it, and the API does not apply an exact venue match after retrieval. Results can therefore include other venues. Omit it, use `null`, or use an empty string to disable the hint. ### include\_keywords [#include_keywords] **Type:** array of strings or `null`. **Example:** `["sleep", "memory"]`. Require **all** entries to appear somewhere in the combined **title, abstract and venue** metadata. They may appear in different fields. Matching is case-insensitive and uses literal substrings, so `"sleep"` can match `"sleeping"`. It does not search the full paper or expand synonyms. Google Scholar also receives each entry as a separate quoted phrase that every result must contain. Provider retrieval can therefore be stricter than the local all-keywords check. Omit it, use `null`, or use `[]` to disable this filter. Entries are trimmed, and empty entries are ignored. ### exclude\_keywords [#exclude_keywords] **Type:** array of strings or `null`. **Example:** `["mouse", "rat"]`. Exclude a source if **any** entry appears in its combined title, abstract or venue metadata. Matching is case-insensitive and uses substrings: `"rat"` can also match a longer word containing those letters. Choose terms carefully when you need precise exclusions. Omit it, use `null`, or use `[]` to disable this filter. An empty string matches every source and would exclude everything. If a source matches both an included and an excluded term, the exclusion wins. Full-paper text is not inspected. ### include\_domains [#include_domains] **Type:** array of strings or `null`. **Example:** `["ncbi.nlm.nih.gov"]`. Return only sources whose `url` or `pdf_url` is on one of these domains or their subdomains. `"ncbi.nlm.nih.gov"` also matches `pubmed.ncbi.nlm.nih.gov`. You can pass bare host names or full URLs; the scheme, `www.` and any path are ignored. Google Scholar also receives matching `site:` operators. Sources without a URL are excluded while this filter is active. Omit it, use `null`, or use `[]` to disable it. ### exclude\_domains [#exclude_domains] **Type:** array of strings or `null`. **Example:** `["wikipedia.org"]`. Drop any source whose `url` or `pdf_url` is on one of these domains or their subdomains, so `"wikipedia.org"` also removes `en.wikipedia.org`. Entries are normalized like `include_domains`, and Google Scholar receives matching `-site:` operators. Omit it, use `null`, or use `[]` to disable it. ### preferred\_domains [#preferred_domains] **Type:** array of strings or `null`. **Example:** `["ncbi.nlm.nih.gov", "nature.com"]`. Move sources from these domains ahead of the rest, most preferred first. Unlike `include_domains`, other domains still appear. Within each group the normal order is kept. Omit it, use `null`, or use `[]` to keep the normal order only. ### Example request with filters [#example-request-with-filters] This request looks for recent papers containing both “sleep” and “memory” in their metadata, with at least ten citations, while excluding the phrase “case report”. Add `open_access`, `paper_types` or `venue` only when you need those additional restrictions. ```json title="Request body" { "text": "How does sleep affect memory consolidation?", "mode": "quick", "enrichment": "none", "filters": { "year_from": 2020, "year_to": 2025, "min_citations": 10, "include_keywords": ["sleep", "memory"], "exclude_keywords": ["case report"] } } ``` ## Response and value reference [#response-and-value-reference] * [JobAccepted fields](/docs/reference/models#jobaccepted) * [SearchRequest and filters](/docs/reference/models#searchrequest) * [All enums](/docs/reference/enums) * [Validation and other errors](/docs/errors) HTTP 402 `insufficient_balance` means the account's credits cannot cover `estimated_cost`. The body says why. Add credits on the **API and MCP** page in Sourcely, or turn on [automatic top-up](/docs/billing#automatic-top-up): ```json title="402 · insufficient_balance" { "error": { "code": "insufficient_balance", "message": "Prepaid balance is below the estimated cost of this search.", "details": { "estimated_cost": 0.165, "credits_remaining": 0.04 } } } ``` `webhook_url` receives a POST when the search finishes. See [Webhooks](/docs/webhooks). Polling still returns the result. # Format a citation (/docs/api/format_citation) Two ways to use it: * **From a DOI.** The paper is looked up in Crossref and Semantic Scholar and the citation is written from the registry record, so the facts are the registry's, not the caller's. * **From metadata.** Pass `source` with the title, authors, year, venue and whatever else you have. The citation is written from exactly those values; nothing is looked up or checked. Use [verify a reference](/docs/api/verify) first if the metadata came from a language model. Any style from [citation styles](/docs/api/citation_styles) can be requested alongside the five original ones; it comes back in `citations.styles` under its id. The formatter is deterministic: the same input always gives the same string. Author names may be written as `Given Family` or `Family, Given`; name particles such as `van der` stay with the family name. **Free.** No charge, no plan needed, no free-search allowance used. Rate limited like reads. ```json title="From metadata" { "source": { "title": "Array programming with NumPy", "authors": ["Charles R. Harris", "K. Jarrod Millman", "Stéfan J. van der Walt"], "year": 2020, "venue": "Nature", "volume": "585", "issue": "7825", "pages": "357-362", "doi": "10.1038/s41586-020-2649-2" }, "citation_formats": ["apa7", "mla9"] } ``` ```json title="Response (abridged)" { "result_type": "citations", "citations": { "apa7": "Harris, C. R., Millman, K. J., & van der Walt, S. J. (2020). Array programming with NumPy. Nature, 585(7825), 357–362. https://doi.org/10.1038/s41586-020-2649-2", "mla9": "Harris, Charles R., et al. \"Array programming with NumPy.\" Nature, vol. 585, no. 7825, 2020, pp. 357–362. https://doi.org/10.1038/s41586-020-2649-2", "ieee": null, "harvard": null, "bibtex": null }, "source": { "id": "src_…", "title": "Array programming with NumPy", "…": "…" }, "registries": [] } ``` ## Style rules [#style-rules] | Style | Authors | Shape | | --------- | -------------------------------------------------------------------- | --------------------------------------------------------------- | | `apa7` | `Family, I. I.` joined with `&`; 21 or more: first 19, `. . .`, last | `(Year). Title. Venue, Vol(Issue), pages. https://doi.org/…` | | `mla9` | `Family, Given`; two: `, and Given Family`; three or more: `, et al` | `"Title." Venue, vol. V, no. N, Year, pp. P. https://doi.org/…` | | `ieee` | `I. I. Family`; seven or more: first `et al.` | `"Title," Venue, vol. V, no. N, pp. P, Year, doi: …` | | `harvard` | `Family, I.I.`; four or more: first `et al.` | `(Year) 'Title', Venue, V(N), pp. P. doi:…` | | `bibtex` | `Given Family and …` | `@article{familyyearword, …}` with only the fields known | Other styles (`chicago-author-date`, `vancouver`, `nature`, …) are rendered through CSL from the same metadata; numeric styles are returned without their number. Missing fields are left out rather than filled in. A missing year is `n.d.` in APA and Harvard. These are journal-article shapes; books and chapters are formatted the same way with the publisher as the venue. A DOI that does not resolve returns **404** `paper_not_found`; a request with neither `doi` nor `source` returns **422**. # Get a paper by DOI (/docs/api/get_paper) Pass the DOI in the path, with or without the `https://doi.org/` prefix. The API resolves it in Crossref and Semantic Scholar and returns one [Source](/docs/reference/models#source): title, authors, year, venue, volume, issue, pages, links, citation count and abstract, with citations in the styles you ask for. **Free.** No charge, no plan needed, no free-search allowance used. Rate limited like reads; usually under a second. `citation_formats` is a comma-separated list of `apa7`, `mla9`, `ieee`, `harvard`, `bibtex`. Omit it for all five; pass an empty value for none. ```bash title="Example" curl -H "Authorization: Bearer $SOURCELY_API_KEY" \ "https://api.sourcely.net/papers/10.1038/s41586-020-2649-2?citation_formats=apa7,bibtex" ``` Crossref supplies the full author list, venue, volume, issue, pages and date; Semantic Scholar adds the citation count, abstract and open-access PDF when it has them. `registries` lists which of the two answered. A DOI that resolves nowhere, or a value that is not a DOI, returns **404** `paper_not_found`. When neither registry answers, **503** `registry_unavailable`. To find a paper by title or reference text instead, use [verify a reference](/docs/api/verify), which also finds its DOI. # Get search results (/docs/api/get_search) Pass the `job_id` from [Create a search](/docs/api/create_search) and the same account's API key. When `status` is `completed`, your sources are ready. A key from another account receives **404** `job_not_found`. `usage.estimated_cost` is present while the search is queued. `actual_cost` is filled when it finishes and deducted from your credits; it is 0 when the search fails. Both include your subscription discount, shown as `usage.discount_percent`. Polling does not add another charge. ## While it runs [#while-it-runs] A `running` search reports its current step in `progress`, so you can show the person what is happening instead of a spinner: ```json title="Progress of a running search" { "job_id": "src_example", "status": "running", "progress": { "stage": "analyzing", "message": "Analyzing source 12 of 26", "done": 12, "total": 26, "updated_at": "2026-11-01T15:04:05Z" }, "usage": { "currency": "USD", "estimated_cost": 0.165, "discount_percent": 0 } } ``` The stages run in order: `preparing`, `searching`, `analyzing` (one step per source), then `sourcing_claims` (one step per claim) when claims were requested. Deep searches add `shortlisting` before the analysis and `reranking` after it. `done` and `total` are present only for the counted stages. See [search states](/docs/lifecycle). ## Reading the result [#reading-the-result] 1. Check `status`: a 200 response means the lookup succeeded, not necessarily the search. 2. Read the ordered IDs from `document.source_ids` or each claim's `source_ids`. 3. Resolve each ID in `sources` to retrieve the full source object. 4. Use each track's `scores` for its ranking context. These are not confidence percentages. 5. `document.search_queries` lists the search phrases that were written from your text and sent to the providers. The example is synthetic and shows a document-only search without citations or enrichment. Consult the [model reference](/docs/reference/models#searchresult) for every field, and [enums](/docs/reference/enums#jobstatus) for the exact state values. ## Missing and failed searches [#missing-and-failed-searches] An unknown ID returns **404** with `error.code: "job_not_found"`. Results live in Redis and survive an API-process restart. Completed and failed results expire one hour after completion by default; polling does not extend that window. Expired, deleted or lost records all return 404. Redis outages return 503 `cache_unavailable`, not 404. A failed search currently returns **200** with `status: "failed"`. Stored job-level failure details are not exposed in the current response model. See [errors](/docs/errors) for the current and planned mappings. # Usage counters (/docs/api/stats) Public, no API key. The numbers are the all-time totals of searches accepted through the MCP server and through the API, and of sources those searches returned. They are exact integers; round them in your UI. ```bash title="Example" curl https://api.sourcely.net/stats ``` The response is cached for 60 seconds (`Cache-Control: public, max-age=60`) and allows any origin, so a page can fetch it in the browser. One client address can read it 30 times a minute; more returns **429** with `Retry-After`. When the counters cannot be read, **503** `cache_unavailable`; a value cached in the last minute is served instead when there is one. # Verify a reference (/docs/api/verify) Send one reference as written, a DOI, or both. The API looks the paper up in Crossref (the DOI registry) and Semantic Scholar, compares the reference with the registry record field by field, and returns the record with formatted citations. Everything is a string comparison: no language model is involved, so the verdict is a comparison of facts, not an opinion. **Free.** The call costs nothing, needs no plan and uses no free-search allowance. It is rate limited like reads and usually answers in under two seconds. ## What you get back [#what-you-get-back] `status` is one of: | status | meaning | `source` | | ------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------ | | `verified` | A real paper, and no checked field disagrees. | the record | | `mismatch` | A real paper was found but the title, authors or year differ. `message` says which. | the record: the entry to use | | `not_found` | No registry has a paper with this title. The reference may be invented. | null | | `invalid_doi` | The DOI does not resolve, or is not a DOI. | the paper the title matches, if any, with its real DOI | `checks` compares the reference text with the record for `title`, `authors` (the first author's surname), `year` and `venue`, each `match`, `mismatch` or `unverified`. `unverified` means the reference or the registry does not state the field; a bare DOI with no reference text leaves every check unverified, because there is nothing to compare. `venue` is never reported as a mismatch, since venues are abbreviated and renamed too often for a missing venue to count against a reference. ```json title="A reference with the wrong year" { "result_type": "verification", "status": "mismatch", "message": "The reference does not match the registry record for year: the year is 2020. The entry under 'source' is the registry's record; use its fields.", "doi": "10.1038/s41586-020-2649-2", "checks": { "title": "match", "authors": "match", "year": "mismatch", "venue": "unverified" }, "source": { "id": "src_da992204b9f9", "title": "Array programming with NumPy", "authors": ["Charles R. Harris", "K. Jarrod Millman", "Stéfan J. van der Walt", "…"], "year": 2020, "venue": "Nature", "doi": "10.1038/s41586-020-2649-2", "url": "https://doi.org/10.1038/s41586-020-2649-2", "pdf_url": "https://www.nature.com/articles/s41586-020-2649-2.pdf", "citation_count": 23585, "citations": { "apa7": "…", "mla9": "…", "ieee": "…", "harvard": "…", "bibtex": "…" } }, "registries": ["crossref", "semantic_scholar"] } ``` `source` is a [Source](/docs/reference/models#source) like the ones a search returns: Crossref supplies the full author list, venue and date, Semantic Scholar the citation count, abstract and open-access PDF when it has them. `registries` lists which of the two answered; if one was slow, the result rests on the other. ## How matching works [#how-matching-works] * A DOI in the request, or inside the reference text, is resolved first. If it does not resolve, the reference text is still searched so the response can name the paper the title matches. * Without a DOI, both registries are queried with the reference text and the best title match is taken. A record counts as the paper when at least 80% of its title's words appear in the reference, or the whole title does. Titles of one or two words are ignored for full references, since they match almost anything. * Among records with the same title (Crossref also lists preprints and reprints), the one whose year the reference names wins. ## Use it for [#use-it-for] * Checking a reference list an assistant or a student produced: one call per entry. * Confirming a DOI before it goes into a bibliography. * Finding the DOI and a formatted citation for a paper you can name. An unreachable registry pair returns **503** `registry_unavailable`; try again in a moment. See [errors](/docs/errors). # API keys & access (/docs/authentication) Create and get search require a dashboard API key: ``` Authorization: Bearer srcly_… ``` Keys are created in the dashboard. This API does not issue them. Send the same key when you retrieve a search. The key is a credential; it is different from the `job_id` returned by a search. A missing, malformed, revoked, or expired key returns **401** with `error.code: "invalid_api_key"`. No search is created. If this API cannot complete verification, it returns **503** with `error.code: "service_unavailable"` and does not run the search. ## Ownership [#ownership] The account that owns the key owns the search. Another key on the same account can retrieve it. A key from a different account receives **404** `job_not_found`, the same response as an unknown ID. Polling does not record another billable request. ## Key handling [#key-handling] Keep API keys on your server, in environment configuration or a secret manager. Do not ship private keys in frontend bundles or place them in URLs. The plaintext key is shown once, when the dashboard creates it. Revoke a lost key there and create a new one. ## Rate limits [#rate-limits] Limits are counted per API key, after the key is accepted. A rejected request does not start a search. | Operation | Limit | | ------------------------------------------------------- | --------------------------------- | | Create a search, including later page and claim updates | 10 per minute and 100 per hour | | Read or delete a search | 120 per minute and 4,000 per hour | Exceeding either window returns **429** with `error.code: "rate_limit_exceeded"` and a `Retry-After` header in seconds. Wait that long, then retry the same request. Polling every two seconds stays inside the read limit. These numbers are not a concurrency cap; a separate concurrency limit is not enforced yet. # Preview availability (/docs/availability) These docs cover the public API at `https://api.sourcely.net`: **create search** and **get search**, the free **verify**, **get paper** and **format citation** endpoints, and the public **usage counters**. The same API serves the hosted MCP server at `https://mcp.sourcely.net`. ## Available in the local implementation [#available-in-the-local-implementation] * Create a search and retrieve it by `job_id`. * Quick and deep search as in the Sourcely app: language-model search phrases, provider ordering, and for deep search a shortlist, full-text reading and a second ranking. See [How search works](/docs/how_search_works). * Document and claim tracks, filters including domain filters, citations and enrichment options. * Structured source maps and the enums listed in the reference. * Validation errors, unknown-search errors and pollable terminal failures. * Shared Redis storage with one-hour result retention by default, fenced updates and explicit cache-outage errors. * Dashboard API key checks on create and get. A search is readable by the owning account only. * Prepaid credits with Stripe top-ups and optional automatic top-up, managed on the **API and MCP** page in Sourcely. Subscription discounts of 15%, 35% and 50% for Pro, Ultra and Max. * A USD quote on create and get, and a charged actual cost when the search finishes. Create returns 402 when the credit balance cannot cover the estimate. * Per-key rate limits on search creation and polling, with `429` and `Retry-After`. * A webhook when `webhook_url` is set. The POST is sent after the search finishes. Polling remains the source of truth. The current server queues searches in Redis for a separate worker, which has a 10-minute execution timeout by default and may use heuristic/provider fallbacks. It does not place a hold. The credit balance decreases when a finished search reports its actual cost, and failed searches cost nothing. ## Planned before public launch [#planned-before-public-launch] * Prepaid holds, so that searches started at the same moment cannot overdraw the balance. * Idempotent creation. A concurrency limit separate from the per-key request windows. * Account-scoped expiry tombstones, a public expiry timestamp and worker recovery. * Clearer provider-failure reporting and recovery from whole-worker or Redis outages. ## Deferred public capabilities [#deferred-public-capabilities] Pagination actions, claim refetch, and public deletion are not part of the initial public reference. Those routes do not send a webhook. Page metadata remains on current models. ## Naming and contract changes [#naming-and-contract-changes] Public field names use snake\_case. Current relevance ratings still use human-readable enum strings such as `"Perfectly Relevant"`. These docs deliberately reproduce the implemented values; any move to snake\_case enum values must update the API and version policy together. ## For agents and SDK generators [#for-agents-and-sdk-generators] * The OpenAPI 3.1 document for the documented operations and their reachable schemas: [`https://docs.sourcely.net/openapi.json`](/openapi.json). The API serves its full document at [`https://api.sourcely.net/openapi.json`](https://api.sourcely.net/openapi.json), which also lists the pagination and claim refetch routes above. * [`https://docs.sourcely.net/llms.txt`](/llms.txt) is an index of these pages for language models; [`https://docs.sourcely.net/llms-full.txt`](/llms-full.txt) is every page in one file. * Interactive Swagger UI at [`https://api.sourcely.net/docs`](https://api.sourcely.net/docs). # Credits and pricing (/docs/billing) The API runs on prepaid credits. One credit is one US dollar. Every API key on your account draws from the same balance. A search is rejected with **402** `insufficient_balance` when the balance cannot cover its estimate, and charged its actual cost when it finishes. ## Add credits [#add-credits] 1. Sign in to Sourcely and open **API and MCP** in the left sidebar. 2. In the **Credits** card, choose **Add credits**. 3. Pick $20, $50, $100 or another whole amount between **$20 and $1,000**, then pay with a card on Stripe's checkout page. Credits appear as soon as the payment goes through. Every payment is listed under **Payments** on the same page. Credits do not expire. ## Automatic top-up [#automatic-top-up] So that requests never stop for lack of credits, you can let Sourcely charge a saved card automatically: * **Save a card** by ticking "Save this card for auto top-up" when you add credits, or with **Auto top-up**, then **Add card**, which charges nothing. * **Choose the rule:** when the balance falls below an amount, add a fixed amount of at least $20. The defaults are "below $5, add $20". * **Set a monthly limit.** Automatic top-ups stop once that much has been added in a calendar month. The default is $200. The balance is checked after every request, and one top-up runs at a time. If the card is declined or the bank asks for confirmation, auto top-up turns itself off and the page explains why. Requests then use the remaining balance until you add credits or fix the card. ## Price list [#price-list] The price depends only on the options you send and on what comes back. Citation formats are free. | Component | List price, USD | | ---------------------------------------- | --------------- | | Quick retrieval, per finished track | 0.005 | | Deep retrieval, per finished track | 0.150 | | Enrichment `none`, per returned source | 0 | | Enrichment `low`, per returned source | 0.002 | | Enrichment `medium`, per returned source | 0.008 | | Enrichment `high`, per returned source | 0.035 | Deep retrieval includes searching widely, the shortlist and the final ranking described in [How search works](/docs/how_search_works). A document request is one track. Each searched claim is another track. ## MCP server [#mcp-server] Searches through the hosted [MCP server](/docs/mcp) are included with Pro, Ultra and Max and do not use credits. Deep searches there count toward the plan's monthly deep search allowance instead. See [Plan and limits](/docs/mcp#plan-and-limits). ## Subscription discount [#subscription-discount] Sourcely subscribers pay less for every request. The discount comes from the subscription on the account that owns the key. It applies to `estimated_cost`, to `actual_cost` and to the balance check, and `usage.discount_percent` on every response shows the rate that was applied. | Subscription | Discount | Quick, 20 sources with analysis | Deep, 15 sources | | ------------ | -------- | ------------------------------- | ---------------- | | None | 0% | $0.165 | $0.675 | | Pro | 15% | $0.140 | $0.574 | | Ultra | 35% | $0.107 | $0.439 | | Max | 50% | $0.083 | $0.338 | A search keeps the discount it was created with, even if the subscription changes while it runs. ## Estimate and actual cost [#estimate-and-actual-cost] `estimated_cost` is the most a search can cost. It assumes every page is full: 10 sources per search phrase in quick mode, so 20 for most texts and 30 for texts over 3000 characters, and the full 15-source shortlist in deep mode. Omitted enrichment means `medium` for quick search and `high` for deep search. `actual_cost` is null until the search finishes. A finished track is charged its retrieval fee plus enrichment for the sources it actually returned, including a track that returns none. Claims that were identified but not searched are free. A failed search costs nothing: it keeps the estimate and sets `actual_cost` to 0. Next-page and claim-refetch calls are not priced yet. ## Balance check [#balance-check] Creating a search reads the account's balance and discount: 1. The key is invalid. The response is **401**. No search is created. 2. The balance is zero or below `estimated_cost`. The response is **402** `insufficient_balance`, and `details` includes `estimated_cost` and `credits_remaining`. No search is created and nothing is charged. A balance equal to the estimate is accepted. 3. Otherwise the search runs, and its `actual_cost` is deducted when it finishes. The API does not place a hold. Two searches started at the same moment can both pass the check, so the balance can briefly go slightly below zero; the next search is then rejected until you add credits. GET, delete, next page and claim refetch do not run this check, and retrieving a search never costs anything. Failed searches are not charged, so there is nothing to refund. Credits are not refunded to the card automatically. ## Usage fields [#usage-fields] See the [Usage model](/docs/reference/models#usage). A null `actual_cost` means the search has not finished. Zero means the finished search was not charged. ## Connection loss and retries [#connection-loss-and-retries] A timeout alone does not mean the search failed. When you have a search ID, retrieve that search. Repeating a create request may start and charge a second search, because idempotency keys are not supported yet. Results expire one hour after completion by default. Expiry never charges again or restarts a search. # Errors & recovery (/docs/errors) ## Implemented error mapping [#implemented-error-mapping] | HTTP / outcome | Code or shape | Meaning | Your next step | | ------------------------------------------------------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | | 401 | `error.code: "invalid_api_key"` | The API key is missing, invalid, revoked, or expired. | Send a valid dashboard key. No search is created. | | 402 | `error.code: "insufficient_balance"` | Your credit balance cannot cover this search's `estimated_cost`. | Top up or reduce the requested work. No search is created and nothing is deducted. | | 404 | `error.code: "job_not_found"` | No retained record for this account, or the ID belongs to another account. | Verify the ID and key. The result may have expired after one hour, been deleted, or been lost. | | 409 | `error.code: "search_conflict"` | The search is already running or its state changed during a write. | Read the known search ID; do not duplicate work automatically. | | 503 | `error.code: "cache_unavailable"` | Redis could not confirm a read or write. | Retry GET with backoff when the ID is known; POST outcomes may be uncertain. | | 429 | `error.code: "rate_limit_exceeded"` | This API key exceeded its per-minute or per-hour limit. | Wait for the `Retry-After` header, then retry the same request. No search is created. | | 503 | `error.code: "service_unavailable"` | API key verification or rate limiting could not be completed. | Retry later. No search is created. | | 422 | `error.code: "invalid_webhook_url"` | `webhook_url` is not a public http(s) URL. | Send a public URL, or omit it and poll. No search is created. | | 422 | `detail: [...]` | Invalid JSON, an unknown field, or a value outside the request schema. | Correct the fields identified in `detail[].loc`. | | 202 creation, then 200 polling with `status: "failed"` | Failed `SearchResult` | Search execution failed, exceeded its execution timeout, or its worker stopped with a recorded failure. | Treat the search as failed; do not interpret HTTP 200 as successful retrieval. | ### Insufficient balance [#insufficient-balance] Creating a search returns **402** when the account cannot cover `estimated_cost`. Branch on `error.code`. The message states the reason. `details.estimated_cost` is the price that was compared. `details.credits_remaining` is your remaining credit balance. ```json title="402 · insufficient_balance" { "error": { "code": "insufficient_balance", "message": "Prepaid balance is below the estimated cost of this search.", "details": { "estimated_cost": 0.165, "credits_remaining": 0.04 } } } ``` No search is created and nothing is charged. Add credits on the **API and MCP** page in Sourcely, or turn on [automatic top-up](/docs/billing#automatic-top-up), then send the request again. A cheaper request, such as `enrichment: "none"`, also has a lower estimate. ### Not found [#not-found] ### Cache unavailable [#cache-unavailable] ```json title="503 · cache_unavailable" { "error": { "code": "cache_unavailable", "message": "Search storage is temporarily unavailable.", "details": null } } ``` A confirmed admission failure before the Redis transaction executes prevents provider execution. A lost acknowledgement or transaction command failure can leave an uncertain outcome; a completion write failure can occur after providers ran. Neither case is automatically retried by the API. If you have the search ID, retry GET with bounded backoff. Without an ID, repeating POST may start duplicate work; request-level idempotency is still planned. A failed search is reported with `actual_cost` 0. A completed search is reported at its calculated cost. A create whose estimate is above the credit balance returns 402 and does not start a search. ### Validation [#validation] For example, `max_claims: 0` is outside the accepted range. The validation envelope differs from the custom API error envelope: ```json title="422 · validation error" { "detail": [ { "loc": ["body", "max_claims"], "msg": "Input should be greater than or equal to 1", "type": "greater_than_equal", "input": 0, "ctx": { "ge": 1 } } ] } ``` Additional details and message text can vary. Branch on the status and structured fields, rather than matching the full message. Validation responses can include the invalid input; avoid recording submitted text or credentials in application logs. ### Failed job [#failed-job] The current `SearchResult` has no job-level `error` field. A failed claim may have its own `error`, but stored job-level error details are not exposed yet. ## Empty results versus failures [#empty-results-versus-failures] A completed search may contain no sources. Current provider adapters also catch upstream failures and return empty lists, so the preview cannot always distinguish no matches from an exhausted provider failure. Clear provider-failure classification is planned. ## Planned production errors [#planned-production-errors] The following are design targets, **not currently enforced responses** for the initial pair of endpoints: | HTTP | Proposed code | Planned action | Planned balance effect | | ---------- | ------------------------------------------------------ | ---------------------------------------------------------------- | -------------------------------------------------------------------- | | 403 | `account_disabled` | Contact support. | No deduction. | | 409 | `idempotency_conflict` | Restore the original request for that key. | No extra deduction. | | 410 | `search_expired` | The retained result has expired, when a tombstone confirms this. | No automatic rerun or deduction. | | 429 | `concurrency_limit_exceeded` | Too many searches are already running for this key. | Back off according to `Retry-After`. Rejected work consumes nothing. | | Failed job | `upstream_error` / `search_timeout` / `internal_error` | Inspect the recorded terminal outcome. | Release the hold or refund that failed operation. | ## Safe recovery and balance [#safe-recovery-and-balance] A dropped connection is not proof that a search failed. Recover an existing search ID when available. In the planned prepaid model, service failures release or refund the affected operation; successful work is not charged again when retrieved. Wallet accounting and automatic refunds are not implemented in the current API. # Full text (/docs/full_text) ## Abstracts and source links [#abstracts-and-source-links] Search results can include an `abstract`, a source landing-page `url`, and a `pdf_url`. Any of these fields may be `null` when the provider does not supply them. An available PDF link does not guarantee download access or a particular license. ## Request source-content extraction [#request-source-content-extraction] Set `enrichment` to `"high"` when creating a search to read each returned source in full. Deep search uses `high` by default: ```json title="Request body" { "text": "How does sleep affect memory consolidation?", "enrichment": "high" } ``` For each source, the API fetches its landing page and, when there is one, its PDF, then converts them to text. The analysis (relevance rating, explanation, quoted evidence and paper type) is written from that text rather than from the abstract alone. Retrieve the search using its `job_id`, then inspect each entry in the `sources` map. The `parsed_source` field contains the extracted text of the page and, when there is one, the PDF: usually the whole paper, capped at 400,000 characters. It can instead contain the abstract as a fallback, or be `null`, for example when a publisher blocks access. It is not a guarantee of the complete paper. With `high`, the sources are also ranked again after they have been read. See [How search works](/docs/how_search_works) and the [enrichment fields](/docs/reference/models#enrichment). Full-text analysis is priced per returned source; see [Credits and pricing](/docs/billing#price-list). ## Filter for PDF availability [#filter-for-pdf-availability] You can set `filters.open_access` to `true` to require a non-empty PDF URL in source metadata. This filter does not verify access rights or the extracted content. See the [filter reference](/docs/api/create_search#open_access). Source-content extraction is an option on [Create a search](/docs/api/create_search). There is no separate full-text download endpoint in the initial API. # How search works (/docs/how_search_works) Both modes start the same way and differ in how widely they search and how much they read. This is the same search the Sourcely app runs. ## 1. Your text becomes search phrases [#1-your-text-becomes-search-phrases] A language model reads your whole text and writes Google Scholar search phrases from it, most relevant first: * **Texts under 22 words** get three paraphrases of the text itself. * **Longer texts** get three topical keyword phrases of three to nine words each. The search uses the first **two** phrases, or the first **three** when the text is longer than 3000 characters. They are returned in `document.search_queries`, so you can show users what was searched. The phrases are written in the language of your text. ## 2. Quick search [#2-quick-search] For each phrase, quick search fetches **one Google Scholar results page** of up to 10 sources. If Google Scholar returns nothing, Semantic Scholar is used instead. Results keep the provider's own ranking. Phrase one's results come first, then phrase two's, so a typical page holds **up to 20 sources**, or 30 for long texts. Duplicates and sources that fail your [filters](/docs/api/create_search#filters) are removed, so a page can be shorter. With the default `medium` enrichment, each returned source gets a relevance rating, a short analysis and quoted evidence, based on its abstract. ## 3. Deep search [#3-deep-search] Deep search runs five stages and usually takes about three minutes: 1. **Search widely.** For each phrase it collects up to 15 results from Semantic Scholar and three Google Scholar pages, up to 30 more results. 2. **Shortlist.** A language model reads every candidate's title and abstract against your text and picks the **15 most promising**. 3. **Read.** Each shortlisted source's landing page and PDF are fetched and converted to text, three at a time. 4. **Analyze.** Each source is rated and analyzed against your text using its full text. The extracted text is returned in `parsed_source`. 5. **Rank again.** A second ranking pass orders the 15 sources using the analysis: relevance rating first, then study type, venue, citations and recency. The default enrichment for deep search is `high`. With `none` or `low`, the shortlist order is returned without the final ranking. The enrichment levels mirror the Sourcely app's tiers. `low` analyzes the title and abstract: rating, a short analysis, quotes from the abstract and the paper-type flags. `medium` is the app's free-tier read: a language model opens the source's landing page and PDF and returns the rating, analysis and paper type without quoting anything (`evidence` is always empty); about 5 seconds for a 20-source page. `high` is the app's paid-tier read, described next. `high` in quick mode works differently from deep mode: no source is scraped and nothing is reranked. Instead a language model opens each source's landing page and PDF itself, as the Sourcely app's quick search does, and returns the relevance rating, a short analysis and three to five evidence quotes taken from the body of the paper (numbers, effect sizes, sample sizes and verbatim sentences when the paper is reachable). The provider order is kept, so a quick page at `high` returns the same sources as at `medium`, read in full rather than from the abstract. A 20-source page takes about 20 seconds. `parsed_source` stays null on these sources; when a source cannot be opened, its abstract is analyzed instead. ## Ordering and scores [#ordering-and-scores] `document.source_ids` is the final order. `document.scores` gives each source a rank score: larger is better, and the scores are not confidence percentages. Sources from [preferred domains](/docs/api/create_search#preferred_domains) move ahead of the rest without reshuffling either group. ## Claims [#claims] With `granularity: ["claim"]`, the API also finds the citation-worthy claims in your text and searches each one separately, the way the Sourcely app's citation-worthy highlights work. A language model reads the whole text and picks the statements that need scholarly backing (well-established claims, not the author's own findings), between 2 and 12 depending on length, each quoted exactly from the text as the claim's `span`. Each claim is then rewritten into a self-contained search phrase, with pronouns and references such as "this approach" resolved from the surrounding text; that phrase is returned as `search_query` and is what the providers receive. Claims are searched up to `max_claims`; omitted, the cap scales with the text's length like the app's, from 1 for a sentence to every claim for an essay. Each searched claim is one search phrase, so it returns one provider page in quick mode or one 15-source shortlist in deep mode. Claims past the cap come back with `searched: false` and can be sourced later through the claim endpoint. ## Citations [#citations] Citations in APA 7, MLA 9, IEEE, Harvard and BibTeX, or any of the 750+ [citation styles](/docs/api/citation_styles) (Chicago, Vancouver, Nature, journal house styles), are formatted from the source's metadata. They cost nothing extra. Check them against the original source before publishing. ## What each mode costs [#what-each-mode-costs] | Typical request | List price | With Max, 50% off | | -------------------------------------- | ---------- | ----------------- | | Quick search, no analysis | $0.005 | $0.0025 | | Quick search, 20 sources with analysis | $0.165 | $0.083 | | Deep search, 15 sources read in full | $0.675 | $0.338 | You pay for the sources actually returned. See [Credits and pricing](/docs/billing) for the full price list and subscription discounts. # Build with academic sources (/docs) ## How it works [#how-it-works] Send your text to `POST /search` and keep the `job_id` it returns. Then call `GET /search/{job_id}` until the status is `completed`. Every source appears once in the `sources` map; the document and claim tracks list the IDs that apply to them. ## Reading the results [#reading-the-results] The [model reference](/docs/reference/models) describes every field, including nulls, defaults, scores, citations, and enrichment. The [enum reference](/docs/reference/enums) lists each wire value and when it appears. A suggested source is relevant to your text, but it does not guarantee that it supports each claim. Check the original before you rely on a quotation or finding. ## Preview status [#preview-status] This preview covers two operations. Searches work the same way as in the Sourcely app; [How search works](/docs/how_search_works) explains quick and deep mode. You pay per request from prepaid credits, and Sourcely subscribers get up to 50% off ([Credits and pricing](/docs/billing)). Holds and automatic worker recovery are planned but not available yet; see [Availability](/docs/availability). # Search lifecycle (/docs/lifecycle) ## Keep the search ID [#keep-the-search-id] `POST /search` returns a `job_id`. Store it in your application and use it for subsequent GET requests. A `job_id` identifies the whole search; a source ID identifies a paper within the search's `sources` map. ## Read the job state [#read-the-job-state] | State | What to do | | ----------- | ---------------------------------------------------------------------------- | | `queued` | Wait, then poll again. | | `running` | Wait; work is still in progress. | | `partial` | Some track results may be usable. Inspect track states and continue polling. | | `completed` | Read the sources and requested tracks. Stop polling. | | `failed` | Stop polling for success and inspect the [error guide](/docs/errors). | A quick search without analysis usually finishes in a few seconds; with the default `medium` analysis it takes about 10 to 20 seconds. A deep search reads 15 sources in full and usually takes a few minutes, so poll it less often or use a [webhook](/docs/webhooks). POST returns `queued` after Redis confirms the search and queue entry. A separate worker changes it to `running`, then `completed` or `failed`. GET may skip over short-lived states between polls. While the search is `running`, the response carries a `progress` object with the current step: its `stage` (`preparing`, `searching`, `shortlisting`, `analyzing`, `reranking` or `sourcing_claims`), a one-line `message` such as "Analyzing source 12 of 26", and `done` and `total` counts when the stage has them. Show the message to the person waiting; it is written for that. `progress` is `null` before the worker starts and once the search has finished. The worker has a **10-minute execution timeout** by default, starting when work begins, excluding time in the queue. A handled timeout becomes `failed`; provider work is not automatically retried. If a search stays `queued`, check that the worker is running with the same Redis connection and queue as the API. `/health` checks Redis, not worker availability. ## Track states are different [#track-states-are-different] The document and each claim use `pending`, `running`, `done`, or `failed`. A claim with `searched: false` can remain `pending` when the overall search is complete. This means the claim was identified but not searched under the current claim cap. Track `scores` are keyed by source ID and reflect that track's ranking. Prefer them to `Source.score` when a source occurs in more than one track. ## Poll without creating new work [#poll-without-creating-new-work] GET reads stored results and does not call search providers again, and polling never costs credits. Use a bounded polling loop; the quickstart uses two seconds as an example interval, not a documented rate entitlement. If you lose a create response, the current API has no implemented idempotency-key protection. Repeating POST may start another search. Planned idempotency and rate controls will be documented when implemented. ## Retention [#retention] Searches are shared in Redis. Completed and failed results are retained for **one hour from completion** by default. GET does not extend retention. Different API processes using the same Redis namespace can read them, including after an API restart. Queued records have a one-hour TTL, reset when execution is claimed. Queued work survives an API restart. Worker failure callbacks record a failed outcome when Redis is reachable, but loss of the whole worker or Redis can leave a running record until this window expires; automatic recovery is not implemented. Late writes cannot restore expired or deleted records. Expired, deleted or lost IDs return `404 job_not_found`; no tombstone or public `expires_at` field is implemented yet. Redis outages return `503 cache_unavailable`. A cache miss never restarts the search. Retention is configurable by the deployment; these durations describe the current defaults. # MCP server (/docs/mcp) The Sourcely MCP server lets an AI assistant find, check and format citations for you. Ask for sources for a paragraph, and the assistant runs a search, waits for the result and cites what comes back. [MCP](https://modelcontextprotocol.io) (Model Context Protocol) is the standard that assistants use to connect to tools. The MCP server is a client of this API: it sends the same requests you would, on behalf of your Sourcely account. The hosted server's address is: ```text title="MCP endpoint" https://mcp.sourcely.net/mcp ``` It uses the Streamable HTTP transport. You don't install anything to use it. ## What you can do [#what-you-can-do] Ask in your own words, and the assistant picks the right tool. | You want to | Try asking | | -------------------------------------- | ------------------------------------------------------------------------- | | Find sources for a topic or a question | "Find academic sources on how urban green spaces affect mental health" | | Add citations to a draft | "Find academic sources for every claim in my draft and add APA citations" | | Narrow a search | "Only randomized controlled trials published since 2020" | | Check a reference list | "Check whether the citations in my reference list are real" | | Look up or format one paper | "Give me a Chicago citation for the paper with DOI 10.1038/171737a0" | For common jobs such as citing a draft or writing a literature review, the server also offers [ready-made tasks](#ready-made-tasks). See [Tools](#tools) for everything the assistant can call. ## Sign in [#sign-in] The hosted MCP server is included with Sourcely **Pro, Ultra and Max** subscriptions; it does not use your prepaid credits. See [Plan and limits](#plan-and-limits). The server never uses a key of its own, so each assistant connects in one of two ways: | Way | Used by | How | | ----------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | | Sign in with Sourcely (OAuth) | ChatGPT, Claude (claude.ai, Desktop and mobile), Claude Code | The assistant opens the Sourcely sign-in page. You sign in and approve access. No key to copy. | | API key | Cursor, Claude Code, other clients | Send a dashboard key on every request: `Authorization: Bearer srcly_your_key`. See [API keys & access](/docs/authentication). | When an assistant connects with sign-in, a key named **MCP connector (OAuth)** appears in your dashboard's API keys list, with its own requests. Revoke that key to disconnect the assistant at once. Connecting again later creates a new one. The server passes your credentials on to the API and never stores them. A request without credentials gets a tool error, and no search runs. ## ChatGPT [#chatgpt] 1. In ChatGPT on the web, open **Plugins**. 2. Select the **+** button, then **Add custom MCP server**. 3. Fill in the form: * **Name:** `Sourcely` * **Description** (optional): `Find academic sources for a text` * **Connection:** `https://mcp.sourcely.net/mcp` * **Authentication:** OAuth 4. Review the risk warning, select **I understand and want to continue**, then select **Create as a plugin**. 5. ChatGPT opens the Sourcely sign-in page. Sign in and approve access. ChatGPT then lists the server's 9 tools. 6. Install the plugin. In a new chat, type **@**, choose **Sourcely** and ask it to find sources for your text. ChatGPT may ask you to confirm before it runs a tool that creates or deletes a search. Because sign-in includes offline access, ChatGPT renews its access on its own; you don't sign in again every day. According to OpenAI, custom MCP servers are available on ChatGPT Business and Enterprise/Edu, on the web only. On a Business workspace, only admins and owners can add them. On Enterprise/Edu, admins can allow other members. If you don't see **Plugins**, your account may still use the older flow: **Settings → Apps → Create**, then enter the same URL, choose OAuth and select **Scan Tools**. ## Claude [#claude] Claude on the web, in the desktop app and on mobile uses the same connectors. 1. In Claude, open **Settings → Connectors** and select **Add custom connector**. 2. Enter `https://mcp.sourcely.net/mcp` as the URL, exactly as written, with no trailing slash. 3. If Claude asks how to register its OAuth client, choose **Register automatically**. 4. Add the connector, then select **Connect**. Claude opens the Sourcely sign-in page. Sign in and approve access. 5. In a chat, turn on **Sourcely** in the tools menu and ask Claude to find sources for your text. Custom connectors work on Claude Free (one connector), Pro and Max. On Team and Enterprise, an owner adds the connector once, and each member then connects with their own Sourcely account. ## Claude Code [#claude-code] Add the server, then sign in: ```bash title="Terminal" claude mcp add --transport http sourcely https://mcp.sourcely.net/mcp ``` Run `/mcp` inside Claude Code, select `sourcely`, then **Authenticate**. Your browser opens the Sourcely sign-in page. To use an API key instead, pass it as a header: ```bash title="Terminal" claude mcp add --transport http sourcely https://mcp.sourcely.net/mcp --header "Authorization: Bearer srcly_your_key" ``` ## Cursor [#cursor] Cursor connects to the hosted server directly and sends your key as a header. 1. Open `~/.cursor/mcp.json`, or create it. A server added there is available in every project. To add it to one project only, use `.cursor/mcp.json` in that project instead, and keep the key out of version control. 2. Add the server: ```json title="~/.cursor/mcp.json" { "mcpServers": { "sourcely": { "url": "https://mcp.sourcely.net/mcp", "headers": { "Authorization": "Bearer ${env:SOURCELY_API_KEY}" } } } } ``` `${env:SOURCELY_API_KEY}` reads the key from the environment. Cursor must be able to see that variable: on macOS, an app opened from the Dock doesn't get the variables set in your shell profile, so start Cursor from a terminal where `SOURCELY_API_KEY` is set. You can also write the key in place, as `"Bearer srcly_your_key"`. 3. Restart Cursor, then open Cursor Settings → **Tools & MCP**. `sourcely` should be listed with a green status dot and its 9 tools. 4. In the agent chat, ask it to find sources. Cursor asks before running each tool, unless you allow it to run them automatically. A red dot or a **401** error usually means the header is wrong or empty. Check that it starts with `Bearer ` (with a space) and that the variable is set. ## Other clients [#other-clients] Any MCP client that connects over Streamable HTTP works, such as VS Code, Windsurf or your own agent. Use `https://mcp.sourcely.net/mcp` as the URL, and either send the `Authorization` header with an API key or let the client sign in with OAuth if it supports it. ## Ready-made tasks [#ready-made-tasks] The server also lists ready-made tasks, known in MCP as prompts (`prompts/list`). Each one tells the assistant which tools to call and how to lay out the reply, so you get the same result every time. To run one, pick it from your assistant's prompts menu. In Claude, that is the **+** menu of a chat; in Claude Code, type `/`. If your assistant has no such menu, which may be the case in ChatGPT, ask for the task in your own words: the tools are the same, but the reply layout is up to the assistant. | Prompt | Arguments | Reply | | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Cite my draft** (`cite_my_draft`) | `text` (optional; otherwise the draft pasted in the chat), `citation_style` (`apa`, `mla`, `chicago`, `harvard`, `ieee`, `bibtex`, or any CSL style id; default `apa`), `sources_per_claim` (1 to 3) | The draft with an inline citation after each supported claim, a reference list, and the claims that got no source | | **Literature review** (`literature_review`) | `topic`, `year_from`, `depth` (`quick`, or `deep`, which uses one of the plan's deep searches), `max_sources` (default 15) | An overview, three to five themed sections with citations, a table of sources, gaps and disagreements, references | | **Fact-check a claim** (`fact_check_claim`) | `claim` | A verdict (Supported, Contested, Unsupported, No evidence found), supporting and contrasting evidence quotes with citations, a confidence line | | **Related work section** (`related_work`) | `abstract_or_intro` (optional), `format` (`prose` or `latex`), `max_sources` (default 12) | A related-work section; in LaTeX with `\cite{}` keys and a BibTeX block. Useful in code editors | | **Annotated bibliography** (`annotated_bibliography`) | `topic`, `count` (default 10), `citation_style` | Entries in the chosen style, each with a three to five sentence annotation from the source's analysis | | **Verify references** (`verify_references`) | `references` (optional; otherwise the list pasted in the chat), `citation_style` for corrected entries | One `verify_citation` call per entry, no search; a table with each entry's status (Verified, Mismatch, Not found, Invalid DOI), what differs and the corrected entry copied from the record, then a summary count | Every prompt except Verify references runs as a quick search unless `depth: deep` is chosen, so it is included in the plan (or uses one of the free searches). Verify references is free: it only checks entries against the registries. ## Tools [#tools] The server has 9 tools. The citation tools are free and run no search. ### Search [#search] | Tool | What it does | API request | | ---------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | `find_sources` | Starts a search and waits for the result. | [Create search](/docs/api/create_search), then [get search](/docs/api/get_search) | | `get_search_results` | Reads an earlier search. Can include the full text where available. | [Get search](/docs/api/get_search) | | `load_more_sources` | Adds the next page of document sources. | `POST /search/{job_id}/next-page` | | `refine_claim_sources` | Searches one claim, gets more sources for it, or searches it again with feedback. | `POST /search/{job_id}/claims/{claim_id}` | | `delete_search` | Deletes a search and its stored text and results. | `DELETE /search/{job_id}` | ### Citations [#citations] | Tool | What it does | API request | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- | | `verify_citation` | Checks that a reference or DOI names a real paper and that its title, authors, year and venue match the record; returns the record with formatted citations. No search is run. | [Verify a reference](/docs/api/verify) | | `get_paper_by_doi` | The registry record for a DOI, with formatted citations, without a search. | [Get a paper by DOI](/docs/api/get_paper) | | `format_citation` | APA 7, MLA 9, IEEE, Harvard, BibTeX or any of 750+ CSL styles from a DOI (looked up) or from supplied metadata (as given). | [Format a citation](/docs/api/format_citation) | | `list_citation_styles` | Finds the id of a citation style (Chicago, Vancouver, Nature, a journal's house style) to pass in `citation_formats`. | [Citation styles](/docs/api/citation_styles) | ### find\_sources arguments [#find_sources-arguments] `find_sources` takes the create search options as arguments: `text`, `mode`, `enrichment`, `granularity`, `max_claims` and `citation_formats`. The filters are separate arguments too: `year_from`, `year_to`, `min_citations`, `open_access`, `paper_types`, `venue`, `include_keywords` and `exclude_keywords`. The meanings are the same as in [create search](/docs/api/create_search), with one MCP default: when `enrichment` is omitted, the search reads each source (`high`), as the Sourcely app's quick search does for paid plans. In quick mode that means a language model opens the source's landing page and PDF itself and quotes from the body, with the relevance rating, analysis and three to five evidence quotes per source; a 20-source page takes about 20 seconds. Pass `medium` for the app's free-tier read (the paper is opened, rating and analysis returned, no quotes; about 5 seconds for 20 sources), `low` for an abstract-only analysis with quotes from the abstract, or `none` for plain metadata. ## Results [#results] Each tool returns the search as JSON with `job_id`, `status`, `usage` and a `next_steps` hint for the assistant. Unlike get search, tracks list their sources inline, in rank order, instead of by source ID: ```json title="Example find_sources result" { "job_id": "src_example", "status": "completed", "document": { "status": "done", "page": 1, "has_more": true, "sources": [ { "rank": 1, "source_id": "s_1", "title": "Urban green space and mental health", "authors": ["Ada Lovelace"], "year": 2021, "url": "https://example.com/paper", "citation_count": 42, "score": 0.91, "citations": { "apa7": "Lovelace, A. (2021). Urban green space and mental health." }, "enrichment": { "relevance": "Relevant", "analysis": "…", "paper_type": ["peer_reviewed"] } } ] }, "usage": { "currency": "USD", "estimated_cost": 0, "actual_cost": 0, "discount_percent": 0 }, "next_steps": "Search finished with 20 document sources, listed in the order returned. … Optional: load_more_sources fetches the next page of document sources." } ``` Empty fields are left out, and a source whose authors, year, venue, url or citation count is unknown names those fields in a `missing` list, so the assistant says "not available" instead of filling the blank from memory. `paper_type` lists only the flags that are true. ### How results are presented [#how-results-are-presented] The server tells the assistant, in its instructions and in every result's `next_steps`, to copy each formatted citation verbatim and to keep title, authors, year, venue and url as returned: no shortened author lists, no changed years, no DOI that is not in the result. If an analysis disagrees with the metadata fields, the assistant cites from the fields and tells you about the difference. It labels the relevance rating and analysis as Sourcely's, and reminds you to check quotes against the papers before relying on them. A `doi` is present only when a registry supplied one; to find one, or to check an entry the assistant wrote from memory, the instructions send it to `verify_citation` (one call per reference) instead of recalling a DOI. An assistant that needs another style should call the tool again with it in `citation_formats` rather than convert by hand. If you build on the [API](/docs/api/create_search) directly, apply the same rules in your own prompts: render `citations` as given, treat `null` fields as unknown, and refer to sources by `id` and `url`. Full text, from `enrichment: "high"` in deep mode, appears as `full_text_available: true` (in quick mode the model reads the source itself and nothing is stored, so the flag stays false). Call `get_search_results` with `include_full_text: true` to get it, up to 20,000 characters per source. ## Waiting [#waiting] `find_sources`, `load_more_sources`, `refine_claim_sources` and `get_search_results` check the search every 3 seconds. They return when it is `completed` or `failed`, or when `wait_seconds` runs out. The default is 60 seconds, enough for a quick search, because some clients stop a tool call after about a minute; `wait_seconds` can raise it to 120. While they wait, each poll forwards the search's current step as an MCP progress notification, for clients that show one. If the search is still running when the wait ends, the result has its `job_id`, current `status` and `progress` (the stage, a message such as "Analyzing source 12 of 26", and counts), and `next_steps` tells the assistant to say what the search is doing and call `get_search_results` again. See [search states](/docs/lifecycle). ## Errors [#errors] API errors come back as tool errors that name the HTTP status and error `code`, so the assistant can explain them. See [errors](/docs/errors). | Error | What the assistant is told | | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | **401** `invalid_api_key` | The API key is wrong or revoked, or the connector's sign-in was revoked. Check the key, or reconnect the assistant. | | **403** `subscription_required` | The account does not include this. Tell the user and do not retry. Deep searches without a plan fail this way. | | **402** `free_limit_reached` | The account has reached its search limit. Tell the user and do not retry. Includes `used` and `limit`. | | **402** `free_tier_limited` | Free searches from this network are limited for now (too many searches or accounts from one address). Tell the user and do not retry. | | **402** `deep_search_limit_reached` | Tell the user the plan's deep searches are used up for this cycle, and offer a quick search. Includes `used`, `limit` and `resets_at`. | | **404** `job_not_found` | The search expired or was deleted. | | **404** `paper_not_found` | The DOI does not resolve. Tell the user, and do not guess another DOI. | | **409** `search_not_ready` | Wait until the search finishes, then try again. | | **429** `rate_limit_exceeded` | Retry after the `Retry-After` delay. | | **503** `registry_unavailable` | Crossref and Semantic Scholar did not answer. Tell the user and try once more in a minute. | Invalid arguments, such as `max_claims: 99`, are rejected before any request reaches the API. ## Plan and limits [#plan-and-limits] The hosted server at `mcp.sourcely.net` is included with Sourcely Pro, Ultra and Max. Searches through it are not charged to your prepaid credits, and their `usage` shows a cost of 0. | Search | Limit | | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | Quick (`mode: "quick"`, the default) | Included, subject to the normal rate limits | | Deep (`mode: "deep"`, or a deep claim refetch) | Uses one of your plan's deep searches, the same monthly allowance as the Sourcely app: 10 on Pro, 30 on Ultra, 1,000 on Max | The deep search allowance resets every 30 days, on the same date as in the app. When it runs out, deep searches through the MCP fail with `deep_search_limit_reached` until the reset, and quick searches keep working. ### Without a plan [#without-a-plan] An account without a plan gets **5 free searches** through the hosted MCP server, once per account (not monthly). They run as quick searches at the free-tier read: each paper is opened for its relevance rating, analysis and paper type, without quotes. A free search's `usage` carries `free_searches_remaining` and `free_searches_limit`. `load_more_sources` on an existing search is not counted; `refine_claim_sources` runs a new search and is. After the fifth search, `find_sources` fails with `free_limit_reached`; deep searches without a plan fail with `subscription_required`. Free searches are also limited per network address (a few an hour, and a few accounts a day from one address); past that, `find_sources` fails with `free_tier_limited`. Subscribing removes all of these limits. Calling the API directly, or running the MCP server yourself, still uses prepaid credits as described in [Credits and pricing](/docs/billing). The server tells the assistant to prefer quick searches and one well-scoped search over many small ones. ## Run it yourself [#run-it-yourself] You can also run the server on your own machine, for example against a local API. It lives in the repository's `mcp_server/` folder and needs Python 3.10 or newer: ```bash title="Terminal" cd mcp_server python3 -m venv .venv .venv/bin/pip install -e . ``` Run locally, it uses the stdio transport: your client starts the server and the key comes from `SOURCELY_API_KEY`. For Claude Code: ```bash title="Terminal" claude mcp add sourcely --env SOURCELY_API_URL=http://localhost:8000 --env SOURCELY_API_KEY=srcly_your_key -- /absolute/path/to/mcp_server/.venv/bin/sourcely-mcp ``` `sourcely-mcp --transport http` serves the same tools over HTTP at `/mcp`, the way `mcp.sourcely.net` does. Over HTTP the server ignores its own `SOURCELY_API_KEY` by default, so a shared server never spends one account's balance on another user's request. The repository's `mcp_server/README.md` covers deploying it, and `mcp_server/OAUTH.md` covers turning on sign-in with `MCP_OAUTH_ENABLED`. | Variable | Default | Purpose | | -------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------- | | `SOURCELY_API_URL` | `https://api.sourcely.net` | The API base URL. | | `SOURCELY_API_KEY` | none | The key for stdio, and for HTTP when `MCP_ALLOW_SERVER_API_KEY=1`. | | `MCP_TRANSPORT` | `stdio` | `stdio` or `http`. Same as `--transport`. | | `MCP_HOST`, `MCP_PORT` | `127.0.0.1`, `8001` | HTTP address. `PORT` overrides `MCP_PORT`. | | `MCP_ALLOWED_HOSTS` | none | Comma-separated public hostnames allowed in the `Host` header. Setting it turns the Host and Origin checks on. | | `MCP_ALLOWED_ORIGINS` | none | Comma-separated browser origins allowed when the checks are on. | | `MCP_ALLOW_SERVER_API_KEY` | `0` | `1` lets HTTP requests without a key use `SOURCELY_API_KEY`. | # Plans and access (/docs/plans_and_access) ## Get started in three steps [#get-started-in-three-steps] 1. **Sign in** to Sourcely and open **API and MCP** in the left sidebar. 2. **Add credits.** The minimum top-up is $20. You can also turn on automatic top-ups. See [Credits and pricing](/docs/billing). 3. **Create an API key** and use it from your application's server, as shown in [Get started](/docs/quickstart). The same page shows your balance, your price per request, usage per key and your payment history. ## Who can use the API [#who-can-use-the-api] Anyone with a Sourcely account and credits can use the API. A subscription is not required, but it lowers the price of every request: | Subscription | Discount on every request | | ------------ | ------------------------- | | None | 0% | | Pro | 15% | | Ultra | 35% | | Max | 50% | The discount comes from the subscription on the account that owns the key, and is shown as `usage.discount_percent` on every response. ## What you pay for [#what-you-pay-for] Each search has a USD cost based on its options and the sources it returns. Retrieving results is free, and a failed search costs nothing. See the [price list](/docs/billing#price-list) and [How search works](/docs/how_search_works) for what each mode does. ## Access details [#access-details] * [API keys and access](/docs/authentication): key handling, ownership and rate limits. * [Credits and pricing](/docs/billing): top-ups, automatic top-ups, discounts and the balance check. * [Preview availability](/docs/availability): implemented features and remaining launch work. # Get started (/docs/quickstart) In Sourcely, open **API and MCP**, add credits, and create an API key. Save it as the `SOURCELY_API_KEY` environment variable. These examples run real searches against `https://api.sourcely.net` and use your credits ([Credits and pricing](/docs/billing)). ## 1. Create a search [#1-create-a-search] Send your text with explicit options. `enrichment: "none"` skips analysis and `citation_formats: []` skips citation formatting, which keeps the first search fast and cheap. ```bash title="Terminal" curl -X POST https://api.sourcely.net/search \ -H "Authorization: Bearer $SOURCELY_API_KEY" \ -H 'Content-Type: application/json' \ --data '{"text":"How do urban green spaces affect mental health?","mode":"quick","enrichment":"none","granularity":["document"],"citation_formats":[]}' ``` The API answers **202 Accepted** with a `job_id` and the status `queued`. The search runs in the background; you read the result in the next step. ```json title="Example acceptance response" { "job_id": "src_example", "status": "queued" } ``` ## 2. Get the results [#2-get-the-results] Request the search by its `job_id` (not a source ID): ```bash title="Terminal" curl https://api.sourcely.net/search/src_example \ -H "Authorization: Bearer $SOURCELY_API_KEY" ``` Replace `src_example` with your `job_id`. Repeat the request until `status` is `completed` or `failed`. A 200 response can still describe a failed search, so always check `status` ([search states](/docs/lifecycle)). ## 3. Put it together [#3-put-it-together] This script creates a search, polls until it finishes, and prints each source. Details live in the `sources` map; `document.source_ids` gives their order. Python JavaScript ```python title="Requires httpx" import os import time import httpx api_base_url = "https://api.sourcely.net" api_key = os.environ["SOURCELY_API_KEY"] headers = {"Authorization": f"Bearer {api_key}"} search_request = { "text": "How do urban green spaces affect mental health?", "mode": "quick", "enrichment": "none", "citation_formats": [], } with httpx.Client(timeout=180) as client: response = client.post(f"{api_base_url}/search", headers=headers, json=search_request) response.raise_for_status() job_id = response.json()["job_id"] for attempt in range(60): response = client.get(f"{api_base_url}/search/{job_id}", headers=headers) response.raise_for_status() search_result = response.json() if search_result["status"] == "failed": raise RuntimeError("Search failed; inspect the error guide.") if search_result["status"] == "completed": break time.sleep(2) else: raise TimeoutError(f"Search still pending; keep job_id {job_id}") document = search_result.get("document") or {} for source_id in document.get("source_ids", []): source = search_result["sources"][source_id] print(source["title"], source["url"]) ``` ```js title="Server-side · Node.js 18+ (ES module)" const api_base_url = 'https://api.sourcely.net'; const api_key = process.env.SOURCELY_API_KEY; async function read_json(response) { if (!response.ok) throw new Error(`HTTP ${response.status}`); return response.json(); } const accepted = await read_json(await fetch(`${api_base_url}/search`, { method: 'POST', headers: { Authorization: `Bearer ${api_key}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ text: 'How do urban green spaces affect mental health?', mode: 'quick', enrichment: 'none', citation_formats: [], }), signal: AbortSignal.timeout(180_000), })); let search_result; for (let attempt = 0; attempt < 60; attempt++) { search_result = await read_json(await fetch( `${api_base_url}/search/${encodeURIComponent(accepted.job_id)}`, { headers: { Authorization: `Bearer ${api_key}` }, signal: AbortSignal.timeout(30_000), }, )); if (search_result.status === 'failed') throw new Error('Search failed'); if (search_result.status === 'completed') break; await new Promise(resolve => setTimeout(resolve, 2_000)); } if (search_result.status !== 'completed') { throw new Error(`Search still pending; keep job_id ${accepted.job_id}`); } for (const source_id of search_result.document?.source_ids ?? []) { const source = search_result.sources[source_id]; console.log(source.title, source.url); } ``` The timeouts and the 2-second polling interval are example client limits, not service guarantees. A client timeout does not mean the search failed: keep the `job_id` and check it again. Creating a search is not idempotent, so don't retry a timed-out `POST` blindly. # Enums (/docs/reference/enums) {/* Generated by npm run docs:sync. Edit scripts/schema_notes.mjs for explanations. */} Values are case-sensitive. Send and compare these exact strings. Field names use snake\_case. The current `RelevanceRating` values are human-readable labels with spaces; a future naming change must be versioned and is not applied to these examples. ## EnrichmentLevel [#enrichmentlevel] | Value | Meaning | | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `none` | Return source metadata and requested citations without analysis. | | `low` | Analyze the title and abstract: relevance rating, a short analysis, evidence quoted from the abstract, paper type. No page is opened. | | `medium` | Read the paper without quoting it, as the Sourcely app does for free accounts: a language model opens the source landing page and PDF and returns the rating, analysis and paper type; evidence is always an empty list. Falls back to abstract analysis when the paper cannot be read. | | `high` | Read the paper. In quick mode a language model opens the source landing page and PDF itself and quotes from the body, keeping the provider order. In deep mode the source is scraped, analyzed in full and reranked. Falls back to abstract analysis when the paper cannot be read. | ## FieldCheck [#fieldcheck] | Value | Meaning | | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `match` | The reference states this field as the registry record does. | | `mismatch` | The reference states this field differently from the registry record. | | `unverified` | The reference or the registry does not state this field, so nothing was compared. Venue is reported as unverified rather than mismatch when it does not match. | ## Granularity [#granularity] | Value | Meaning | | ---------- | --------------------------------------------------------- | | `document` | Find sources for the complete input. | | `claim` | Identify claims and find sources for the selected claims. | ## JobStatus [#jobstatus] | Value | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `queued` | Accepted and waiting to start. | | `running` | Search work is in progress. | | `partial` | Some results may be usable while other requested work remains. Tracks are published together when the search finishes; while it runs, progress reports the current step. | | `completed` | The search finished. Inspect tracks and searched flags for per-claim coverage. | | `failed` | The search failed. HTTP 200 on a status read does not imply search success. | ## PaperTypeFilter [#papertypefilter] | Value | Meaning | | ---------- | ------------------------------------------------- | | `research` | Research papers. | | `review` | Review papers and related review classifications. | ## ProgressStage [#progressstage] | Value | Meaning | | ----------------- | ------------------------------------------------------------------------ | | `preparing` | Reading the text and working out what to look for. | | `searching` | Querying the academic databases. | | `shortlisting` | Choosing the most promising candidates to read in full (deep mode only). | | `analyzing` | Analyzing each source against the text; done and total count sources. | | `reranking` | Ordering the analyzed sources (deep mode and high enrichment only). | | `sourcing_claims` | Finding sources for each identified claim; done and total count claims. | ## RelevanceRating [#relevancerating] | Value | Meaning | | -------------------- | --------------------------------------------- | | `Perfectly Relevant` | Strongest relevance label. | | `Relevant` | Relevant to the research text. | | `Somewhat Relevant` | Partially relevant to the research text. | | `Not Relevant` | Not considered relevant to the research text. | ## SearchMode [#searchmode] | Value | Meaning | | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `quick` | One Google Scholar page per keyword, Semantic Scholar as fallback, provider order kept. | | `deep` | Wide retrieval from Semantic Scholar and three Scholar pages per keyword, a model-chosen shortlist of 15, full-text analysis and a final rerank. | ## TrackStatus [#trackstatus] | Value | Meaning | | --------- | ----------------------------------------------------------------- | | `pending` | This track has not started; an unsearched claim may stay pending. | | `running` | Work on this track is in progress. | | `done` | This track finished. | | `failed` | This track failed; inspect its error when available. | ## VerifyStatus [#verifystatus] | Value | Meaning | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `verified` | The reference names a real paper and no checked field disagrees with the registry record. | | `mismatch` | A real paper was found, but the title, authors or year in the reference differ from the record. The message names the fields; source holds the record to use. | | `not_found` | No registry has a paper with this title. The reference may be invented, or the title may be wrong. | | `invalid_doi` | The DOI does not resolve in Crossref or Semantic Scholar, or the value is not a DOI. source may still hold the paper the reference title matches, with its real DOI. | Webhook events belong to a later release and are not part of these two endpoints. # Response & request models (/docs/reference/models) {/* Generated by npm run docs:sync. Edit scripts/schema_notes.mjs for explanations. */} A required field must be present. An optional field may be omitted. A type containing `null` also accepts a null value. The server currently serializes optional response fields as null rather than removing them. Resolve entries in `document.source_ids` and `claims[].source_ids` through the top-level `sources` map. Scores are relative ranks, not confidence percentages. See [all enum values](/docs/reference/enums) for the exact tokens referenced below. `balance_after` stays null. A `webhook_url` receives a POST when the search finishes; see [Webhooks](/docs/webhooks). ## SearchRequest [#searchrequest] | Field | Type | Presence / default | Meaning | | ------------------ | ------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `text` | `string` | Required | The text to find academic sources for. At least one character; there is no maximum length. Whitespace-only input is currently accepted by validation. Minimum length: 1. | | `mode` | `SearchMode` | Optional; default: `"quick"` | Search depth. quick fetches one Google Scholar page per generated keyword, falling back to Semantic Scholar, and keeps the provider order. deep fetches Semantic Scholar plus three Scholar pages per keyword, has a language model shortlist the 15 most promising sources, reads each one, and ranks them again with the analysis in hand. deep takes minutes rather than seconds. | | `enrichment` | `EnrichmentLevel \| null` | Optional | Analysis level, independent of search depth. Omitted or null means medium for quick and high for deep. | | `granularity` | `array` | Optional | Result tracks to produce. Defaults to \["document"]. Use \["claim"] or \["document", "claim"] for claim-level results. An empty list currently falls back to document. | | `max_claims` | `integer \| null` | Optional | Maximum identified claims to search, from 1 to 12. Omitted or null: scales with the length of the text as in the Sourcely app, from 1 for a sentence to every identified claim (up to 12) at 880 characters or more. Only applies when the claim track is requested. | | `citation_formats` | `array \| null` | Optional | Citation styles to populate: apa7, mla9, ieee, harvard, bibtex, or any CSL style id from GET /citations/styles (chicago-author-date, vancouver, nature, a journal house style). At most 10 per request. Omitted or null selects the five original styles; an empty array disables citations. The five original styles have their own fields in citations; every other style lands in citations.styles under its id. | | `filters` | `Filters \| null` | Optional | Optional constraints on source selection. Omit or use null for no additional filtering. | | `webhook_url` | `string \| null` | Optional | Optional http(s) URL. When set, the API POSTs the finished search here. The host must be public unless the deployment allows private URLs. Polling still works. | ## Filters [#filters] | Field | Type | Presence / default | Meaning | | ------------------- | -------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `year_from` | `integer \| null` | Optional | Inclusive lower publication-year bound. For example, 2020 keeps papers from 2020 onward. Papers without a known year are excluded when this is set. Omit or use null for no lower bound; use year\_from \<= year\_to when both are set. | | `year_to` | `integer \| null` | Optional | Inclusive upper publication-year bound. For example, 2024 keeps papers published in 2024 or earlier. Papers without a known year are excluded when this is set. Omit or use null for no upper bound. The current API does not validate year-range ordering. | | `min_citations` | `integer \| null` | Optional | Minimum citation count, inclusive, as an integer >= 0. For example, 10 keeps sources with at least 10 citations. An unknown citation count is treated as zero for filtering, so it passes a threshold of 0 but not a positive threshold. Omit or use null to disable this filter. | | `open_access` | `boolean \| null` | Optional | When true, require a non-empty pdf\_url in the available source metadata. This is a PDF-availability check, not verification of licensing or download access. false, null or omission disables the filter; false does not mean closed-access only. | | `paper_types` | `array \| null` | Optional | Optional array of exact enum values: research and review. \["review"] keeps sources identified as reviews by a metadata-text heuristic; \["research"] excludes those sources. Both values disable this local distinction, but upstream providers can still favor reviews when review is included. Omit, use null or \[] to avoid a paper-type restriction. This filter is not a peer-review guarantee. | | `venue` | `string \| null` | Optional | Optional journal or publication-venue name, such as Nature. Forwarded to Semantic Scholar and Scholar URL-based providers; the current Serper adapter does not forward it. No exact venue check is applied after retrieval, so matching depends on the provider and unrelated venues can appear. Omit, use null or an empty string to disable the venue hint. | | `include_keywords` | `array \| null` | Optional | Optional array of strings that must all occur in the combined title, abstract and venue metadata. Local matching uses case-insensitive substrings, not whole words or full-paper text. For example, \["sleep", "memory"] requires both. Scholar providers also receive each entry as a required quoted phrase added to the query, which can narrow retrieval further. Omit, use null or \[] to disable. Entries are trimmed and empty ones ignored. | | `exclude_keywords` | `array \| null` | Optional | Optional array of strings: exclude a source if any occurs in its title, abstract or venue metadata. Local matching uses case-insensitive substrings. For example, \["mouse", "rat"] excludes either match, including rat inside another word. Omit, use null or \[] to disable. Do not include an empty string, because it matches every source. This does not inspect full-paper text. | | `include_domains` | `array \| null` | Optional | Optional array of host names. Only sources whose url or pdf\_url is on one of these domains, or a subdomain, are returned. For example, \["ncbi.nlm.nih.gov"] also matches pubmed.ncbi.nlm.nih.gov. Entries may be given as bare hosts or full URLs; scheme, [www](http://www). and paths are ignored. Scholar providers receive matching site: operators as well. Sources without a URL are excluded when this is set. Omit, use null or \[] to disable. | | `exclude_domains` | `array \| null` | Optional | Optional array of host names. Any source whose url or pdf\_url is on one of these domains, or a subdomain, is dropped. For example, \["wikipedia.org"] removes en.wikipedia.org results. Entries are normalized like include\_domains. Scholar providers receive matching -site: operators as well. Omit, use null or \[] to disable. | | `preferred_domains` | `array \| null` | Optional | Optional array of host names, most preferred first. Sources on these domains, or their subdomains, are moved ahead of other results; earlier entries rank ahead of later ones, and provider order is kept within each group. Other domains still appear. Omit, use null or \[] to keep the provider ranking only. | ## JobAccepted [#jobaccepted] | Field | Type | Presence / default | Meaning | | -------- | --------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `job_id` | `string` | Required | Opaque search identifier. Save it and pass it unchanged to GET /search/\{job\_id}. | | `status` | `JobStatus` | Optional; default: `"queued"` | Search state at acceptance. POST /search returns queued; GET /search/\{job\_id} provides the latest state. | | `usage` | `Usage \| null` | Optional | USD quote for this search. estimated\_cost is the maximum charge for the requested options. actual\_cost is null until the search finishes. balance\_after stays null; the dashboard holds the balance. | ## SearchResult [#searchresult] | Field | Type | Presence / default | Meaning | | ------------- | ------------------------ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `job_id` | `string` | Required | The same opaque search identifier returned by creation. | | `status` | `JobStatus` | Required | Overall job state. Inspect this even when the HTTP response is 200. | | `result_type` | `string` | Optional; default: `"search"` | Response discriminator; currently "search". | | `progress` | `SearchProgress \| null` | Optional | Current step while status is running, or null once the search has finished or before it starts. Poll GET /search/\{job\_id} to follow it. | | `document` | `DocumentTrack \| null` | Optional | Document-level result track, or null when not requested or not available. | | `claims` | `array \| null` | Optional | Identified claims and their results, or null when the claim track was not requested or is unavailable. | | `sources` | `map` | Optional | Source objects indexed by source ID. Resolve each document.source\_ids or claim.source\_ids entry in this map. | | `usage` | `Usage \| null` | Optional | USD quote and charge for this search. estimated\_cost is set when the search is created. actual\_cost is null while it is running, the calculated charge when it completes, and zero when it fails. balance\_after stays null; the dashboard holds the balance. | | `metadata` | `SearchMetadata \| null` | Optional | Requested and actual claim-search counts, when available. | ## SearchProgress [#searchprogress] | Field | Type | Presence / default | Meaning | | ------------ | ----------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `stage` | `ProgressStage` | Required | The stage the search is in. Stages happen in the order listed in the ProgressStage enum; a search skips the stages its options do not need. | | `message` | `string` | Required | One line describing the current step, written to be shown to the person waiting, such as "Analyzing source 12 of 26". The wording can change between releases; branch on stage, not on this text. | | `done` | `integer \| null` | Optional | Items finished in this stage, when the stage counts them (analyzing sources, sourcing claims). Null otherwise. | | `total` | `integer \| null` | Optional | Items in this stage, when the stage counts them. Null otherwise. | | `updated_at` | `string` | Required | When this step was recorded, as an ISO 8601 timestamp in UTC. | ## DocumentTrack [#documenttrack] | Field | Type | Presence / default | Meaning | | ---------------- | --------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `source_ids` | `array` | Optional | Ordered source IDs for this document. Resolve each ID in the top-level sources map. | | `scores` | `map` | Optional | Rank scores keyed by source ID for this document context. Larger values rank higher; these are not confidence percentages. | | `search_queries` | `array` | Optional | The search phrases sent to the academic providers for this document, most relevant first. They are written from the submitted text by a language model, two for most texts and three past 3000 characters, and reused for later pages. Empty until the track has run. | | `page` | `integer` | Optional; default: `1` | Latest page fetched for this track, initially 1. A page is one provider results page of up to 10 sources for every search query, in query order, so a document page holds up to 20 sources, or 30 for texts over 3000 characters. Additional-page endpoints are outside the initial public surface. | | `has_more` | `boolean` | Optional; default: `false` | True when at least one search query filled its latest provider page, so another page may exist. It is not a guarantee or an initial-release pagination capability. | | `status` | `TrackStatus` | Optional; default: `"pending"` | State of this result track, distinct from overall job status. | ## Claim [#claim] | Field | Type | Presence / default | Meaning | | -------------- | --------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | `string` | Required | Identifier for this claim within the search. | | `span` | `string` | Required | The identified claim text from the input. | | `search_query` | `string \| null` | Optional | The search phrase written from the span, with pronouns and references resolved from the surrounding text, that was sent to the providers. Null until the claim is searched. | | `searched` | `boolean` | Required | Whether a source search was attempted for this claim. Claims beyond max\_claims can be returned with false. | | `source_ids` | `array` | Optional | Ordered IDs pointing into the top-level sources map. | | `scores` | `map` | Optional | Per-claim rank scores keyed by source ID; not probabilities. | | `page` | `integer` | Optional; default: `1` | Latest page fetched for this claim; initially 1. | | `has_more` | `boolean` | Optional; default: `false` | Heuristic indication of additional potential results. Claim refetch is deferred. | | `status` | `TrackStatus` | Optional; default: `"pending"` | State of the claim track. Unsearched claims may remain pending after the job completes. | | `error` | `ErrorDetail \| null` | Optional | Safe error details for a failed claim, when present. | ## Source [#source] | Field | Type | Presence / default | Meaning | | ---------------- | -------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | `string` | Required | Source identifier matching its key in the sources map. | | `title` | `string` | Required | Title of the academic source. | | `authors` | `array` | Optional | Author names in provider order. An empty array means unavailable. | | `year` | `integer \| null` | Optional | Publication year, or null when unknown. | | `venue` | `string \| null` | Optional | Publication venue or journal, or null when unknown. | | `abstract` | `string \| null` | Optional | Available abstract or provider summary; may be null. | | `url` | `string \| null` | Optional | Source landing-page URL as a string, or null. Current validation does not enforce a URL format. | | `pdf_url` | `string \| null` | Optional | Available PDF URL as a string, or null. | | `doi` | `string \| null` | Optional | The DOI without a prefix (for example 10.1038/s41586-020-2649-2) when a registry supplied one: Semantic Scholar results and every POST /verify record. Google Scholar results carry none, so most quick-search sources have null. Null never means the paper has no DOI; POST /verify finds it. | | `volume` | `string \| null` | Optional | Journal volume when a registry supplied it (verify and paper records); null for search results from Google Scholar. | | `issue` | `string \| null` | Optional | Journal issue when a registry supplied it; null otherwise. | | `pages` | `string \| null` | Optional | Page range such as 357–362 when a registry supplied it; null otherwise. | | `citation_count` | `integer \| null` | Optional | Known citation count, or null when unavailable. Zero differs from an unknown count. | | `score` | `number \| null` | Optional | Rank score attached to the source. Use the track-specific scores map when a source is shared between tracks. | | `citations` | `Citations \| null` | Optional | Formatted citations. Null when citation\_formats is empty; unrequested individual formats are null. | | `enrichment` | `Enrichment \| null` | Optional | Analysis object, or null for enrichment none. Low only populates relevance; other levels may use fallback analysis. | | `parsed_source` | `string \| null` | Optional | Text scraped during high enrichment in deep mode, with abstract fallback when full text is unavailable. Null in quick mode, where the model reads the source itself and nothing is stored. Not a guarantee of a complete paper. | ## Citations [#citations] | Field | Type | Presence / default | Meaning | | --------- | ------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `apa7` | `string \| null` | Optional | APA 7 formatted citation, or null if not requested. | | `mla9` | `string \| null` | Optional | MLA 9 formatted citation, or null if not requested. | | `ieee` | `string \| null` | Optional | IEEE formatted citation, or null if not requested. | | `harvard` | `string \| null` | Optional | Harvard formatted citation, or null if not requested. | | `bibtex` | `string \| null` | Optional | BibTeX entry, or null if not requested. | | `styles` | `map \| null` | Optional | Every other requested style, keyed by its CSL style id (for example chicago-author-date), each a bibliography entry rendered through CSL from the source metadata. A value is null when the style could not render this source. Null when no CSL style was requested. | ## Enrichment [#enrichment] | Field | Type | Presence / default | Meaning | | ------------------ | ----------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `level` | `EnrichmentLevel` | Required | Effective enrichment level used for this source. | | `relevance_rating` | `RelevanceRating \| null` | Optional | Qualitative relevance label. These current wire values are case-sensitive, human-readable strings; see the enum reference. | | `analysis` | `string \| null` | Optional | Markdown explanation of the source’s relevance, present at low, medium and high. | | `evidence` | `array \| null` | Optional | Supporting excerpts and their explanations: quoted from the abstract at low, from the body of the paper at high (3–5 items when the paper is reachable). Always an empty list at medium, which reads the paper without quoting it. | | `paper_type` | `PaperTypeClassification \| null` | Optional | Eight classification flags, present at low, medium and high. Heuristic/model output is not independent verification. | ## SupportingEvidence [#supportingevidence] | Field | Type | Presence / default | Meaning | | ------------- | -------- | ------------------ | ---------------------------------------------------------------------------------------------------------------- | | `quote` | `string` | Required | An excerpt or finding attributed to the source. Check against the original source before quoting it as verbatim. | | `explanation` | `string` | Required | Markdown explanation connecting the evidence to the research text. | | `tag` | `string` | Required | Short descriptive label for the evidence. | ## PaperTypeClassification [#papertypeclassification] | Field | Type | Presence / default | Meaning | | -------------------------- | --------- | ------------------ | ------------------------------------------------------------------- | | `peer_reviewed` | `boolean` | Required | Whether analysis classifies the source as peer reviewed. | | `renowned_author` | `boolean` | Required | Whether analysis classifies the author as established in the field. | | `top_tier_venue` | `boolean` | Required | Whether analysis classifies the venue as top tier. | | `meta_analysis` | `boolean` | Required | Whether the source is classified as a meta-analysis. | | `research_article` | `boolean` | Required | Whether the source is classified as original research. | | `review_article` | `boolean` | Required | Whether the source is classified as a literature review. | | `preprint` | `boolean` | Required | Whether the source is classified as a preprint. | | `randomized_control_trial` | `boolean` | Required | Whether the source is classified as a randomized controlled trial. | ## SearchMetadata [#searchmetadata] | Field | Type | Presence / default | Meaning | | ---------------------- | ----------------- | ------------------ | ----------------------------------------------------------------------------------- | | `requested_max_claims` | `integer \| null` | Optional | Requested cap for claim searches. | | `actual_max_claims` | `integer \| null` | Optional | Reported number of claims eligible under the request cap and extracted claim count. | ## Usage [#usage] | Field | Type | Presence / default | Meaning | | ------------------------- | ----------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `currency` | `string` | Optional; default: `"USD"` | Currency for the amounts in this object. Currently USD. | | `estimated_cost` | `number \| null` | Optional | Maximum USD charge for the requested mode, enrichment, source count, and claim count. Computed before the search runs. Null only on older records. | | `actual_cost` | `number \| null` | Optional | USD reported for this search. Null while the search is still running. Zero when the search fails. On success, retrieval plus per-source enrichment for the sources actually returned, which can be below the estimate. A finished track with no sources still includes its retrieval fee. | | `discount_percent` | `integer \| null` | Optional | Subscription discount already applied to estimated\_cost and actual\_cost, as a whole percentage: 15 for Pro, 35 for Ultra, 50 for Max, 0 without a subscription. Null only on older records. | | `balance_after` | `number \| null` | Optional | Prepaid balance after this search. Null on this response. Create reads the dashboard balance and rejects with 402 when it cannot cover the estimate. The later usage report is what decreases it. | | `free_searches_remaining` | `integer \| null` | Optional | Free MCP searches the account has left after this one. Present only on a search that an account without a Sourcely plan made through the Sourcely MCP server; null on direct API calls and for subscribers. When it reaches 0, the next search through the MCP server fails with 402 free\_limit\_reached. | | `free_searches_limit` | `integer \| null` | Optional | Total free MCP searches an account without a plan gets (5 at launch; one allowance per account, not monthly). Present together with free\_searches\_remaining, null otherwise. | ## ErrorResponse [#errorresponse] | Field | Type | Presence / default | Meaning | | ------- | ------------- | ------------------ | ----------------------------- | | `error` | `ErrorDetail` | Required | Structured API error details. | ## ErrorDetail [#errordetail] | Field | Type | Presence / default | Meaning | | --------- | ---------------- | ------------------ | ------------------------------------------------------------------------- | | `code` | `string` | Required | Stable machine-readable error identifier. | | `message` | `string` | Required | Human-readable description. Clients should branch on code, not this text. | | `details` | `object \| null` | Optional | Optional additional error details; structure depends on the error. | ## HTTPValidationError [#httpvalidationerror] | Field | Type | Presence / default | Meaning | | -------- | ------------------------ | ------------------ | ------------------------------------------------------------------------------------------ | | `detail` | `array` | Optional | Field-level validation issues returned by FastAPI; differs from the custom error envelope. | ## ValidationError [#validationerror] | Field | Type | Presence / default | Meaning | | ------- | -------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------- | | `loc` | `array` | Required | Location of the invalid value, such as \["body", "max\_claims"]. | | `msg` | `string` | Required | Human-readable validation explanation. | | `type` | `string` | Required | Machine-readable validation issue type. | | `input` | `any` | Optional | Invalid input value when included by FastAPI. Avoid logging validation payloads containing sensitive text. | | `ctx` | `object` | Optional | Additional validation context, when present. | # Use cases (/docs/use_cases) ## Research discovery [#research-discovery] Let users submit a research question or paragraph, then display relevant papers with titles, authors, publication years and source links. Use the document track's `source_ids` to resolve ordered entries from the `sources` map. Start with [Create a search](/docs/api/create_search), then [Get search results](/docs/api/get_search) using the returned `job_id`. ## Citation tools [#citation-tools] Request the citation formats your application needs through `citation_formats`. The API supports APA 7, MLA 9, IEEE, Harvard and BibTeX, plus 750+ CSL styles listed by [citation styles](/docs/api/citation_styles): Chicago, Vancouver, Nature, AMA and hundreds of journal and university styles. Display the available formatted citations beside each source, or let users copy them into their writing workflow. See [citation fields](/docs/reference/models#citations) and the [format enum](/docs/reference/enums#citationformat). ## Claim-level source suggestions [#claim-level-source-suggestions] Use `granularity: ["claim"]` or `["document", "claim"]` to return identified claims with source suggestions. Each claim includes a `searched` flag and source IDs; `max_claims` limits how many are searched. These are source suggestions, not independently verified fact-check verdicts. Review the original sources before treating them as support for a claim. ## Source analysis [#source-analysis] Use enrichment to show relevance assessments and supporting evidence next to search results. `high` enrichment reads each source in full before analyzing it, and deep search adds a shortlist and a second ranking. See [Full text](/docs/full_text) and [How search works](/docs/how_search_works). ## Integration flow [#integration-flow] Your server creates a search with its API key, keeps the search ID, retrieves the result with the same account's key, and maps sources into your UI. Handle empty results, failures and expiration using the [error guide](/docs/errors) and [search lifecycle](/docs/lifecycle). Each search is paid from your account's prepaid credits; see [Credits and pricing](/docs/billing). Automatic worker recovery is still planned. # Webhooks (/docs/webhooks) Pass `webhook_url` on [create search](/docs/api/create_search). When that search finishes, the worker POSTs the result to that URL. [Get search](/docs/api/get_search) stays the source of truth. A missed webhook does not change the stored result. The URL must be `http` or `https` and must resolve to a public address. A private or loopback address returns **422** `invalid_webhook_url`, and no search is created. A deployment can set `WEBHOOK_ALLOW_PRIVATE_URLS=1` to allow those addresses for local testing. ## Event [#event] The body is JSON. `data` is the same search result you get from GET, including `status` and `usage`. | `type` | When | | ------------------ | --------------------------------------------------------- | | `search.completed` | The search finished with status `completed` or `partial`. | | `search.failed` | The search finished with status `failed`. | ```json title="Webhook payload" { "event_id": "evt_example", "type": "search.completed", "created_at": "2026-10-14T15:00:00Z", "job_id": "src_example", "data": { "job_id": "src_example", "status": "completed" } } ``` `event_id` stays the same if the delivery is retried. Use it to ignore a duplicate. Headers: | Header | Value | | --------------------- | ----------------- | | `X-Sourcely-Event` | The `type` value. | | `X-Sourcely-Delivery` | The `event_id`. | Reply with any **2xx** to acknowledge. A **429** or **5xx**, or a connection failure, is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, and 6 hours. Any other **4xx** is not retried. Redirects are not followed. Next-page and claim refetch do not send a webhook.