The scenario: the platform cannot push directly to a phone
A phone bridge may be able to reach the platform while the platform cannot initiate a connection back to that phone. A pull-based outbox changes the direction: the bridge asks for work, performs the delivery operation and reports the result. The API must distinguish a permitted bridge request from an arbitrary caller trying to read or modify queued messages.
The reviewed Movo-X implementation separates an outbox provider from its direct gateway provider. Six isolated tests across configuration, patient handlers and outbox handlers passed with mocked dependencies. This chapter examines the bridge API boundary. The tests did not connect to WhatsApp, operate a real phone or validate database leasing.
Expose the bridge surface only for the selected mode
The outbox handler checks the selected provider and required bridge configuration before serving its operations. If the outbox is not the active provider, required settings are missing or inbound handling is disabled, the handler does not offer the normal outbox API. The tests cover selected disabled and wrong-provider cases.
This makes provider selection part of the route contract instead of leaving every delivery mechanism available by default. It does not prove the environment is correctly configured in a current deployment. A release review should record which provider is intended, who owns the bridge and how that choice is safely verified without dumping tokens or secret configuration.
Require both the bearer and the signed request
The inspected handler checks a bearer credential and then verifies a timestamped HMAC over the raw request body. For a GET lease request, the body used by that verification is empty. For a POST result, the raw body is read with a bound before JSON processing.
The isolated tests reject an incorrect bearer, an incorrect signature and a result whose signature was made for a different body. A correct request reaches the mocked coordinator. These are useful request-boundary checks, not proof of a fully replay-proof protocol. Possession of both bridge secrets remains powerful, and any wider transport, rotation or replay design requires its own review.
Understand exactly what the signature binds
The reviewed verifier binds the timestamp and raw body, checks the accepted signature representation and enforces a bounded time difference. It does not include the method, URL path or query string in that signed text. The bearer and the endpoint’s validation still participate in deciding whether a request is accepted.
That detail belongs in a precise protocol review. Do not describe a body signature as if it cryptographically covers every request field. Likewise, a freshness window limits age but does not itself establish one-time consumption. A separate acceptance plan should evaluate duplicate reports, valid-window repeats and path/query handling against the authoritative coordinator rather than claiming guarantees absent from the signed representation.
Bound the amount of leased work
The lease endpoint converts the requested limit and accepts only an integer within its configured range, with a small default. A tested valid request forwards the accepted limit to the coordinator; an out-of-range request is refused before that operation. The response comes from the injected coordination layer.
The endpoint therefore narrows the API request, while the database still owns message eligibility, expiry and lease state. A successful mock response does not prove exclusive work allocation or crash recovery. To accept those properties, run competing synthetic bridge clients in an authorized environment and inspect the actual lease and message transitions, including a worker that disappears after receiving work.
Treat a result as a validated report, not arbitrary data
The result endpoint requires the expected message identifier shape and a body containing only the supported sent/failed status and an optional bounded reason string. Unexpected fields, unsupported statuses and oversized reason values are refused in the rerun tests before the mocked RPC is called.
An accepted body is then forwarded to the authoritative result operation. Its returned state can differ from the bridge report, such as a failed attempt becoming queued for retry. The test uses a mocked result to show that response mapping. It does not establish the actual retry schedule, delivery receipt semantics or whether a reported sent message reached the recipient.
Keep message contents out of routine lease diagnostics
The inspected lease path records an event and the number of leased messages when there is work. It does not print the message array, phone numbers or one-time codes in that routine event. Unexpected handler exceptions produce the shared generic internal-error response rather than returning a raw exception to the bridge.
A bounded reason string is still untrusted descriptive input. Operations should define what the bridge is allowed to include and where result information is retained. A length limit alone cannot make free text private. This public account uses no real message content or bridge credentials and does not claim to have audited every downstream log or database retention policy.
A concrete bridge API handover
Deliver the provider-mode gate, authentication representation, signed-field definition, lease input bound and result schema. Include wrong-secret, modified-body and invalid-result fixtures. List coordinator exclusivity, duplicate completion, secret rotation and actual delivery confirmation as separate integration evidence.
For a CTO, this turns a phone-based integration into an inspectable boundary. The platform does not need to guess whether a bridge was reachable, and the bridge cannot submit arbitrary result fields through the reviewed route. The API evidence is useful precisely because it stays distinct from the untested phone session, database state machine and recipient delivery outcome.
Illustrative control flow
Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.
if selected_provider != pull_outbox:
refuse_route()
verify_bearer(request)
verify_timestamp_and_raw_body_signature(request)
if lease_request:
coordinator.lease(validate_limit(request))
elif result_request:
coordinator.record(validate_message_result(request))
# The reviewed HMAC binds timestamp and body, not every request field.About this engineering series
Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.
Explore the Movo-X engineering series → · Related implementation experience →
Discuss a similar engineering problem
Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.
Discuss your project on WhatsApp ↗