Claude Citations — Document Block Format Rejected with 400 invalid_request_error
Claude returned 400 invalid_request_error when you enabled citations on a document block. The block structure doesn't match the expected schema: wrong source type combination, missing required fields, malformed content array, or unsupported combinations. This page has the exact valid schemas for every document type.
Every citation-enabled document block needs: type: "document", a valid source object matching one of three shapes (text, base64, content), citations: {enabled: true}, and optionally title/context. For custom-content docs, the source's content array must contain {type: "text", text: "..."} objects only — no nested documents or images.
The Error Messages You're Seeing
# Missing source type:
HTTP/1.1 400 Bad Request
{"type":"error","error":{"type":"invalid_request_error",
"message":"document.source.type is required. Expected 'text', 'base64', 'file', or 'content'."}}
# Invalid combination — text with base64 data:
{"type":"error","error":{"type":"invalid_request_error",
"message":"document.source with type 'text' does not accept a 'data' field with base64 content. Use 'data' as plain string."}}
# Custom-content with unsupported nested types:
{"type":"error","error":{"type":"invalid_request_error",
"message":"document.source.content[0] must be of type 'text'. Nested document or image blocks not supported inside content array."}}
# Citations enabled on image-only document:
{"type":"error","error":{"type":"invalid_request_error",
"message":"citations feature not supported for image-only documents."}}
# Missing media_type on text source:
{"type":"error","error":{"type":"invalid_request_error",
"message":"document.source.media_type is required when source.type is 'text' or 'base64'. Expected 'text/plain', 'application/pdf', etc."}}
Valid Document Block Schemas (Nov 2026)
| Purpose | source.type | Required fields | Citations? |
|---|---|---|---|
| Plain text doc | text | media_type: text/plain, data (string) | ✓ Yes |
| PDF (inline) | base64 | media_type: application/pdf, data (base64 string) | ✓ Yes |
| PDF (uploaded) | file | file_id: file_... | ✓ Yes |
| Multi-chunk RAG | content | content: [{type:text, text:...}, ...] | ✓ Yes (block-level) |
| Image (analysis only) | base64 | media_type: image/*, data | ✗ No |
What Actually Causes This Error
Fixes That Work (Tested Nov 2026)
1Use the Correct Schema for Each Source Type
2Validate Document Blocks Before Sending
3Migrate Legacy Schemas Automatically
Preventing This Error Going Forward
- Wrap document block construction in a validator. Catches schema issues before API call.
- Use SDK helper classes (types.DocumentBlockParam). Type-checked by mypy; avoids field errors.
- Test all four source types in CI. Catches regressions when Anthropic updates schemas.
- Keep SDK on latest minor version. Schema definitions ship with SDK updates.
- Never send raw citations: true. Legacy shorthand no longer accepted.
- Filter content[] arrays to text-only. Silent field drops cause confusing errors downstream.
- Log the exact failed payload on 400. Redact sensitive fields but keep structure for debugging.
Researcher · AI Error Hub
Frequently Asked Questions
Yes. A user message content array can contain multiple document blocks alongside text blocks. Each document has its own citations setting. Citations returned in the response reference which document (via document_index) contributed each cited passage.
text is a single string blob — Claude cites character ranges. content is a structured array of text chunks — Claude cites specific chunks by index. Use content for RAG where you want chunk-level attribution; use text for whole documents where character-range citations are fine.
No — only {type: "text", text: "..."} sub-blocks. Nested images, documents, or tool_use blocks are rejected. Images intended for analysis go in separate image content blocks alongside the document.
Currently only {enabled: bool} is supported. There's no way to pass additional citation config per document. Add metadata (author, date, section) to the document title or context field instead.
Yes — the optional context field lets you provide document-level metadata that Claude uses when deciding what to cite. Example: context: "Legal contract signed 2024-05-01". Doesn't count toward citations but improves quality.
Related Errors
Get Grounded Claude Answers
Weekly: schema patterns, RAG architectures, citation quality metrics. 12,000+ builders subscribe.
Subscribe Free →