Compare desired and observed
Shows, per group, what changed here and what changed on the marketplace.
Shows what is left to publish and what changed on the marketplace, one group at a time. Use it before publishing or after a listing.external_changed notice. The route only reads what MarketAPI already stores: it does not call the marketplace.
curl "$BACKEND_URL/v1/listings/<listingId>/diff" \
-H "Authorization: Bearer mk_your_api_key"The response always has the five groups, in this order: content and catalog (from the MarketplaceProduct), offer, inventory and status (from the offer). One group, shortened:
{
"group": "offer",
"state": "pending_publication",
"changedPaths": ["priceInCents"],
"desired": { "priceInCents": 489900, "currency": "BRL" },
"observed": { "priceInCents": 499900, "currency": "BRL" }
}How to read state
desired and observed almost always differ: the marketplace adds fields you never sent. So each side is compared with what the last publication confirmed. Only what changed since then counts.
state | Means | What it asks of you |
|---|---|---|
in_sync | Neither side changed since the last publication. | Nothing. |
pending_publication | You changed it here and have not published yet. | Publish. |
external_change | It changed on the marketplace and you did not touch this group. | Decide: copy the observed value into desired, or publish to impose yours. |
conflict | Both sides changed, or there is an open conflict on the group. | Resolve the conflict. |
never_published | The group was never published: there is no base to compare with. | Publish. |
Watch out
- Only
contentandofferbecomeconflict. Incatalogandinventory, with both sides changed, the state ispending_publication: the next publication sends your value. Inventory comes from your balance; to undo a change made there, resend the stock. statushas no desired value (desiredisnull). It only goes toexternal_changewhen the marketplace changes the status. The reason is in issues.changedPathslists only what you set and that differs fromobserved: the keys of the value and, inside it,attributes.<key>(incontent) andlines.<identity>(ininventory).conflictincontentorofferalways has a record in conflicts to resolve, whoever moved first: the outside change arriving with your edit pending, or your edit arriving after the outside change.
How it fits: Stay in sync.
api_keyAuthorizationBearer <token>API key (mk_...)
listingId*string^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidThe five groups, always in the same order.
application/json- response
The offer compared with the marketplace, group by group. Calculated on read; it does not call the marketplace.
listingId*stringThe listing compared.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidmarketplaceProductId*stringThe marketplace product whose content and catalog are compared.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidgroups*array<>One entry per group, always in this order: content, catalog, offer, inventory, status.
curl -X GET "https://example.com/v1/listings/497f6eca-6276-4993-bfeb-53cbbbba6f08/diff"{ "listingId": "0e2ce906-a6ab-4101-9461-4168c8b6b902", "marketplaceProductId": "8a6f0c55-6a1e-4c55-9b0a-3b1f2d9e4c10", "groups": [ { "group": "content", "state": "in_sync", "changedPaths": [], "desired": { "title": "iPhone 16", "brand": "Apple" }, "observed": { "title": "iPhone 16", "brand": "Apple" } }, { "group": "catalog", "state": "in_sync", "changedPaths": [], "desired": null, "observed": null }, { "group": "offer", "state": "pending_publication", "changedPaths": [ "priceInCents" ], "desired": { "priceInCents": 489900, "currency": "BRL" }, "observed": { "priceInCents": 499900, "currency": "BRL" } }, { "group": "inventory", "state": "in_sync", "changedPaths": [], "desired": { "lines": { "MLB123": 7 } }, "observed": { "lines": { "MLB123": 7 } } }, { "group": "status", "state": "in_sync", "changedPaths": [], "desired": null, "observed": { "marketplaceStatus": "active", "buyable": true } } ]}