CertSafari
    Anthropic Claude Certified Developer – Foundations (CCDV-F) - December 7 onwards· Lessons

    Domain 6 · Lesson 18/24

    Grounding Claude's answers in supplied documents with citations

    Grounding and Source Citation

    18 min read
    3.75% of exam
    6 sources
    Published 18 Nov 2026
    Docs as of 18 Nov 2026

    What you will be able to do

    • Write a prompt that limits Claude to the supplied documents and makes it return an exact 'not found' reply when they lack the answer
    • Use document blocks with citations enabled so every claim comes back with a source location you can check
    • Return retrieved passages as search_result blocks so answers carry source attributions without a custom citation parser
    • Choose between sending the full document set and retrieving only relevant passages, based on corpus size, cost and freshness

    Key concept

    Grounded answer — An answer built only from the documents in the request. Each claim can be traced to a passage in those documents, and when the documents don't contain the answer, the reply says so instead of filling the gap from general knowledge.

    1.Restricting answers to the documents and returning not found

    A grounded assistant has two jobs, and most failures come from the second one. The first job is answering from the documents. The second is noticing when the documents say nothing and stopping there. Take an HR assistant built on a benefits handbook. Asked about relocation bonuses, which the handbook never mentions, it will often describe a typical industry policy. To the employee that reads like company policy, and it is wrong.

    The fix is two explicit instructions working together. External knowledge restriction tells Claude to use only the supplied documents and not its general knowledge. Permission to say "I don't know" gives Claude an approved way out when the documents fall short, and this alone can sharply reduce false information. Put them together and the prompt looks like this: answer only from the handbook, and if it lacks the answer, reply exactly "Not found in the handbook" instead of guessing.

    An exact not-found string matters for two reasons. It tells Claude precisely what to say when the documents fall short. It also gives your application a fixed value it can detect, so it can route the question to a human or log the gap in the handbook. The anti-hallucination guidance uses the same pattern for quote extraction: if Claude can't find relevant quotes, it is told to state "No relevant quotes found."

    Common alternative instructions fail in predictable ways. "Prefer the handbook, otherwise use general knowledge with a disclaimer" still produces content the handbook never stated, and a disclaimer doesn't make it true for this company. A persona told to always give a confident answer pushes Claude toward guessing, which is the opposite of permission to admit uncertainty. A length limit controls how much Claude writes, not where its information comes from, so a three-sentence answer can be entirely invented.

    Checkpoint 1 of 9· Check yourself

    An HR assistant answers employee questions from a benefits handbook. Asked about relocation bonuses, which the handbook never mentions, it describes a typical industry policy, and employees take that as company policy. Which instruction fixes this?

    Checkpoint 2 of 9· Exam question

    An HR assistant answers from an uploaded benefits handbook. When employees ask about topics the handbook omits, such as relocation bonuses, Claude fills in typical industry policy. Which instruction best fixes this?

    Sources1

    2.Extracting quotes before answering

    For long documents, ask Claude to pull word-for-word quotes out of the material before it answers. The guidance applies this to inputs above about 20k tokens. Extracting quotes first focuses Claude on the relevant passages and ignores the rest. The answer is then built from text that actually appears in the documents, not from a general impression of them.

    A two-step prompt makes this concrete. In a compliance review of a privacy policy, step 1 tells Claude to extract the exact quotes relevant to GDPR and CCPA, and to state "No relevant quotes found" if there are none. Step 2 tells Claude to analyse only those quotes and refer to them by number. The not-found rule sits right at the extraction step, so an empty result stops the analysis before it can drift into general knowledge. Wrapping each document in tags with a source label, and putting the documents above the question, are layout techniques covered in prompt revision.

    Prompt-level verification adds a check after the draft. Once Claude has written the response, have it find a supporting quote for each claim and retract any claim it can't support. In one press-release example, each removed claim is marked with empty [] brackets so a reviewer can see where something was cut. All of this is still text Claude writes, though. The next section covers the API feature that returns source locations as data.

    Checkpoint 3 of 9· Check yourself

    A team asks Claude to assess a 60k-token vendor contract for data-retention obligations. The analysis often cites retention rules that appear in no clause of the contract. Which prompt change best grounds the analysis in the contract?

    Sources21

    3.Document blocks with the Citations feature

    Asking Claude in the prompt to tag each claim with "[Doc 3, p. 12]" produces tags that look reliable but aren't checked. The tag is generated text like everything else, so it can point to a page that doesn't contain the claim. Few-shot examples of well-formed tags make the tags more consistent, but they don't connect a tag to a location. Temperature 0 makes wrong tags repeatable. A second call that sees only the finished answer has no documents to check the pages against. And a self-reported confidence score is just more generated text.

    The reliable fix is the Citations feature. Pass each file as a document content block and set citations.enabled to true. Claude's response then comes back as several text blocks, and each claim's block carries a list of citations pointing to specific locations in your documents. The API takes those locations from the documents themselves, so you can use them directly as your source tags. All active models support citations.

    A plain text document block with citations enabled. title and context reach the model but are never cited from.json
    {
      "type": "document",
      "source": {
        "type": "text",
        "media_type": "text/plain",
        "data": "Plain text content..."
      },
      "title": "Document Title",
      "context": "Context about the document that will not be cited from",
      "citations": { "enabled": true }
    }

    The document type sets how fine-grained a citation can be and what the location looks like. Every citation also has a document_index, counted from 0 across all document blocks in the request, and a cited_text field holding the exact passage. cited_text doesn't count toward output tokens.

    Citable document types and the location each citation returns
    Document typeChunkingCitation location
    Plain textSentenceCharacter indices (0-indexed, exclusive end)
    PDFSentence, from extracted textPage numbers (1-indexed, exclusive end)
    Custom contentNone: your content blocks are used as-isBlock indices (0-indexed, exclusive end)

    Several constraints catch people out. Citations must be enabled on all of the documents in a request or none of them. Only text can be cited, so a scanned PDF with no extractable text gives Claude nothing to cite. For field extraction, prompt for one field: value line per field, reassemble the lines from the text blocks, and then check that every field has both a value and at least one citation, because the API guarantees neither. Parsing that output defensively is covered in structured output.

    Checkpoint 4 of 9· Fill the gap

    This document block should return citations that point to locations in the text. Which field name completes it?

    {
      "type": "document",
      "source": {
        "type": "text",
        "media_type": "text/plain",
        "data": "Plain text content..."
      },
      "title": "Document Title",
      "context": "Context about the document that will not be cited from",
      " ? ": { "enabled": true }
    }

    Checkpoint 5 of 9· Check yourself

    Your extraction pipeline sends four policy documents with citations enabled and asks for one 'field: value' line per field. After it rebuilds the lines from the text blocks, what should the code do before saving the results?

    Checkpoint 6 of 9· Exam question

    A developer asks Claude in the prompt to end each claim with a source tag like "[Doc 3, p. 12]". Reviewers find tags that point to pages which do not contain the claim. What is the most reliable fix with the Messages API?

    Sources3

    4.Search result blocks for your own retrieval

    With your own vector search, retrieved passages don't arrive as files, but they can still be cited automatically. Return each passage from your search tool as a search_result content block with a source and a title. Claude then cites your content the same way it cites web search results, and each citation carries the source and title you supplied. No special prompting is needed, and you don't need a parser that maps sentences back to URLs.

    A search_result block with citations explicitly enabled. source can be any stable string, such as a URL or kb://article-1234.json
    {
      "type": "search_result",
      "source": "https://docs.company.com/guide",
      "title": "User Guide",
      "content": [{ "type": "text", "text": "Important documentation..." }],
      "citations": {
        "enabled": true // Enable citations for this result
      }
    }

    The block format comes with rules. The content array holds only text blocks, so images and other media aren't allowed. search_result blocks can appear only in user messages, which includes inside tool results. Inside a tool_result, it's all or nothing: if any block is a search_result, every block must be one. To add supporting text, put it as a text block inside a search result's content, where it also becomes citable. Splitting long content into logical text blocks gives Claude finer citation boundaries. Each citation comes back as a search_result_location with the source, the title, a search_result_index and block indices.

    The retrieval path needs its own not-found behaviour. When a search fails or returns nothing, return a plain text block such as "No results found." instead of raising an error. Claude explains the empty result to the user and the conversation continues. Combined with the instruction to answer only from retrieved content, this gives the same honest 'not found' as the prompt-level rule earlier.

    Checkpoint 7 of 9· Fill the gap

    Your vector-search tool hands back a passage from your own docs site. You want Claude to cite it and show the source and title you supplied. Which block type completes this tool output?

    {
      "type": " ? ",
      "source": "https://docs.company.com/guide",
      "title": "User Guide",
      "content": [{ "type": "text", "text": "Important documentation..." }],
      "citations": {
        "enabled": true // Enable citations for this result
      }
    }

    Checkpoint 8 of 9· Exam question

    A team runs its own vector search and returns passages from a search tool. They want Claude's final answer to carry clickable source attributions per claim without the team writing a citation parser. What should the tool result contain?

    Sources4

    5.Full document set or retrieved passages: size, cost and freshness

    Once you know how to ground and cite, the remaining decision is what goes into the request: the whole corpus as document blocks, or only the passages retrieved for this question. Three factors decide it: corpus size, cost and freshness.

    Corpus size sets the hard limit and the soft one. Current models such as Claude Opus 5.5, Sonnet 5.5 and Haiku 5.5 have a 1M-token context window. Other models, including Claude Sonnet 4.5, have 200k. Everything in the request counts toward the window: system prompt, documents, tool definitions and the output. A request can also include at most 600 images or PDF pages, or 100 on 200k models, so a large set of PDFs can hit the request size limit before the token limit. Fitting isn't the whole story either. As token count grows, accuracy and recall degrade, which is called context rot (see context management). That argues for retrieval even when the full set technically fits.

    Cost grows with every token you send, on every request. On Claude Haiku 5.5, prompts over 100,000 tokens cost more than standard pricing. Prompt caching changes the calculation for a large, stable document set: put cache_control on the document blocks, and later requests with the same prefix reuse them, with less processing time and cost. Citations and caching work together, because the source documents can be cached even though the citation blocks can't. The catch is lifetime. Caches use a 5-minute or 1-hour TTL, so a 400k-token archive queried about once an hour with a 5-minute cache is re-sent at full cost every time. Either the TTL has to cover the gap between questions, or retrieval has to shrink what gets sent. Enabling citations itself adds only a little input cost. The economics of caching are covered in cost optimization.

    Freshness favours retrieval when content changes. A document set placed in the prompt and cached is the version you sent. A search tool fetches content at runtime, and Claude cites what it returned. To make sure retrieval runs on every turn, force the tool call with tool_choice. Return only the most relevant results so the context doesn't overflow.

    Checkpoint 9 of 9· Match them up

    When deciding whether to send the whole corpus or only retrieved passages, several mechanisms affect the choice. Match each one to its effect on that decision.

    Tap a term, then the definition that fits it.

    Sources5634

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “External knowledge restriction: Explicitly instruct Claude to only use information from provided documents and not its general knowledge.”
      ↩︎ Restricting answers to the documents and returning not found
      “Explicitly give Claude permission to admit uncertainty. This technique can drastically reduce false information.”
      ↩︎ Restricting answers to the documents and returning not found
      “If you can't find relevant quotes, state "No relevant quotes found."”
      ↩︎ Restricting answers to the documents and returning not found
      “Only base your analysis on the extracted quotes.”
      ↩︎ Extracting quotes before answering
      “If it can’t find a quote, it must retract the claim.”
      ↩︎ Extracting quotes before answering
      “External knowledge restriction: Explicitly instruct Claude to only use information from provided documents and not its general knowledge.”
      ↩︎ Exam trap 1
      “ask Claude to extract word-for-word quotes first before performing its task. This grounds its responses in the actual text, reducing hallucinations.”
      ↩︎ Checkpoint
    2. 2.
      “ask Claude to quote relevant parts of the documents first before carrying out its task.”
      ↩︎ Extracting quotes before answering
    3. 3.
      “Set citations.enabled=true on each of your documents. Currently, citations must be enabled on all or none of the documents within a request.”
      ↩︎ Document blocks with the Citations feature
      “For PDFs: Citations include the page number range (1-indexed).”
      ↩︎ Document blocks with the Citations feature
      “The cited_text field is provided for convenience and does not count toward output tokens.”
      ↩︎ Document blocks with the Citations feature
      “PDFs that are scans of documents and do not contain extractable text are not citable.”
      ↩︎ Document blocks with the Citations feature
      “The citation blocks generated in responses cannot be cached directly, but the source documents they reference can be cached.”
      ↩︎ Full document set or retrieved passages: size, cost and freshness
      “Citations return the exact passages that support each claim, so you can verify answers and surface sources to your users.”
      ↩︎ Key concept
      “Check that each field has a value and at least one citation. The API doesn’t guarantee either.”
      ↩︎ Exam trap 2
      “Currently, citations must be enabled on all or none of the documents within a request.”
      ↩︎ Exam trap 3
      “A request with such a prompt succeeds, but the response might contain few or no citations.”
      ↩︎ Prediction
      “Check that each field has a value and at least one citation. The API doesn’t guarantee either.”
      ↩︎ Checkpoint
    4. 4.
      “each citation carries the source and title you provided.”
      ↩︎ Search result blocks for your own retrieval
      “No special prompting is needed: ask your question, and citations appear on the text blocks that draw on your content.”
      ↩︎ Search result blocks for your own retrieval
      “search_result blocks can only appear in user messages (including inside tool results).”
      ↩︎ Search result blocks for your own retrieval
      “Claude explains the empty result to the user, and the conversation continues.”
      ↩︎ Search result blocks for your own retrieval
      “tools fetch content at runtime, and Claude cites it in the response.”
      ↩︎ Full document set or retrieved passages: size, cost and freshness
      “Result limits: Return only the most relevant results to avoid context overflow”
      ↩︎ Full document set or retrieved passages: size, cost and freshness
      “if any block in a tool_result content array is a search_result, all of its blocks must be search_result.”
      ↩︎ Exam trap 4
      “Citations are disabled by default; every example on this page sets "enabled": true explicitly.”
      ↩︎ Prediction
    5. 5.
      “As token count grows, accuracy and recall degrade, a phenomenon known as context rot.”
      ↩︎ Full document set or retrieved passages: size, cost and freshness
      “If you send many images or large documents, you might reach request size limits before the token limit.”
      ↩︎ Full document set or retrieved passages: size, cost and freshness
      “long-context requests are billed at standard pricing, except on Claude Haiku 5.5, where prompts over 100,000 tokens cost more.”
      ↩︎ Full document set or retrieved passages: size, cost and freshness
    6. 6.
      “using automatic caching or explicit breakpoints with 5-minute or 1-hour TTLs.”
      ↩︎ Full document set or retrieved passages: size, cost and freshness

    Ready to test yourself?

    Practise Anthropic Claude Certified Developer – Foundations (CCDV-F) - December 7 onwards in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.