ClaudeCode.Content.DocumentBlock (ClaudeCode v0.36.3)

View Source

Represents a document content block within a Claude message.

Document blocks contain document data (PDF, plain text) either inline or by reference. They appear in user messages and can also appear within server tool results (e.g., web fetch).

Source types

  • "base64" — inline document with data and media_type
  • "text" — inline plain text with data and media_type
  • "url" — remote document referenced by url
  • "content" — structured content with nested blocks

Summary

Types

source()

@type source() ::
  %{type: :base64, media_type: String.t(), data: String.t()}
  | %{type: :text, media_type: String.t(), data: String.t()}
  | %{type: :url, url: String.t()}
  | %{type: :content, content: list() | String.t()}

t()

@type t() :: %ClaudeCode.Content.DocumentBlock{
  citations: map() | nil,
  context: String.t() | nil,
  source: source(),
  title: String.t() | nil,
  type: :document
}

Functions

new(data)

@spec new(map()) :: {:ok, t()} | {:error, atom() | {:missing_fields, [atom()]}}