> ## Documentation Index
> Fetch the complete documentation index at: https://developers.redo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# upsertMarket

> Create a market, or update one when `id` is given. Returns null if no market with that id is owned by the caller. Adding a country sets it up on the store's sales channel, so this can take several seconds. Removing a country tears down its Shopify market, catalog and price list. Throws a 400 error with an extension code of MARKET_COUNTRIES_REQUIRED, DUPLICATE_MARKET_COUNTRY, MARKET_COUNTRY_ADDED_AND_REMOVED, MARKET_COUNTRY_NOT_IN_MARKET, INVALID_MARKUP, or INVALID_MARKET_SETTINGS when the input is invalid (settings are checked against the market as it would be after the update), a 400 error with an extension code of UNEXPECTED_MARKET_RESOLUTION for a resolution no conflict needs, a 409 CONFLICT error (with an extension code of MARKET_COUNTRY_IN_USE) when a country already belongs to another market, and a 409 CONFLICT error (with an extension code of MARKET_COUNTRY_CONFLICT and a `conflicts` extension listing, per country, the conflicting Shopify market handle, its other countries, a `reason` sentence explaining the conflict, and `allowedResolutions` as `{ kind, effect }` pairs whose `effect` says what that choice does to the merchant's Shopify market) when a country being added is in one of the merchant's own Shopify markets without an allowed resolution. Nothing is written when a request fails.

**Required scopes:** [`markets_write`](/docs/api-reference/v3/reference/scopes#scope-markets_write)

## Arguments

<ResponseField name="id" type="ID">
  The id of the market to update. Omit to create one.
</ResponseField>

<ResponseField name="input" type={<a href="/docs/api-reference/v3/reference/markets/upsert-market-input">UpsertMarketInput!</a>} required>
  The market's settings.

  <Expandable title="fields" lazyRender>
    <ResponseField name="addCountryCodes" type={<a href="/docs/api-reference/v3/reference/common/country-code">[CountryCode!]</a>}>
      Destination countries to add. Required when creating. A country can belong to only one market; adding one this market already has does nothing. Each new country is set up as a market, catalog and price list on the store's sales channel. If a country is already in one of the merchant's own Shopify markets, the request fails with MARKET\_COUNTRY\_CONFLICT until `resolutions` says what to do with it.
    </ResponseField>

    <ResponseField name="breakdownDisplay" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-breakdown-display">LandedCostBreakdownDisplay</a>}>
      How uncharged landed-cost lines appear in the checkout breakdown. Defaults to REMOVE.
    </ResponseField>

    <ResponseField name="breakdownLabels" type={<a href="/docs/api-reference/v3/reference/markets/market-breakdown-labels-input">MarketBreakdownLabelsInput</a>}>
      Replaces the custom checkout breakdown labels. Send an empty object to restore the defaults.

      <Expandable title="fields" lazyRender>
        <ResponseField name="dutiesAndFees" type="String">
          The label for the duties and fees line.
        </ResponseField>

        <ResponseField name="shipping" type="String">
          The label for the shipping line.
        </ResponseField>

        <ResponseField name="taxes" type="String">
          The label for the taxes line.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="coveredByMarkup" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-component">[LandedCostComponent!]</a>}>
      Landed-cost components whose checkout charge the markup absorbs, in order. Must not overlap `includedInPrice`.
    </ResponseField>

    <ResponseField name="enabled" type="Boolean">
      Whether the market's pricing is live. Defaults to false.
    </ResponseField>

    <ResponseField name="excludedFromCheckout" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-component">[LandedCostComponent!]</a>}>
      Landed-cost components neither charged nor shown at checkout. Must not overlap `includedInPrice`.
    </ResponseField>

    <ResponseField name="includedInPrice" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-component">[LandedCostComponent!]</a>}>
      Landed-cost components to bake into product prices. FEES is only allowed with ADAPTIVE\_COEFFICIENT, which requires either TAXES alone or all three.
    </ResponseField>

    <ResponseField name="markup" type={<a href="/docs/api-reference/v3/reference/common/decimal">Decimal</a>}>
      The markup on the base price, as a fraction from "0" to "1" with at most 6 decimal places (e.g. "0.1" for 10%). Defaults to 0.
    </ResponseField>

    <ResponseField name="markupStrategy" type={<a href="/docs/api-reference/v3/reference/markets/market-markup-strategy">MarketMarkupStrategy</a>}>
      How the markup combines with the landed cost. Defaults to ABSORBING.
    </ResponseField>

    <ResponseField name="name" type="String">
      The market's name. Send null or an empty string to clear.
    </ResponseField>

    <ResponseField name="pricingMode" type={<a href="/docs/api-reference/v3/reference/markets/market-pricing-mode">MarketPricingMode</a>}>
      How landed costs are turned into prices. Defaults to COEFFICIENT, or CALCULATED when `includedInPrice` is set.
    </ResponseField>

    <ResponseField name="removeCountryCodes" type={<a href="/docs/api-reference/v3/reference/common/country-code">[CountryCode!]</a>}>
      Destination countries to remove. Not allowed when creating, and each must currently be in the market. Removing a country tears down its Shopify market, catalog and price list, so shoppers there stop seeing this market's prices. The market must keep at least one country.
    </ResponseField>

    <ResponseField name="resolutions" type={<a href="/docs/api-reference/v3/reference/markets/market-country-conflict-resolution-input">[MarketCountryConflictResolutionInput!]</a>}>
      Resolutions for countries in `addCountryCodes` that are already in one of the merchant's own Shopify markets, as reported in a MARKET\_COUNTRY\_CONFLICT error: each conflict's `reason` explains it, and each of its `allowedResolutions` gives a `kind` to send here with an `effect` describing the outcome. TAKE\_OVER adopts that Shopify market; ARCHIVE\_EXISTING sets it to draft; REMOVE\_REGION removes the country from it. Naming a country without such a conflict fails with UNEXPECTED\_MARKET\_RESOLUTION.

      <Expandable title="fields" lazyRender>
        <ResponseField name="countryCode" type={<a href="/docs/api-reference/v3/reference/common/country-code">CountryCode!</a>} required>
          A country in `addCountryCodes`.
        </ResponseField>

        <ResponseField name="kind" type={<a href="/docs/api-reference/v3/reference/markets/market-country-conflict-resolution-kind">MarketCountryConflictResolutionKind!</a>} required>
          The resolution. Must be a `kind` from the conflict's `allowedResolutions`; its `effect` says what happens to the merchant's Shopify market.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Returns

<ResponseField name="upsertMarket" type={<a href="/docs/api-reference/v3/reference/markets/market">Market</a>}>
  A cross-border market: a set of destination countries that share one landed-cost pricing policy.

  <Expandable title="fields" lazyRender>
    <ResponseField name="breakdownDisplay" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-breakdown-display">LandedCostBreakdownDisplay!</a>} required>
      How uncharged landed-cost lines appear in the checkout breakdown.
    </ResponseField>

    <ResponseField name="breakdownLabels" type={<a href="/docs/api-reference/v3/reference/markets/market-breakdown-labels">MarketBreakdownLabels!</a>} required>
      Custom labels for the checkout landed-cost breakdown.

      <Expandable title="fields" lazyRender>
        <ResponseField name="dutiesAndFees" type="String">
          The label for the duties and fees line.
        </ResponseField>

        <ResponseField name="shipping" type="String">
          The label for the shipping line.
        </ResponseField>

        <ResponseField name="taxes" type="String">
          The label for the taxes line.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="countries" type={<a href="/docs/api-reference/v3/reference/markets/market-country">[MarketCountry!]!</a>} required>
      The destination countries this market sells into.

      <Expandable title="fields" lazyRender>
        <ResponseField name="countryCode" type={<a href="/docs/api-reference/v3/reference/common/country-code">CountryCode!</a>} required>
          The destination country.
        </ResponseField>

        <ResponseField name="createdAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime!</a>} required>
          When the country was added to the market.
        </ResponseField>

        <ResponseField name="currency" type="String">
          The ISO 4217 currency shoppers in this country are charged in. Null until the country has been set up on the sales channel.
        </ResponseField>

        <ResponseField name="updatedAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime!</a>} required>
          When the record was last updated.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="coveredByMarkup" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-component">[LandedCostComponent!]!</a>} required>
      Landed-cost components whose checkout charge is absorbed by the markup, drawn down in order.
    </ResponseField>

    <ResponseField name="createdAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime!</a>} required>
      When the record was created.
    </ResponseField>

    <ResponseField name="enabled" type="Boolean!" required>
      Whether the market's pricing is live.
    </ResponseField>

    <ResponseField name="excludedFromCheckout" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-component">[LandedCostComponent!]!</a>} required>
      Landed-cost components neither charged nor shown at checkout.
    </ResponseField>

    <ResponseField name="id" type="ID!" required>
      The id of this market.
    </ResponseField>

    <ResponseField name="includedInPrice" type={<a href="/docs/api-reference/v3/reference/markets/landed-cost-component">[LandedCostComponent!]!</a>} required>
      Landed-cost components baked into product prices.
    </ResponseField>

    <ResponseField name="lastSyncedAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime</a>}>
      When prices were last pushed to the sales channel. Null until the first sync.
    </ResponseField>

    <ResponseField name="markup" type={<a href="/docs/api-reference/v3/reference/common/decimal">Decimal!</a>} required>
      The markup on the base price, as a fraction (e.g. "0.1" for 10%).
    </ResponseField>

    <ResponseField name="markupStrategy" type={<a href="/docs/api-reference/v3/reference/markets/market-markup-strategy">MarketMarkupStrategy!</a>} required>
      How the markup combines with the landed cost in the price.
    </ResponseField>

    <ResponseField name="name" type="String">
      The merchant-set name. Null when unnamed; the countries then identify the market.
    </ResponseField>

    <ResponseField name="pricingMode" type={<a href="/docs/api-reference/v3/reference/markets/market-pricing-mode">MarketPricingMode!</a>} required>
      How landed costs are turned into prices.
    </ResponseField>

    <ResponseField name="shopCurrency" type="String!" required>
      The ISO 4217 currency of the store's base prices, which the market's prices are converted from.
    </ResponseField>

    <ResponseField name="updatedAt" type={<a href="/docs/api-reference/v3/reference/common/date-time">DateTime!</a>} required>
      When the record was last updated.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

```graphql theme={null}
mutation {
  upsertMarket(id: "...", input: { ... }) {
    breakdownDisplay
    coveredByMarkup
    createdAt
    enabled
    excludedFromCheckout
    id
    includedInPrice
    lastSyncedAt
    # ...
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.