SMM API Error Handling: Separate Transport and Order Errors
“The API failed” is not enough information to choose a safe next step. A connection failure, an HTTP error, an unreadable response and an error inside one batch item describe different situations. The same network timeout also has different consequences when reading a status and when creating a paid order.
Build an error record that preserves both the operation and the layer where evidence stopped. The AlwaysCompleted public reference documents JSON responses and several per-item error shapes. The additional transport scenarios in this guide are hypothetical test cases, not observed incidents or promised behavior of the live API.
Record the action before diagnosing the response
Create a local attempt record before sending a request. Include a local correlation ID, action, attempt time, application version and the related local intent or returned order ID when available. Record whether the action reads information or can change state. Keep the API key out of this record.
Use an allowlist for log fields. Logging the complete request and redacting it later is fragile: form fields, URLs, exceptions and debug output can take different paths. The OWASP logging guidance treats access tokens, passwords and primary secrets as information to exclude or protect. For this integration, the useful record is the action and its outcome, not the credential that authorized it.
If the request contains a customer target URL, consider whether you need that URL in the diagnostic event at all. A restricted internal reference may be sufficient. Do not place unrelated orders or customer contact data in a support bundle.
Move through four evidence layers
Transport: Did the client receive a response? A DNS error or connection timeout differs from a timeout after the request may already have reached the server. Preserve the exception category without assuming whether a write was applied.
HTTP: Was there an HTTP response and what status did it contain? Keep the status code and safe headers needed for diagnosis. HTTP success alone does not establish that a business operation succeeded.
Representation: Does the body parse as JSON in the expected top-level shape? A valid JSON array is not interchangeable with the object expected for a single-order status. A proxy or generic error page can also be HTML. The HTML scenario in the downloadable fixture pack is deliberately synthetic.
Action or item: Once the representation is understood, inspect the action result and each requested batch item. A batch can contain both a valid status and an error. Check that each requested identifier has a corresponding result and that no unexpected identifier is silently assigned to another order.
An unfamiliar optional field should not automatically turn a known successful response into failure. Preserve or ignore it according to a versioned parser policy. By contrast, a missing required field or a known field with an unexpected type requires review. Do not coerce an error object into a string and display it as an order status.
Choose recovery by operation semantics
For a failed read, a bounded retry can be reasonable. Set a maximum number of attempts, a delay strategy and an escalation point. Keep the last confirmed value with its timestamp. A failed balance request should produce “balance unavailable”, not a fabricated zero or the assumption that previous funds remain available for new commitments.
For an uncertain add outcome, preserve the local intent and pause automatic resubmission. A timeout does not prove no order was created. The reference does not promise server-side idempotency or lookup by a local client_reference. The separate timeout guide explains the duplicate-submission problem in more detail.
The same caution applies to other state-changing actions such as creating a refill. Resolve what can be established from known IDs and account evidence before deciding to submit again. A retry policy for a local database transaction must not automatically replay the later API write.
Treat 429 as a scenario, not a published quota
MDN documents HTTP 429 as a rate-limit response that may include Retry-After. That does not establish that AlwaysCompleted uses a particular request limit or always returns this status. The public reference does not publish a fixed rate-limit allowance.
If your application encounters 429, preserve the actual evidence. Interpret a valid Retry-After according to HTTP semantics, then schedule a bounded retry only if the operation's semantics permit it. If the header is missing or invalid, apply your own conservative backoff and escalation policy. A delay indication is not proof that a previous state-changing request had no effect.
Do not immediately increase concurrency because some items succeeded. A burst of retries can multiply both load and ambiguity. Give the incident a single owner and retain the relationship between attempts and the original intent.
Run the eight-scenario exercise
The error scenario matrix and blank incident record and JSON fixtures cover a read timeout, add timeout, 429 with and without a retry header, HTML instead of JSON, an action error, a batch item error and an unfamiliar optional field. These are local design exercises. They contain no credentials and send no requests.
For each row, write the visible customer state, the next machine action and the escalation condition before running an implementation test. Then assert the important negative outcomes: no new paid submission after an ambiguous add, no loss of successful neighbors, no zero-filled missing amounts and no secret value in the recorded incident.
Keep two outputs from a test: the parser result and the chosen operational decision. A parser may correctly identify an error while the retry decision is still unsafe. A complete integration review needs both.
Give technical support a concise incident bundle
Include the action, timestamp with timezone, local correlation reference, relevant returned order or refill ID, HTTP status when one exists, a redacted error description and the decision already taken. State clearly when the outcome is unknown. A screenshot or raw dump is unnecessary if a small structured record captures the issue more accurately.
Use the developer guide and current API reference as the contract. Ask technical support about undocumented behavior instead of turning one incident into a permanent assumption. Confirm service scope before ordering, and keep operational delivery status separate from the customer's marketing results.
Does HTTP 200 mean every order in a batch succeeded?
No. Parse the response and inspect individual items. The reference itself shows mixed batch outcomes.
Should every unexpected response be retried?
No. Determine whether the operation can change state and whether the prior outcome is known. A malformed reply to a write can leave an unresolved outcome.