A custom Contact Form 7 integration receives HTTP 200 and marks an inquiry delivered. Later, the team discovers that the response was an HTML login page, malformed JSON or a valid JSON object describing a business rejection. Checking the response code was useful, but it did not establish the intended lead outcome.

This guide describes a response-validation boundary for an adapter you maintain. It does not claim that CF7 or CF7 Analytics supplies that adapter. Define the destination’s real response contract first, then distinguish transport, representation and business-result checks.
Write down what the destination promises
Find the documentation for the exact operation and API version. Record expected status codes, media types, response structure and completion meaning. A create endpoint, an update endpoint and an asynchronous import endpoint may have different successful responses even within one service.
A documented 204 No Content response should not fail merely because there is no JSON body. Conversely, a documented JSON create response should not pass because an empty body happened to accompany a 200 code. Apply the contract for that operation rather than a universal rule requiring every success to contain an identifier.
Separate accepted processing from final completion. Our HTTP 202 guide explains why an acceptance response may require later observation. The response parser should preserve that distinction instead of collapsing every permitted status into delivered.
Handle transport errors before examining the body
In a WordPress adapter, check whether the HTTP call returned a WP_Error before inspecting response fields. A connection failure is a different observation from a remote 400 response. Retain a safe error classification and correlation reference without logging credentials or complete visitor messages.
WordPress provides separate helpers for the response code and response body. Extracting either value does not validate the destination’s business result. Also retain the relevant content type and endpoint identity through your HTTP client’s documented interface.
If a timeout occurs after transmission, record an uncertain outcome. A response-processing failure does not prove that the remote write never happened. Do not automatically turn a parsing error into a new create request.
Check the expected representation
For an endpoint that promises JSON, compare the declared content type against that endpoint’s documented media types. Some APIs use a vendor-specific JSON type. Do not reject those merely because the header differs from a hard-coded application/json string, and do not accept arbitrary HTML because it contains braces.
An unexpected HTML response may indicate an authentication page, proxy error or wrong route. Investigate the actual endpoint and redirect chain. Our redirect guide covers the request method and destination checks that precede the final response.
Define a reasonable response-size limit and retain only the diagnostic material your policy permits. A full response body may contain personal answers or access tokens. A redacted error classification, timestamp and provider request reference can be more useful than a public log containing the entire exchange.
Parse JSON with an explicit failure path
JSON syntax permits several top-level value types. Successfully decoding a value therefore does not prove that the result is the object your operation expects. The values null, true and an empty list may all be valid JSON while failing the response schema.
In PHP, json_decode() supports JSON_THROW_ON_ERROR. An explicit exception path avoids treating a syntax failure and a legitimate decoded null as the same observation. Choose the expected object or associative-array representation consistently, and validate the decoded structure afterward.
Do not repair malformed responses by removing arbitrary characters until parsing succeeds. That can conceal a server problem and change meaning. Preserve a safe diagnostic and route the item for investigation when the documented contract is violated.
Validate fields and business meaning separately
The following fictional response illustrates why a nonempty identifier is insufficient. It is a synthetic example, not a response from a named CRM:
{
"operation_reference": "demo-operation-a",
"outcome": "rejected",
"errors": [{"field": "region", "code": "unsupported_value"}]
}
The operation reference identifies the attempt; it does not identify a created contact. Your adapter must understand which documented field establishes success, what type it has, and whether errors can coexist with partial results. A string containing “false” is not a boolean false, and a success-looking message is not a substitute for the actual status field.
For batch operations, validate each item’s outcome under the provider’s contract. One successful item cannot mark the whole batch complete. Keep the source reference associated with its own destination reference and error details. Distinguish confirmed rejection, confirmed completion, accepted processing and unexpected response.
Route uncertainty without creating duplicates
A destination might save a record and then return a damaged response. Before replaying that write, use its documented idempotency behavior or an authorized lookup by an external reference when supported. An arbitrary idempotency header provides no protection if the endpoint does not implement it.
Keep a response-contract failure visible in the operational queue. Give it an owner and a review deadline. Do not rewrite the original form outcome or tell the visitor to submit again simply because the adapter cannot interpret the remote reply.
Review a response matrix before release
Use synthetic fixtures for expected JSON success, documented empty success, HTML 200, invalid JSON, valid JSON of the wrong type, explicit rejection, missing required fields and partial batch completion. Verify the resulting classifications and retained references. These are proposed acceptance checks, not claims of firsthand tests against a live CRM.
We publish CF7 Analytics. Our free Svetlik Analytics for Contact Form 7 documents submission trends and statistics. Keep destination response validation in the adapter that owns the handoff, and use form measurements alongside that evidence rather than treating either one as proof of inbox delivery.
