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, or the marketplace did not keep what you published. | 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
-
in_syncnever haschangedPaths, and a group withchangedPathsis neverin_sync. This holds forcontent,offer,inventoryandcatalog.statusandnever_publishedare left out. -
A change on a key you do not define does not take the group out of
in_sync. If the marketplace changes something you never set (a warranty changed in its panel, for example), the group staysin_syncand the new value shows inobserved. This holds for all four groups. -
Offer with lines: on Mercado Livre User Products (and on the
mock), each line is an item of its own, and each item is compared with what the publication sent it.lines.<bindingId>.<key>inchangedPathssays the line's item holds another value for that key: a key the line sets itself, and also one it inherits from the Listing (<key>shows too when the valueobservedshows for it differs from yours). A legacy Mercado Livre item is one item for every line. A line the last publication does not cover (to be created, or removed since) shows aslines.<bindingId>inofferand ininventory, withpending_publication. -
Marketplace options are part of
offer.marketplaceOptionsis indesired, inobservedand in the baseline of the last publication. The path ismarketplaceOptions.<key>, and Mercado Livre sale terms aremarketplaceOptions.saleTerms.<id>. A term that an offer field already covers (warranty,handlingTime,purchaseLimit) is compared through that field only. As with the other paths, only a key you set counts.observed.marketplaceOptionscan carrysaleTermLabels, read only: the text of each value listed insaleTerms. -
The group's value in
observed. For a key the lines inherit from the Listing,observedshows one value: yours, if the item of any of those lines still holds it; otherwise the value most of those items hold (a tie goes to the line with the lowestbindingId). Read order does not matter. A line inherits a key only when it has no own value for it: an own value is own even when it equals the Listing's. If line A owns 4000, the Listing is 4000 and the marketplace moves A's item and the item of an inheriting line B, two paths show:lines.<A>.priceInCentsandpriceInCents. Each item ofobserved.lines[]carries theofferandmarketplaceOptionsof its own item. -
A key no item receives is out of the comparison. If every line sets its own key, or every line's offer replaces the sale term (
warranty,handlingTime,purchaseLimit), the key reaches no item: it is not inchangedPaths, editing it changes nothing, and the group staysin_syncand the listingclean. -
An option only some items hold differently shows as
lines.<bindingId>.marketplaceOptions.<key>(or….saleTerms.<id>): the line's item holds another option than the Listing's. A line holds no options of its own, so this path resolves only withinherit(the item takes the Listing's option again at the next publication). -
The marketplace did not keep what you published? It refused or dropped the value (a warranty that disappears, another category). The group is
pending_publication, the path shows inchangedPaths, andobservedcarries the marketplace value next to yours. Two ways out: copy theobservedvalue intodesired(the group goes back toin_sync), or publish again (your value is sent once more). When the marketplace only normalizes a number (decimal places, such as 19.9 and 19.90), it is the same value and the group staysin_sync. Text is compared by its exact value: an extra space or line break is already a different value. -
mediais compared by the ids the marketplace gave your pictures. A published picture does not show as a difference.mediaonly enterschangedPathswhen the local list and the marketplace list really differ. -
Variations:
variants.<id>andvariationAxesenterchangedPathsincontentwhen the local variation differs from the published one (picture, measure, axes). After publishing, the path leaves. -
Both sides on the same value read
in_sync. A group (exceptstatus) with no path isin_synceven when both sides changed, for example a sale on ML and your stock adjusted to the same number. -
Stock of an existing Mercado Livre item: an update never sends the quantity, so after a stock change the
inventorygroup stayspending_publication, with the line path inchangedPaths, and does not becomein_sync. A sale on ML between creation and the re-read shows asexternal_changeininventory, with the line (ML limitation). -
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. -
Stock per location: on a marketplace that keeps stock per location, the
inventorygroup only compares the desired value with what was published:pending_publicationuntil the job sends the number, thenin_sync, neverexternal_changeorconflict. A change made outside becomes a stock discrepancy, per location. Without stock per location, nothing changes. -
statushas no desired value (desiredisnull). It only goes toexternal_changewhen the marketplace changes the status. The reason is in issues. -
The title (
title) appears inchangedPathswhen your title differs from the one published (exact text, the same rule the publication refuses by), or when the title read from the marketplace no longer has the words of the published one (this side is compared by word list: ignoring case, with punctuation between words only separating them, because the marketplace rewrites the text). Without a published title, yours is compared with the one the creation sent and, without that, with the one the marketplace stores, by exact text. With nothing to compare,titleshows whenever it is set. On Mercado Livre, once the title is published it leaves thediff. If ML stores a family name with other words at creation (the catalog name, for example), that text becomes the published title: thediffshowstitleas pending, and to change the title you send ML's text. -
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 } } ]}