Skip to content

Update a product (PATCH)

Open .md

PATCH/v1/api/store/{team_slug}/product/{hash_id}

v1Operation ID v1_public_products_update_patch

Updates a product. A custom variant product's size_data and color_data follow its variants and are not taken here; rename a size or color through variant/rename_options. A variant's own price, weight and vendor are changed with Update a variant.

Use PUT: it checks the fields, and needs type (send the product's type; a product's type never changes). PATCH takes the same body but checks nothing.

Permission

Needs the Manage Products permission at the level that can update products.

Business rules

  • Send vendor_id on every update: leaving it out, or sending an empty string, clears the product's vendor.
  • Send prices as a whole number of thousandths: 12500 is 12.50.
  • Existing sales order lines keep the price they were sold at.
  • Other fields sent as null are dropped, as if left out (for vendor_id that means the vendor is cleared, as above). Send an empty string to blank a text field.

Path parameters

  • team_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team
  • hash_idstringrequired

    The product's id (id from List products). A hash id from an earlier answer; unique keys and document numbers (such as PO0042) don't work here.

    • Example EDhVUaC6jbLbed

Request body

application/json, required.

  • typestringrequired

    Required on PUT: simple or variant. It is not compared with the product and never changes it.

    • One of: "simple", "variant"
  • barcodestring

    The product's barcode. Saved as sent.

  • brandstring

    The product's brand.

  • Send a whole number of thousandths: 12500 is 12.50.

  • A description of the product.

  • price_datamap of objects

    Prices for pricing groups, keyed by pricing group id: {"<pricing group id>": {"price": 11000}}. A line priced with that group uses this price instead of default_price. Send a whole number of thousandths: 11000 is 11.00.

    Fields of each item (1)
    • priceintegerrequired

      Send a whole number of thousandths: 11000 is 11.00.

  • The supplier's code for the product.

  • taxableboolean

    Whether sales tax applies to it.

  • titlestring

    Required on create. The product name shown on orders.

  • vendor_idstring

    The vendor you buy it from.

  • weightnumber

    The product's weight. Simple products only.

Response

200Successful response.

  • dataobjectrequired

    One of, picked by type:

    Simple productsimple
    Variant productvariant
    • typestringrequired
      • Always "variant"
    • color_dataarray of objectsrequired
      Fields of each item (3)
      • idstringrequired
      • labelstring | nullrequired
      • hexstring | null
    • idstringrequired
    • size_dataarray of objectsrequired
      Fields of each item (2)
      • idstringrequired
      • labelstring | nullrequired
    • titlestring | nullrequired
    • trashedbooleanrequired
    • variant_typestringrequired
      • One of: "size", "color", "size_color"
    • brandstring | null
    • default_priceinteger | number | string | null

      Not used for variant products: each variant has its own. Null when not set. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • descriptionstring | null
    • enableboolean
    • supplier_idstring | null
    • taxableboolean
    • vendor_idstring | null
  • statusintegerrequired
  • successbooleanrequired

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You are not allowed to do this. api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only {"message": "Insufficient Permission"}. Other refusals use the error envelope, with unauthorized or user_is_not_authorized.

    When
    Your role cannot update products. This 403 has a short body, {"message": "Insufficient Permission"}, with no success or error.
    Fix
    Ask a team owner to set Manage Products to "Users CAN view, update and create products".
  • 404Not found. page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. code: null, with a message that starts "No query results for": there is no record with that id.

    When
    No live product with this id. error.code is null and error.message names the record type.
    Fix
    Restore a deleted product first.
  • 500A business rule refused the request (see the operation's errors), or something failed inside YoPrint. Refusals use the error envelope with a code such as action_not_allowed; an unexpected failure answers {"message": "Server Error"}. Repeating a refusal gets the same answer; after an unexpected failure, read the record back before you retry a change.

    When
    default_price is not a whole number of thousandths.
    Fix
    Send a whole number: 13500 for 13.50.