Skip to content

Policies and Actions

This page describes two shared blocks that appear in cart, checkout, catalog, and order responses:

  • policies[]: a declarative snapshot of the business rules that apply to the items in the response at the time of purchase — returns and refunds, warranty, and the like.
  • actions: outstanding, out-of-band work that the Platform needs to process, defined by an active extension (for example, a verification or an authentication challenge).

Both are optional. Neither creates a new obligation for those who do not use them.

Policies

A policy is a business rule — return terms, warranty, subscription terms, and the like — that applies to the items in a response at the time of purchase. It is carried in the core policies[] array, alongside messages[] and links[].

policies[] is reference data: it describes the terms, it does not execute them. In BCP, the post-sale return operation (legal deadline, reason, reverse logistics, recording on the order) remains the responsibility of the Brazilian returns extension (br.dev.bcp.shopping.returns). A policy of type br.dev.bcp.shopping.policy.return only summarizes, for presentation, the terms that apply to the items in that response.

Schema

See Policy in the Schema Reference for the canonical field definition.

Policy Types

Every policy carries a type drawn from an open, reverse-DNS vocabulary.

Well-known type Description
br.dev.bcp.shopping.policy.return Return terms.
br.dev.bcp.shopping.policy.warranty Warranty terms.

A Business MAY define custom types in its own domain (e.g., com.example.policy.price_match) and MAY add type-specific fields that a Platform modeling that type can read. Because the vocabulary is open, a Platform MUST tolerate unknown type values, presenting the policy from its description (see Presenting Policies).

Targeting (applies_to)

applies_to is an array of RFC 9535 JSONPath expressions, evaluated relative to the root of the response containing the policy — the same convention messages[].path uses. The root differs by surface: $.line_items[N] on cart, checkout, and order; $.products[N] on catalog search and lookup; $.product on get_product. A policy targets nodes in one of three forms:

  • Singular query: an expression naming exactly one node using only name and index selectors (RFC 9535 §2.3.5.1), e.g. $.line_items[2].
  • Set match: a filter, wildcard, or slice matching a set of nodes, e.g. $.products[?@.category=='electronics'].
  • Response-wide: an omitted applies_to; the policy applies to the entire response. This is the common case: a site-wide policy is one entry with no targeting, never repeated per item.

A target covers the node it names and everything nested under it — a policy on $.products[0] covers the product and all its variants; one on $.products[0].variants[3] covers only that variant.

Precedence

Policies of different type are independent: a single node can carry a warranty policy and a price-match policy at once.

Policies of the same type can contest a node. When they do, exactly one governs and replaces the rest — a Platform MUST NOT merge their bodies. When terms genuinely stack, the Business folds them into the most-specific policy: composition is authored by the Business, not inferred by the Platform. The choice is a longest-prefix match against the response in hand:

  1. Take the same-type policies whose target covers the node. A Response-wide policy targets the root $ and covers every node at depth 0. If none cover the node, no policy of that type governs it.
  2. Score each by its deepest covering match as the pair (depth, precision): depth is the length of the matched Normalized Path (RFC 9535 §2.7) prefix; precision is 1 for a singular query and 0 for a set match.
  3. The policy with the greatest score governs — depth first, then precision.
  4. A tie at the greatest score has an undefined outcome: it is an authoring error (two overlapping set matches, or two Response-wide entries of the same type). A Business MUST NOT publish such a collision; a Platform SHOULD flag the ambiguity rather than resolve it silently.

Absent vs. Empty

When policies[] is absent or empty, the Platform SHOULD refer to the general policy resources in links[] (e.g., refund_policy, or per-variant seller.links in catalog).

Presenting Policies

A Platform MAY reason over policies for its own decisions — eligibility, a computed return deadline. So that every policy is presentable even by a Platform that does not model its type, a Business MUST provide a description, a human-readable summary a Platform MAY surface to the Buyer. Presenting a policy is optional.

When a Business requires a condition to be shown to the Buyer — a non-returnable item, a regulatory notice — it MUST emit a messages[] warning that:

  • sets presentation: "disclosure", so the Platform displays the content and cannot hide or dismiss it (see Warning Presentation);
  • sets path to the item the notice concerns; and
  • sets code to the policy's type, linking the notice to its policy.

The notice pairs with the policy that governs its path node under Precedence. The notice's content MUST agree with that policy, and the notice SHOULD have a corresponding policy.

This page defines no new rule about the right of withdrawal (Consumer Defense Code art. 49); legal deadlines and conditions follow the returns extension.

In the example below, a return policy applies to the whole checkout, and a more specific policy marks the custom item on line 2 as non-exchangeable; the notice on that line pairs with it:

[
  {
    "type": "br.dev.bcp.shopping.policy.return",
    "description": { "plain": "Free returns within 30 days of delivery." }
  },
  {
    "type": "br.dev.bcp.shopping.policy.return",
    "description": { "plain": "This item was engraved to order and cannot be exchanged for change of mind." },
    "applies_to": ["$.line_items[2]"],
    "url": "https://loja.example.com.br/trocas#personalizados"
  }
]
[
  {
    "type": "warning",
    "code": "br.dev.bcp.shopping.policy.return",
    "path": "$.line_items[2]",
    "presentation": "disclosure",
    "content": "This item was engraved to order and cannot be exchanged for change of mind."
  }
]

links[] and policies[] are complementary. links[] is the always-present fallback — a labeled URL, response-wide, usually one per type. policies[] is the structured layer when available — typed, with optional per-item targeting and multiple entries (a general default plus exceptions).

Examples

A general warranty with a per-item exception, both the same type. On line 2 the singular query governs; the other lines keep the general warranty:

[
  {
    "type": "br.dev.bcp.shopping.policy.warranty",
    "description": { "plain": "1-year warranty on all items." }
  },
  {
    "type": "br.dev.bcp.shopping.policy.warranty",
    "description": { "plain": "3-year extended warranty on this item." },
    "applies_to": ["$.line_items[2]"]
  }
]

A custom type a Platform does not model is still presentable from its description:

[
  {
    "type": "com.example.policy.price_match",
    "description": { "plain": "We match a competitor's lower price for 14 days after purchase." },
    "applies_to": ["$.products[0]"]
  }
]

Actions

An Action is an outstanding unit of extension-defined work for a Platform to process. Its presence means the effect defined by its type is gated until the work is done. Actions appear only in responses, under the actions map. The common fields identify the work but do not define how to process it; the active extension does.

The shape is reusable, but a capability supports Actions only when its specification explicitly adopts it and defines the specific behavior: where Actions appear, the effect each type gates, how Messages apply, and how a later response reflects processing. Schema composition alone does not establish support. Cart, Checkout, and Catalog adopt the shape (see Eligibility Verification at Completion for a complete checkout flow).

Schema

The actions map is keyed by Action type (reverse-DNS); each value is a non-empty array of outstanding instances of that type. Each instance has:

Actions Instance

Actions and Messages

Actions and Messages have different roles. An Action represents outstanding work: it carries an identity and extension-owned processing configuration. A Message communicates explanatory or diagnostic context about the current response and can identify an exact Action occurrence through its path (RFC 9535, relative to the response root). Messages do not define how the Action is processed, and neither requires the other.

{
  "actions": {
    "com.example.identity.student_verification": [
      {
        "id": "verify-student-1",
        "config": {
          "verification_url": "https://loja.example.com.br/verificar/abc"
        }
      }
    ]
  },
  "messages": [
    {
      "type": "info",
      "code": "eligibility_accepted",
      "content": "Student discount applied provisionally. Verify your status.",
      "path": "$.actions['com.example.identity.student_verification'][0]"
    }
  ]
}

Rules

  • For a newly processed successful response from a capability that adopts Actions, the Business MUST include every outstanding Action and MUST omit actions when none are outstanding.
  • An Action's gate and the operation outcome are orthogonal: neither the resource status nor a Message's type or severity determines whether the Action gates its effect. For a state-changing operation whose requested effect was not applied because of an Action, the Business MUST return the current resource with a recoverable error Message whose path selects the exact Action occurrence.
  • When an Action prevents a Cart or Checkout operation, processing it does not repeat the operation. To try again, the Platform submits a new operation under the Replay Protection rules.
  • Each actions key is a reverse-DNS Action type, which follows the Namespace Governance rules: an extension can declare only types within a namespace controlled by its schema authority. An extension can declare several types. The map defines no processing order across types; within a type, the extension defines whether array order carries meaning.
  • The Business MUST use a distinct id for each instance in a response. While the same work remains outstanding on the same resource, the Business MUST keep the same type and id; replacement work MUST have a new id, and an id MUST NOT be reused during the resource's lifetime.
  • The Business MUST emit an Action type only when the extension that declares it is active in the capability's negotiated intersection.
  • The Platform MUST tolerate and ignore instance fields it does not recognize.

Trust and Execution Boundaries

Negotiating an extension confirms support for the complete contract of its Action types, but does not make every runtime value trusted. Each instance remains subject to the composed schema, the type's contract, and Platform policy.

  • A Platform MUST NOT treat any field other than the config fields defined by the active contract as an instruction to load content, render HTML, execute code, run a command, or invoke a native API.
  • A Platform MAY apply its own trust policy and MAY decline any instance that does not satisfy it.
  • A Platform MUST NOT assume that the gated effect was released merely because an external interaction completed. The Business's next response remains the source of truth.

The common Actions contract defines no generic machinery: no URL scheme, origin policy, sandbox, presentation model, timeout, callback, or polling. Each concrete Action type adds only what its processing requires.