Listings

Compare desired and observed

Shows, per group, what changed here and what changed on the marketplace.

GET
/v1/listings/{listingId}/diff

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.

stateMeansWhat it asks of you
in_syncNeither side changed since the last publication.Nothing.
pending_publicationYou changed it here and have not published yet, or the marketplace did not keep what you published.Publish.
external_changeIt changed on the marketplace and you did not touch this group.Decide: copy the observed value into desired, or publish to impose yours.
conflictBoth sides changed, or there is an open conflict on the group.Resolve the conflict.
never_publishedThe group was never published: there is no base to compare with.Publish.

Watch out

  • in_sync never has changedPaths, and a group with changedPaths is never in_sync. This holds for content, offer, inventory and catalog. status and never_published are 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 stays in_sync and the new value shows in observed. 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> in changedPaths says 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 value observed shows 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 as lines.<bindingId> in offer and in inventory, with pending_publication.

  • Marketplace options are part of offer. marketplaceOptions is in desired, in observed and in the baseline of the last publication. The path is marketplaceOptions.<key>, and Mercado Livre sale terms are marketplaceOptions.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.marketplaceOptions can carry saleTermLabels, read only: the text of each value listed in saleTerms.

  • The group's value in observed. For a key the lines inherit from the Listing, observed shows 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 lowest bindingId). 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>.priceInCents and priceInCents. Each item of observed.lines[] carries the offer and marketplaceOptions of 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 in changedPaths, editing it changes nothing, and the group stays in_sync and the listing clean.

  • 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 with inherit (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 in changedPaths, and observed carries the marketplace value next to yours. Two ways out: copy the observed value into desired (the group goes back to in_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 stays in_sync. Text is compared by its exact value: an extra space or line break is already a different value.

  • media is compared by the ids the marketplace gave your pictures. A published picture does not show as a difference. media only enters changedPaths when the local list and the marketplace list really differ.

  • Variations: variants.<id> and variationAxes enter changedPaths in content when 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 (except status) with no path is in_sync even 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 inventory group stays pending_publication, with the line path in changedPaths, and does not become in_sync. A sale on ML between creation and the re-read shows as external_change in inventory, with the line (ML limitation).

  • Only content and offer become conflict. In catalog and inventory, with both sides changed, the state is pending_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 inventory group only compares the desired value with what was published: pending_publication until the job sends the number, then in_sync, never external_change or conflict. A change made outside becomes a stock discrepancy, per location. Without stock per location, nothing changes.

  • status has no desired value (desired is null). It only goes to external_change when the marketplace changes the status. The reason is in issues.

  • The title (title) appears in changedPaths when 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, title shows whenever it is set. On Mercado Livre, once the title is published it leaves the diff. If ML stores a family name with other words at creation (the catalog name, for example), that text becomes the published title: the diff shows title as pending, and to change the title you send ML's text.

  • changedPaths lists only what you set and that differs from observed: the keys of the value and, inside it, attributes.<key> (in content) and lines.<identity> (in inventory).

  • conflict in content or offer always 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.

Authorization

api_key
headerAuthorizationBearer <token>

API key (mk_...)

Path Parameters

listingId*string
Match^([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)$
Formatuuid

Response Body

The five groups, always in the same order.

application/json
  1. response

The offer compared with the marketplace, group by group. Calculated on read; it does not call the marketplace.

listingId*string

The listing compared.

Match^([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)$
Formatuuid
marketplaceProductId*string

The marketplace product whose content and catalog are compared.

Match^([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)$
Formatuuid
groups*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      }    }  ]}