CCDV-F · Domain 2: Applications and Integration · 20% of the exam
Task 2.1: Messages API Mechanics
What a Messages API request and response contain and how they behave: message structure, tool use, streaming, images, thinking, prompt caching, structured output and stop reasons, and when to send requests in real time or as a batch.
Study it
Messages API requests and responses: tool use, streaming, thinking, caching, stop reasons and batches
Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.
Question 1 · choose 1
A Messages API request that worked yesterday now fails with a 400 invalid_request_error after a teammate renamed one of its tools to group tools by system. The tools array now contains:{
"name": "orders.lookup",
"description": "Looks up an order by its ID and returns status and items.",
"input_schema": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"]
}
}What fixes the request?
AAdd "strict": true so that the API validates the tool against its schema before accepting it
BRename it to orders_lookup, since names allow only letters, digits, underscores and hyphens
CMove the order_id property out of required so that the schema accepts calls without it
DShorten the description to a single sentence so that the tool definition passes validation
Show the answer and why
AAdd "strict": true so that the API validates the tool against its schema before accepting it
Incorrect
The name rule applies to every tool definition; adding strict does not make a name with a dot acceptable.
BRename it to orders_lookup, since names allow only letters, digits, underscores and hyphens
Correct
The name must match ^[a-zA-Z0-9_-]{1,128}$, and the dot is outside that set.
CMove the order_id property out of required so that the schema accepts calls without it
Incorrect
The schema is valid as written; the error comes from the name, not from the required list.
DShorten the description to a single sentence so that the tool definition passes validation
Incorrect
Descriptions should be detailed, several sentences where needed; their length is not what fails.
A tool's name must match the regular expression ^[a-zA-Z0-9_-]{1,128}$: letters, digits, underscores and hyphens only. A dot breaks the rule, so group tools with a separator such as an underscore instead.
Your service streams Messages API responses and meters output tokens per customer. The meter adds the output_tokens value of every message_delta event it receives to the customer's total. Finance reports that streamed replies are sometimes billed to customers above what the usage on the final Message would show. What is wrong with the meter?
AIt should read output_tokens from message_start only, since the count reported there already covers the whole reply
BIt should add the length of each content_block_delta's text instead of reading usage from events
CIt should skip message_delta events that carry no stop_reason, since only the last one counts
DThe usage counts in message_delta are cumulative, so the meter should keep the last value instead of adding them
Show the answer and why
AIt should read output_tokens from message_start only, since the count reported there already covers the whole reply
Incorrect
message_start arrives before any content, so its count does not cover the reply.
BIt should add the length of each content_block_delta's text instead of reading usage from events
Incorrect
Text length is not a token count, and usage is reported in the stream.
CIt should skip message_delta events that carry no stop_reason, since only the last one counts
Incorrect
Every message_delta carries cumulative counts; the fix is not about stop_reason.
DThe usage counts in message_delta are cumulative, so the meter should keep the last value instead of adding them
Correct
Adding cumulative counts double-counts whenever a stream carries more than one message_delta.
A stream sends message_start, the content blocks, one or more message_delta events with top-level changes, then message_stop. The token counts in the usage field of message_delta are cumulative, so take the latest value rather than summing them.
Your Q&A service sends the same long system prompt and the same handbook document with every request, with a cache_control breakpoint at the end of the document. Depending on the customer, the document block is sent either as{"type": "document", "source": {"type": "text", "media_type": "text/plain", "data": "..."},
"citations": {"enabled": true}, "cache_control": {"type": "ephemeral"}}or with "citations" left out. Traffic alternates between the two kinds of customer, and cache reads are far lower than expected. What change restores them?
AUse the same citations setting on the document in every request that shares the cached prefix
BSwitch the breakpoint to the 1-hour cache duration so that entries survive the alternating traffic
CPlace the document before the system prompt so it is cached ahead of the setting
DAdd a second breakpoint on the last user message so that each request writes one more cache entry
Show the answer and why
AUse the same citations setting on the document in every request that shares the cached prefix
Correct
Toggling citations modifies the system prompt, which invalidates the system and message caches.
BSwitch the breakpoint to the 1-hour cache duration so that entries survive the alternating traffic
Incorrect
A longer lifetime does not help when consecutive requests carry different prefixes.
CPlace the document before the system prompt so it is cached ahead of the setting
Incorrect
The cache follows the fixed order tools, system, then messages; a document cannot precede the system prompt.
DAdd a second breakpoint on the last user message so that each request writes one more cache entry
Incorrect
More breakpoints add entries but do not make the toggled requests share a prefix.
The cache follows tools, system, then messages, and enabling or disabling citations modifies the system prompt, invalidating the system and message caches. Requests that should share a cached prefix need the same citations setting on their documents.
Your etl service submits a large Message Batch every night with an API key created for the etl workspace, and a reporting service in the analytics workspace collects the results the next morning. A realtime support chat that calls the Messages API keeps serving users through the night. Which TWO statements are true? (Choose TWO.)
AThe reporting service needs a key that works in the etl workspace to see the batches and their results
BEach request's result can be downloaded as soon as that request finishes, before the rest of the batch completes
CThe results come back in the order the requests were submitted, so the reporting service can match them by position
DResults stay downloadable for as long as the batch object exists in the workspace
EThe batch's work does not use up the Messages API rate limits that the support chat relies on
Show the answer and why
AThe reporting service needs a key that works in the etl workspace to see the batches and their results
Correct
Batches are scoped to the workspace they were created in, and a key created for a workspace only works there.
BEach request's result can be downloaded as soon as that request finishes, before the rest of the batch completes
Incorrect
Results are available when all requests have completed or after 24 hours, whichever comes first.
CThe results come back in the order the requests were submitted, so the reporting service can match them by position
Incorrect
Batch results can be returned in any order, not necessarily the order of the requests.
DResults stay downloadable for as long as the batch object exists in the workspace
Incorrect
Results are available for 29 days after creation; the batch can still be viewed after that.
EThe batch's work does not use up the Messages API rate limits that the support chat relies on
Correct
The Message Batches API has its own rate limits, and batch usage does not affect the rate limits of the Messages API.
Batches are scoped to the workspace in which they are created, so a service needs a key that works in that workspace to see them. The Message Batches API has its own rate limits, and its usage does not affect the Messages API's rate limits. Results arrive when the whole batch ends or after 24 hours, in any order, and stay available for 29 days.
You are moving a support conversation from an older chatbot into a Messages API request so that Claude can continue it. The earlier replies were written by the old bot, not by Claude. How can you include them?
AYou cannot: assistant turns must be Claude's own earlier responses, so start a new conversation instead
BPut the old bot's replies in the system prompt, since only Claude's replies may use the assistant role
CUpload the transcript with the Files API and ask Claude to read it in the first user message
DSend them as assistant messages in the history; earlier turns don't have to come from Claude itself
Show the answer and why
AYou cannot: assistant turns must be Claude's own earlier responses, so start a new conversation instead
Incorrect
Earlier turns don't need to originate from Claude.
BPut the old bot's replies in the system prompt, since only Claude's replies may use the assistant role
Incorrect
Synthetic assistant messages can carry them in the conversation itself.
CUpload the transcript with the Files API and ask Claude to read it in the first user message
Incorrect
The history can be sent directly as messages; no upload is needed.
DSend them as assistant messages in the history; earlier turns don't have to come from Claude itself
Correct
The API is stateless, and synthetic assistant messages can stand in for earlier turns.
The Messages API is stateless: you send the full conversational history with each request. Earlier turns don't necessarily need to originate from Claude, so you can use synthetic assistant messages.
A workspace has a monthly spend limit, and a large Message Batches job finished slightly above it, while the team's realtime traffic in the same workspace stopped at the limit. What explains the batch's overshoot?
ABatch requests are exempt from workspace spend limits
BThe batch discount is applied after the limit is checked
CHigh throughput and concurrent processing can take a batch slightly past the limit
DThe limit resets for each new batch that is submitted
Show the answer and why
ABatch requests are exempt from workspace spend limits
Incorrect
The limit applies; batches can go only slightly over it.
BThe batch discount is applied after the limit is checked
Incorrect
The page explains the overshoot by throughput, not by how discounts are applied.
CHigh throughput and concurrent processing can take a batch slightly past the limit
Correct
Because of high throughput and concurrent processing, batches might go slightly over the workspace spend limit.
DThe limit resets for each new batch that is submitted
Incorrect
A workspace spend limit is not reset per batch.
Because of high throughput and concurrent processing, batches might go slightly over the spend limit configured in the Claude Console for your workspace.