Update Product

PATCH /wp-json/content-api/v1/product/

Updates an existing WooCommerce product.

Authentication

This endpoint requires a Bearer token in the Authorization header. To authenticate:

  1. Go to Content API > Settings in your WordPress admin panel.
  2. Set a secure token in the “Token” field and save it.
  3. Include the token in your request header as follows:
Authorization: Bearer <your-token-here>

Replace <your-token-here> with the token you configured.

Parameters

Name Type Description Required
product_id integer The ID of the product Yes if no sku provided
sku string The SKU of the product Yes if no product_id provided
name string Product name No
status string Status of product (publish, draft, ect) (Requires 1.0.5) No
slug string Product slug No
description string Product description No
short_description string Short description No
price float Regular price No
sale_price float Sale price No
map_price float MAP price of the product (Requires 1.0.4) No
cost float Cost of the product (Requires 1.0.4) No
stock_status string Stock status (e.g., “instock”) No
stock_quantity integer Stock quantity No
tags array Product tags No
categories array Product categories by ID or slug. Replaces current categories. (Requires 1.0.4) No
featured_image string URL of featured image No
images array Gallery image URLs No
yoast object Yoast SEO metadata No

Example Request Using Product ID

{
  "product_id": 123,
  "name": "Sunglasses",
  "slug": "sunglasses",
  "sku": "SUNGLASS-1",
  "description": "Updated description",
  "short_description": "Updated short description",
  "price": 129.99,
  "sale_price": 89.99,
  "map_price": 79.99,
  "cost": 74.99,
  "stock_quantity": 22,
  "tags": ["test1", "test2"],
  "categories": ["test-1", "test-2"],
  "featured_image": "https://www.example.com/featured.jpg",
  "images": [
  "https://www.example.com/example1.jpg",
  "https://www.example.com/example2.jpg"
  ],
  "yoast": {
    "title": "SEO Title",
    "description": "SEO Description",
    "premium": {
    "social_appearance": {
      "title": "Facebook Title",
      "description": "Facebook Description",
      "image": "https://www.example.com/facebook.jpg"
    },
    "x": {
      "title": "Twitter Title",
      "description": "Twitter Description",
      "image": "https://www.example.com/twitter.jpg"
    }
  }
}

Example Response

{
  "success": true,
  "product_id": 123,
  "message": "Product updated successfully"
}

Example Request Using SKU


{
  "sku": "SUNGLASS-1",
  "name": "Sunglasses",
}

Example Response

{
  "success": true,
  "product_id": 123,
  "message": "Product updated successfully"
}

Possible Errors

Code Message Description HTTP Status
not_authorized Not Authorized The provided Bearer token is invalid or does not match the configured token. 401
missing_identifier Product ID or SKU is required Neither a product ID nor SKU was provided in the request body. 400
product_id_invalid Product ID is invalid The provided product ID is not a valid numeric value. 400
sku_invalid SKU is invalid The provided SKU contains invalid characters or is not properly sanitized. 400
conflicting_identifiers Both Product ID and SKU are provided. Please provide only one. Both product ID and SKU were provided in the same request, which is not allowed. 400
product_not_found Product not found No product was found matching the provided product ID. 404
product_not_found Product not found with provided SKU No product was found matching the provided SKU. 404
slug_invalid Invalid slug format The provided slug is empty after sanitization. 400
slug_exists Slug already in use by another product The provided slug is already used by a different product. 400
update_failed Failed to update product An error occurred while saving the updated product data to the database. 500
media_upload_failed [Error message from WordPress] Failed to upload the featured image or gallery images to the media library (e.g., invalid URL, server error). 500