Create Product
POST /api/v1/products
Description
Creates a new product in the system, capturing essential details such as name, description, pricing, location, and product type specifics. This endpoint is used to expand the product catalog and manage inventory for a business.
Headers:
tenantId(required): The tenant ID under which the product is being created. This should be included as a header.userId(required): The user ID of the individual responsible for creating the product. This should also be included as a header.countryCode(required): The country code where the product is being registered or sold. This should be included as a header.
Request Body (application/json): Required. The body should include comprehensive details about the product:
{
"name": "string",
"state": "string",
"city": "string",
"photos": [
"string"
],
"description": "string",
"quantity": 0,
"costPrice": 0,
"sellingPrice": 0,
"currencyCode": "string",
"businessId": "string",
"userId": "string",
"tenantId": "string",
"countryCode": "string",
"productTypeId": "string",
"productTypeDetail": {}
}
Responses:
- 201 Created: Indicates that the product has been successfully created. The response typically includes details of the newly created product.
Example Request:
curl -X POST "http://[base_url]/api/v1/products" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [access_token]" \
-H "tenantId: TEN123" \
-H "userId: USR456" \
-H "countryCode: US" \
-d '{
"name": "Organic Apples",
"state": "California",
"city": "San Francisco",
"photos": ["http://example.com/photo1.jpg"],
"description": "Fresh organic apples from our sustainable orchards.",
"quantity": 100,
"costPrice": 0.50,
"sellingPrice": 1.00,
"currencyCode": "USD",
"businessId": "BIZ789",
"userId": "USR456",
"tenantId": "TEN123",
"countryCode": "US",
"productTypeId": "123",
"productTypeDetail": {
"size": "Medium",
"packaging": "Box"
}
}'
Example Response:
{
"message": "Product created successfully.",
"productId": "prod123"
}
Error Responses:
- 400 Bad Request: Incorrect or incomplete data for the product creation.
- 403 Forbidden: The user does not have permission to create a product.
LANGUAGE
CURL REQUEST
curl --request POST \
--url /api/v1/products \
--header 'accept: application/json' \
--header 'content-type: application/json'
RESPONSE
Click Try It! to start a request and see the response here!