Request Constraints¶
After capabilities and extensions are negotiated, the resolved request schema
defines the fields and structure allowed for each operation. In an
authoritative response, a Business can use ucp.request_constraints to signal
additional rules it will apply to the Platform's next request — for
example, constraining a line's quantity to exactly 100 sale-basis steps, or
requiring billing_address on a submitted payment instrument. The Platform can
evaluate these constraints before submitting the request (preflight) and
avoid a round trip the Business has already indicated it will reject.
ucp.request_constraints is used only in authoritative operation
responses. It has no effect in discovery profiles or requests. It is optional
for the Business and optional for the Platform.
This page also documents the reserved ucp member at nested scopes and the
map_order annotation, which share the same mechanism.
The Reserved ucp Member¶
The member name ucp is reserved as the protocol namespace in every
structured BCP object scope — an object whose members are schema-defined
fields. The top-level ucp that profiles and responses carry is just the root
manifestation of this namespace. The key keeps the name ucp inherited from
UCP for wire compatibility (it is one of the fork's allowed residues); its
contents are defined by the BCP core in schemas/ucp.json#/$defs/members.
- The reservation does not apply to dictionaries, whose keys are data: a
ucpkey inattribution, for example, is ordinary data. - Schema authors MUST NOT define a domain field named
ucpin structured objects or extensions. - The
ucpcontainer is open: consumers MUST ignore members they do not recognize. Openness exists so documents from newer protocol versions remain readable — it is not extension space. Only the protocol core defines members insideucp; extension authors MUST NOT place data there. - Producers MUST NOT emit
ucp.ucp; if present, the receiver MUST ignore it. - Outside the root, the Business and Platform MAY omit the member at any scope. Every member admitted to the vocabulary is safe to ignore: a receiver that does not process it loses only that member's benefit, never correctness.
Today the vocabulary has two members, both response-only
(ucp_request: omit): request_constraints and map_order.
Validation Model¶
A submitted request is valid under the constraints only if it satisfies the resolved request schema and every object selected by the constraints satisfies the corresponding expression. Constraints only narrow the resolved schema; they never make valid a request that the schema rejects.
valid = validate(resolved_request_schema, request)
for each constraint:
objects = select(request, effective_path(constraint))
valid = valid AND validate_all(expression(constraint), objects)
return valid
The Platform MAY perform the same checks as preflight. For each chosen value, it MUST use the effective path and the complete expression. The Platform MAY submit the request regardless of the preflight result; the Business's evaluation is authoritative.
Constraint Expression¶
A request_constraints value and every nested constraint object use an
embedded, closed JSON Schema Draft 2020-12 language. The outer value may
additionally contain an optional path; nested objects may not. The grammar
does not admit ucp. Keys in properties name fields on the selected request
objects.
| Position | Admitted members | Shape and behavior |
|---|---|---|
| Object Constraint | required, properties, anyOf |
required is an array of unique field names. properties maps field names to Object or Value Constraints. anyOf is a non-empty array of non-empty Object Constraints, at least one of which the object must satisfy. |
| Value Constraint | enum, const |
enum is a non-empty array of unique JSON values; const is any JSON value. At least one of the two is present; when both are present, both apply. |
No other member is admitted at either position.
Members present at the same Object Constraint all apply. anyOf does not
replace its siblings: the object must satisfy every sibling member and at
least one branch. Branches are alternatives, not a partition. Within a branch,
properties constrains a member only when it is present; for a branch to match
only the shape it describes, also name the discriminator in required.
The grammar is independent of the object it is bound to. Request constraints
bind it to objects in the next request and add path; other schemas reuse it
where the declaration already identifies the object, such as
available_instruments[].constraints in payment handlers.
request_constraints¶
See Request Constraints in the Schema Reference for the canonical field definition.
Value Constraint¶
Constraint Expression Value Constraint
Path¶
Every request_constraints value has exactly one effective path:
- Without
path, the effective path is the RFC 9535 Normalized Path from the response root to the structured object whoseucpmember containsrequest_constraints. At the response root, that is$. - With
path, the provided value supersedes the derived one; the Business MUST use a complete RFC 9535 JSONPath query.
In both cases, the path is evaluated against the next logical request to the
same resource — unlike messages[].path, which is evaluated against the
response itself.
An omitted path establishes correspondence by position, not stable
identity: an index still points to that position if items are reordered. The
Business MUST provide an explicit path when the Normalized Path does not
identify the intended objects, and MUST use a query that encodes identity
(for example, a filter on id) when the constraint has to follow a specific
object. When building the query from data, the Business MUST serialize and
escape each value as a valid RFC 9535 literal and MUST NOT use unsafe
string concatenation.
Before emitting a value, the Business MUST validate it against the shared request constraints schema, and the Platform MUST do the same before using it for preflight. A path that selects nothing has no effect. If several paths select the same object, every expression applies; the Business MUST ensure they are jointly satisfiable — contradictory requirements on the same property are an authoring error. There is no precedence or override.
Guidelines¶
Business¶
- MAY include
ucp.request_constraintsin an authoritative response to describe rules it will enforce against the next request. - MUST emit values conforming to the shared schema, with effective paths that select only objects, and MUST enforce every constraint it emits.
- SHOULD NOT emit constraints for rules that may change before the next
request, unless it can continue to enforce them. Execution-time conditions —
inventory, fraud, payment authorization — remain governed by the operation's
outcomes and
messages.
Platform¶
- MAY use
ucp.request_constraintsfor preflight, evaluating any supported subset. Preflight is optional and advisory. - A malformed or unsupported value, a value whose path selects a non-object, or one that exceeds the Platform's resource limits is unavailable for preflight — not a pass or a failure. The Platform MUST skip the whole value and continue with the others.
- A successful preflight result covers only the evaluated values. The protocol defines no wire status or marker for the preflight result.
Scope and Lifecycle¶
Each authoritative response for a resource supplies the constraint set for the
next request to that resource. The response to that request supplies the
following set and replaces the previous one. Omission clears the set.
Invalid values in the new set do not preserve old values, and sets are not
merged by path. Only values attached to eligible structured objects count;
dictionary keys are data.
A response without an authoritative resource supplies no set. A response with an authoritative resource supplies the set even when it reports an application error.
Constraints provide proactive preflight; messages report the outcome of a
submitted request. Passing both the schema and the constraints establishes only
schema validity — the request can still fail other Business rules. Constraints
add no new error code or outcome.
Examples¶
Fixed Quantity on Every Line¶
The constraint at the cart root applies quantity 1 to every line in the next
request:
{
"ucp": {
"version": "2026-11-16",
"request_constraints": {
"path": "$['line_items'][*]",
"properties": {
"quantity": { "const": 1 }
}
}
},
"id": "cart_123",
"line_items": [
{
"id": "line_123",
"item": { "id": "sku_123", "title": "Bulk fasteners", "price": 1200 },
"quantity": 1,
"totals": [
{ "type": "subtotal", "amount": 1200 },
{ "type": "total", "amount": 1200 }
]
}
],
"currency": "BRL",
"totals": [
{ "type": "subtotal", "amount": 1200 },
{ "type": "total", "amount": 1200 }
]
}
Fixed Quantity on a Specific Line¶
The constraint sits in the line's own ucp and uses a filter on id, which
survives reordering. If the filter does not match, the constraint has no
effect:
{
"ucp": { "version": "2026-11-16" },
"id": "cart_123",
"line_items": [
{
"id": "line_123",
"item": { "id": "sku_123", "title": "Bulk fasteners", "price": 1200 },
"quantity": 100,
"totals": [
{ "type": "subtotal", "amount": 120000 },
{ "type": "total", "amount": 120000 }
],
"ucp": {
"request_constraints": {
"path": "$['line_items'][?@['id'] == 'line_123']",
"properties": {
"quantity": { "const": 100 }
}
}
}
}
],
"currency": "BRL",
"totals": [
{ "type": "subtotal", "amount": 120000 },
{ "type": "total", "amount": 120000 }
]
}
The two examples are alternative responses; combining them would create
contradictory constraints for line_123, which is an authoring error.
Billing Address on a Card Instrument¶
A Business can attach the constraint to an available instrument declared in
the handler, requiring billing_address on every submitted instrument that
matches the filter. The example is illustrative and defines no card brands,
credentials, or payment policy; the BCP reference payment method remains
Pix.
{
"type": "card",
"ucp": {
"request_constraints": {
"path": "$['payment']['instruments'][?@['handler_id'] == 'processor_1' && @['type'] == 'card']",
"required": ["billing_address"]
}
}
}
Alternative Requirements with anyOf¶
Each branch pins the credential's type discriminator with const; the object
must satisfy the sibling required and at least one branch:
{
"type": "card",
"ucp": {
"request_constraints": {
"path": "$['payment']['instruments'][?@['handler_id'] == 'processor_1' && @['type'] == 'card']",
"required": ["credential"],
"properties": {
"credential": {
"anyOf": [
{
"properties": { "type": { "const": "pan" } },
"required": ["cvc"]
},
{
"properties": { "type": { "const": "network_token" } },
"required": ["cryptogram", "eci_value"]
}
]
}
}
}
}
}
Two separate constraints could not express this rule: constraints add up, so
one requiring cvc and another requiring cryptogram would require both.
map_order¶
Optional; not used by BCP profiles
map_order is vendored in the schema and accepted by the protocol, but
the BCP profiles, fixtures, and playground do not use it. Ignoring it
is always safe: the consumer simply traverses the map with no declared
order.
JSON object members are unordered, and RFC 8785 (JCS) canonicalization, used in
signatures, sorts keys. map_order uses an array so that the declared order
survives canonicalization and signing.
map_order declares a preferred traversal order for map-valued fields in
the scope annotated by its containing ucp. At a nested scope, each key of
map_order names a map field on the object that contains ucp; at the root,
it names a sibling map inside the ucp envelope (services,
capabilities, payment_handlers). Each value is an array of the target map's
keys in preferred order. It does not apply to requests.
Rules for a field <field> and the array map_order.<field>:
- Producers MUST NOT rely on JSON object member order;
map_orderis the order carrier. - The array MAY be partial: listed keys come first, in array order; unlisted keys remain valid and come after, in the field-defined order or, absent one, in RFC 8785 name order.
- The array is not an allowlist: consumers MUST NOT interpret omission of a key as removal, ineligibility, or reduced support.
- Producers MUST name a present, map-valued target and list only present
keys; receivers MUST NOT reject the document over an unusable entry — if
they process
map_order, they ignore the entry. - Producers MUST NOT repeat keys; consumers honor the first occurrence.
- Without
map_order(or without the field's entry), no order is declared, and consumers MUST NOT fall back to object member order. - What the order means is defined by each field;
map_orderonly carries the order. The only meaning defined today is the Business's presentation preference forpayment_handlers.
Shape example (illustrative; BCP profiles do not use it):
{
"ucp": {
"version": "2026-11-16",
"payment_handlers": {
"br.dev.bcp.pix": [
{ "id": "pix_recebedor_001", "version": "2026-11-16" }
],
"com.example.card_handler": [
{ "id": "card_handler", "version": "2026-11-16" }
]
},
"map_order": {
"payment_handlers": ["br.dev.bcp.pix", "com.example.card_handler"]
}
}
}