Tracking jobs

Background operations — track them with GET or through the webhook (job.completed, job.partially_completed, job.failed).

Everything that depends on the marketplace runs in the background, as a job. The API answers right away; the work goes on afterwards.

There are several job types (list in States and events). The most common is connection.sync, started for each connected account. Its id arrives in data.syncJobId: in the connection.created event, and in connection.updated when the seller connects the same account again.

Two ways to track

  1. Through the webhook (recommended): subscribe your endpoint to job.completed, job.partially_completed and job.failed (or *). Each final status has its own event: job.completed only arrives when every item succeeded. The event carries the whole job. See Receiving webhooks.
  2. By polling: Get a job with the id. JOB_ID is the data.syncJobId of the connection.created event (or of the connection.updated of a reconnection). Wait a few seconds between calls.
curl $BACKEND_URL/v1/jobs/$JOB_ID \
  -H "Authorization: Bearer mk_your_api_key"

Outcome

The final status tells how it went: completed (every item succeeded), partial (some failed) or failed (none succeeded). Each job has items with their own outcome: the failed ones are in List items with status=failed. States and rules are in Jobs.

With an account that has no subscription in good standing, a commercial job already queued (publication, removal, offer action, MarketplaceProduct publication, promotion) or an explicit stock request ends with failed items and error PAYMENT_REQUIRED: Subscription required. Add a payment method in the dashboard., with no marketplace call. Reactivate in Billing and send the command again, with a new Idempotency-Key: with the same key, within 24 h, the API returns the old job (Idempotency-Replayed: true, see Idempotency). Details in Billing.

In automatic stock publication, the item of a blocked account keeps going and carries result.billingSafetyContinuation: true: only the quantity was sent, so the marketplace does not keep a wrong stock. The same goes for the job of a movement with publishTargets, for the items whose binding automatic publication would pick; the other items end failed with PAYMENT_REQUIRED. The job closes as partial if there are items of both kinds, failed if none keeps going and completed if all do.

A job can stay running longer when the marketplace limits how many calls we can make. The remaining items wait for the quota to come back, then go on. The job does not fail because of it. The same goes for a Mercado Livre publication that retries right after a creation with no result seen: it waits a few minutes, the item stays pending and no attempt is spent (more).

A publication that failed midway

Publishing has steps (steps on the item): for example content, offer and inventory. At Mercado Livre they are pictures, items and descriptions (see the steps). If one fails, the item is failed, with the steps that worked marked succeeded, and error gives the reason (format).

A refusal decided before any write (such as offer_group_taken, on Mercado Livre: another offer of the same product already holds the group, quantity_required: the Variant's stock is not in marketapi, listing_type_required: listingTypeId is missing, or description_not_plain_text: the description has an HTML tag) leaves no step done and is not retried: the item ends failed with MarketplaceError: VALIDATION (offer_group_taken). Fix the offer and publish again (reasons).

On the next attempt (a new publication, or the batch) the publication resumes from the step that stopped: the ones that already worked are not redone, and their externalRef is reused. That is why the retry does not create a second product at the marketplace. The new attempt shows up in attempts with its own steps.

An item that a blocked account stops from publishing, on a resource whose previous attempt failed, inherits that attempt's succeeded steps, with their original times, and ends failed with PAYMENT_REQUIRED.

A marketplace action

An action (pause, activate, close, relist) is a single call, and it is the item's one step, named after the action. If the job is interrupted after the marketplace ran the action, it carries on by reading the offer as it was left, without running the action again or writing the activity entry or the event twice.

On relist, the step's externalRef is the ID of the new offer. If the item fails after the marketplace created that offer, the next relist of the same Listing uses that offer instead of creating another, even with other actions on the Listing in between. If that offer is gone from the marketplace, that relist fails with the step failed, and the one after it creates a new offer. If you import the new offer (POST /v1/connections/{id}/listing-imports) before the job resumes, the imported Listing stays as it is: the resume only completes the relisted_from relation and the relisted activity on the old one, and the item returns the imported Listing.