Engineering, AI & Security

Business APIs Need Decision Reasons

A rejection without a reason forces consumers to guess. A rejection interpreted through exact wording breaks when someone improves a translation. The contract must separate both.

By Josué Trindade Engineering & AI ~7 min

Someone tries to change an order and receives “operation not permitted”. They try again, change a field and eventually contact support. An automated agent can enter the same loop: repeat the request, rephrase the explanation and still not know what needs to change.

In this hypothetical example, the API correctly rejected the operation because the order had left the warehouse. Control worked, but the contract did not help its consumer understand the decision. The team transferred information already known by the service into a support conversation.

I would make rejection reasons part of API design. Returning a friendlier sentence is insufficient. The stable identification of a problem, its explanation for a person and details reserved for technical investigation need to be separated.

Reasons should distinguish situations requiring different next steps

An incomplete address, an already dispatched order and missing permission can all prevent the same change. They cannot be resolved in the same way. The first calls for corrected data; the second may need a different process; the third depends on permitted access.

I would start with distinctions that change the consumer’s action. I would not create a code for every line of implementation. A small set of business reasons with defined meanings can be more useful than hundreds of technical errors nobody can maintain.

In a web application, the same reason can guide the interface and an assistant integration. That reduces disagreement between channels without making every channel display the same sentence. Meaning can be shared while explanations adapt to the reader.

Human text should not become a control language

Imagine a consumer searching for “dispatched” in the message to decide whether to offer another route. When the translation changes to “shipped”, the integration stops working. An editorial improvement has become a behavioural change.

RFC 9457 on HTTP problem details distinguishes structured information from readable explanations and advises against parsing detail for control information. That separation allows better messages without requiring the program to understand prose.

I would document a problem type or extension appropriate to the chosen contract. The sentence explains this occurrence; stable identification lets a consumer recognise the situation. Exact names and fields should be decided for the real API rather than copied as universal business vocabulary.

The reason belongs to the service’s actual decision

A consumer should not reconstruct the reason from partial information. After rejection, it may not know whether state changed or a restriction exists that it cannot see. Explanation should accompany the evaluation performed by the service.

In the example, the service might indicate that the change is unavailable at this stage. That does not mean the entire order is complete or that any person can intervene through another channel. The reason should have the scope of the rejected operation.

I would not place authority with the agent either. It can explain the reason clearly and help select a permitted next step. It should not decide that rejection no longer applies because someone insists or provides a persuasive justification.

Explanation must not disclose inaccessible resources

An excessively detailed reason can expose an approver’s name, another order’s existence or a restricted limit. The team needs to decide what each consumer may be told rather than simply what can be calculated.

I would separate usable explanation from internal diagnostics. Someone can receive enough information to seek help. An authorised team can investigate through an occurrence identifier without sending the entire technical report to the customer.

For supply chain management platforms, relationships span companies and warehouses. Rejection should not become an indirect search for another organisation’s stock or operations. An error contract needs the same access boundaries as a normal result.

Repetition helps only when the condition can change that way

Temporary unavailability can justify another attempt under the service’s conditions. A change rejected because an order has already shipped does not improve through identical requests every second.

I would define how the consumer distinguishes correcting input, waiting, obtaining an authorised decision and ending that route. The response need not prescribe every interface detail. It needs to prevent distinct situations being hidden behind one generic error.

If a reason includes retry information, its scope and validity matter. An old instruction does not replace fresh evaluation. Nor should every communication failure be assumed to mean rejection: the result may remain unknown and require a state lookup instead.

The first rejection does not necessarily describe every problem

A service may stop at the first condition preventing an operation. After someone corrects the address, a second restriction can appear. That does not establish that the first reason was wrong; the contract may never have promised a complete assessment of every condition.

I would explain that difference. Returning several input validation failures together can save work where feasible. When evaluation depends on later stages or restricted resources, the response should remain within what the service can establish and disclose.

Consumers should not promise that correcting this one problem guarantees acceptance. They can explain that the correction is necessary for another evaluation. The answer then remains useful without turning a necessary condition into a sufficient one. This is particularly relevant when an agent compresses a technical rejection into one short instruction for a person who cannot see the underlying checks.

Codes have a lifecycle too

Adding a reason can appear minor, but an older consumer might not recognise it. I would define conservative handling for unknown types: show a permitted explanation, preserve the identifier and use the appropriate assistance path without inventing an automatic action.

Changing an existing code’s meaning is more dangerous. If it previously meant “correct the address” and now means “request approval”, the same client could continue performing the wrong behaviour without a syntax error.

The article on expand-contract database migrations develops a related concern about compatibility during change. For error contracts, I would apply the same attention to still-active consumers before retiring or redefining reasons.

Do not copy the complete business policy into every client

The strongest objection is that detailed reasons can encourage rule duplication. A client starts predicting the server’s decision and treating prediction as permission. That risk deserves an explicit boundary.

I would use reasons to explain decisions and guide interaction while retaining final evaluation in the service. An interface can warn that a change is usually unavailable after dispatch. During execution, the API must continue checking relevant state and authority.

An experience improvement then avoids creating two independent versions of the rule. The consumer can anticipate useful information without owning the operational decision. Documentation and integration examples should make that difference clear.

Check the contract across language, version and access

I would prepare fictional cases for an incomplete address, incompatible state, missing access and temporary failure. Change wording and language while keeping the reason’s identity. Consumer behaviour should not depend on those editorial changes. These are proposed checks rather than observed results.

I would introduce a new reason to an old client and inspect its fallback path. I would also check that public details reveal only permitted information. An API can explain a problem well to engineering while disclosing too much to the person making the request.

Include a case in which communication fails after the service has acted. A rejection reason must not be fabricated for an operation whose outcome has not been established. The consumer needs a way to reconcile that result rather than assume that any error text authorises repetition.

Between 2026 and 2030, if more consumers are generated or operated by agents, explicit reasons may make integration more predictable. In technical consulting, I would begin with a frequent rejection currently creating support calls. Define meaning, explanation, limits and next steps before adding more intelligence to the consumer.

[+] On this page 16 topics ▼
FAQ · Common Questions

Frequently Asked Questions

Is a readable message enough to explain rejection?

It helps the person but should not be the program's only signal. A stable documented reason allows handling without depending on wording or language.

Should the client reproduce server rules?

Not as the final authority. It can guide interaction, but the service executing the operation should continue enforcing current rules and permissions.

Should every decision detail be shown?

No. Explain what is necessary for the next step within permitted access. Internal diagnostics and restricted resource information need their own treatment.

Start your project

Need a website that earns trust, ranks in search, and gives your business a stronger digital presence? Start the conversation here.

Official sources used on this page