Create Product

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

Updates an existing WooCommerce product.

Content API Version: 1.0.4

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
upc string UPC or other identifier unique to this product using numbers and hyphens only (Requires 1.0.6) No
weight string Weight of the product (Requires 1.0.7) No
name string Product name No
status string Status of product (publish, draft, ect). Default “draft”. 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
manage_stock bool Pass true to manage stock or false otherwise. (Requires 1.0.9) No
stock_quantity integer Stock quantity No
tags array Product tags No
categories array Product categories by ID or slug. 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

{
  "name": "Sunglasses",
  "slug": "sunglasses",
  "sku": "SUNGLASS-1",
  "upc": "123456-789",
  "weight": "10.59",
  "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 created 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
product_sku_exists Product with provided SKU already exists The provided product SKU exists. 400
upc_malformed UPC must contain only numbers and hyphens You have characters other than numbers and – 500
slug_exists Slug already in use by another product Another product already has this slug. 400
creation_failed Failed to create 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
product_exception An error occurred when attempting to update UPC. It may be in use, please check your trash. Occurs typically when UPC or SKU is already in use. 500