JSON API » products » products/create

Creates a new product.

Input parameters

Requires authentication and the commerce role privilege.

NameTypeDescriptionRequiredDefault value
auth_usernameStringAuthentication username.Yes
auth_passwordStringAuthentication password.Yes
nameStringName.Yes
allowInteger1 to allow only direct customers to purchase this product, -1 to allow customers recursively.No1
amountIntegerNumber of seconds for call time, or number of concurrent calls. Not used for type=product.No0
create_buyDecimalCost to reseller on purchase.No0.00
create_feeDecimalCost to customer on purchase.No0.00
currencyStringCurrency costs are in.NoSystem currency.
customerIntegerID of customer to create in.NoCustomer of authentication user.
descriptionStringDescription.NoEmpty string.
informationStringInformation to provide customer before they purchase.NoEmpty string.
periodStringHow often the period cost recurs. "monthly", "quarterly", "annually", or empty string for never. Not used for type=call_time.NoEmpty string.
period_buyDecimalCost to reseller each period. Not used for type=call_time.No0.00
period_feeDecimalCost to customer each period. Not used for type=call_time.No0.00
sharedInteger1 to share with all customers on system, 0 not to.No0
typeStringType. "call_time", "calls_in", "calls_in_out", "calls_in_out_total", "calls_in_total", "calls_out", "calls_out_total", "calls_total", or "product".No"product"
validationInteger1 to validate input then return, 0 for full action.No0

Responses

ProductDescription
200Success.
201Input passed validation. Only returned if validation=1.
400Invalid input parameters specified. Check the key and message fields for more details.
401The authentication details provided are invalid.
402Your role does not allow this.

Data returned

The ID of the created product.

Example: With required parameters

http://enswitch.example.com/api/json/products/create/?auth_username=user;auth_password=password;name=example

{ "responses":[ { "product":200, "key":"", "message":"OK" } ], "data":{ "id":123 } }

Change history

VersionChanges
4.0allow input parameter added.
3.13Function added.