Original api forms diagram: Type, Fields, Bounds, Review.

SMM API Order Forms: Validate Fields by Service Type

A universal “link and quantity” form looks convenient until the selected service expects a package, a keyword list or individual comment lines. At that point, the form can collect the wrong information while still appearing complete. Choose the form from the current service type, then validate its particular inputs before the application constructs a paid order request.

The public AlwaysCompleted API reference documents different add fields for different types. The four examples here are a deliberately limited implementation: Default, Package, SEO and Custom Comments. A type outside that list goes to configuration review. It does not fall back to Default.

Start with an authoritative service record

The browser may submit a product choice, but the server must resolve that choice to its own current catalogue record. Otherwise, a modified browser request could supply a different type or an older minimum and maximum. Keep your internal product ID separate from the service ID used by the API.

Record which catalogue snapshot and service description informed the form. The catalogue is useful for type, bounds and other advertised fields; it is not a complete validation schema for every individual offer. A destination requirement in the service description still matters even when the generic URL field passes.

If the type changes, pause the offer until its form is reviewed. If the service disappears, do not silently substitute another ID. Those are catalogue maintenance decisions, covered in the catalogue change review.

Map four different input contracts

The reference gives these business inputs in addition to the common authentication, action and service fields:

Type Documented inputs relevant here Form behavior
Default link, quantity; optional runs and interval Require quantity; implement optional controls only deliberately
Package link Do not add a quantity requirement from a shared template
SEO link, quantity, newline-separated keywords Validate the text list as well as the numeric quantity
Custom Comments link, newline-separated comments Collect comment lines; the documented request has no separate quantity field

The example downloads implement the required inputs in this table. They do not implement optional Default scheduling fields. The server builds authentication fields separately; accepting a key value from an order form is not part of this design.

This distinction also improves the confirmation screen. A Package buyer should review the package and destination. A Custom Comments buyer should see the actual normalized comment lines. A quantity label copied into both screens would hide what the buyer is approving.

Validate syntax and meaning on the server

OWASP distinguishes syntactic and semantic validation. Applied here, a quantity can be a syntactically valid integer and still be outside the selected service's allowed range. Client-side checks help people correct mistakes quickly, while the server repeats the authoritative checks.

Use an explicit field allowlist for each configured type. In the example, an unexpected quantity on a Package form is rejected as an unconfigured field. That is a local application policy, not a claim that the API rejects every extra field. The policy makes stale form code visible before it can influence a request.

For numeric inputs, reject booleans, fractions and ambiguous strings. Compare a whole-number quantity against reviewed current bounds. If the bounds themselves are malformed, hold the service; substituting a convenient default would turn missing catalogue evidence into permission to spend.

A basic URL check should reject unsupported schemes, embedded credentials and obvious malformed input. It does not prove that the destination is reachable, public or valid for that particular service. Show the expected destination type next to the field, and verify any additional service conditions separately.

Make multiline normalization visible

Keywords and comments need a clear rule for blank lines, leading spaces and line endings. The fixture strips surrounding whitespace from each line, removes empty lines and joins the remaining lines with newline characters. Show that normalized value in the confirmation step so the buyer can see exactly what remains.

The example also caps the number and length of lines. Its settings—100 lines and 500 characters per line—are DEMO application limits chosen to exercise validation. They are not published AlwaysCompleted API limits and should not be copied into a production offer without a reason.

Do not assume that catalogue quantity bounds automatically define the allowed number of comment lines. That relationship needs confirmation for the selected service. Similarly, a syntactically valid keyword list does not establish that its content or destination meets the offer's requirements.

Walk through eight offline cases

All IDs and URLs in the download are invented. The code performs no HTTP requests and does not create orders.

Case Expected decision
Default, quantity 100 within DEMO bounds Accept and normalize the digit string
Package with a link and no quantity Accept
SEO with no keywords Return a keywords error
Default quantity above the maximum Return a quantity error
An unconfigured service type Hold for type-specific implementation
Custom Comments with two nonblank lines Accept and preview the normalized lines
A JavaScript URL Return a link error
Comments containing only whitespace Return a comments error

The useful result is a field-level decision, not merely a red “invalid request” banner. Keep the person's other inputs so they can correct the affected field. A service configuration failure should explain that ordering is temporarily unavailable rather than asking the buyer to guess another number.

Three additional guards exercise a boolean quantity, an injected key field and corrupt catalogue bounds. A passing run establishes the behavior of this local example. It does not test remote acceptance, live prices or all service types.

Revalidate at the point of submission

A correct form can become stale while someone is reviewing it. Before constructing the request, confirm that the chosen service remains enabled, the type still matches the form, and the submitted fields still pass the current contract. If a material condition changed, show the updated offer for review.

Keep that review separate from duplicate-submit protection. Validation answers whether the proposed input is acceptable to your application. It does not answer whether a previous create request already reached the API. A timeout after submission needs an unknown-outcome workflow, not another validation pass followed by an automatic duplicate.

For deployment, record the supported types, optional fields, current catalogue source, content restrictions and owner responsible for future changes. Use the service description worksheet to make those conditions understandable to the buyer, and the offline integration checklist to review the wider client workflow.

Download the validator and review worksheet

Save the Python and JSON files together and run python3 service_type_validator.py. No key, account access or paid order is needed. Before enabling a real offer, compare its selected type and conditions with the current API reference and developer guidance.

By AlwaysCompleted · Published