JSON API » products » products/create
Creates a new product.
Input parameters
Requires authentication and the commerce role privilege.
| Name | Type | Description | Required | Default value |
|---|---|---|---|---|
| auth_username | String | Authentication username. | Yes | |
| auth_password | String | Authentication password. | Yes | |
| name | String | Name. | Yes | |
| amount | Integer | Number of seconds for call time, or number of concurrent calls. Not used for type=product. | No | 0 |
| create_buy | Decimal | Cost to reseller on purchase. | No | 0.00 |
| create_fee | Decimal | Cost to customer on purchase. | No | 0.00 |
| currency | String | Currency costs are in. | No | System currency. |
| customer | Integer | ID of customer to create in. | No | Customer of authentication user. |
| description | String | Description. | No | Empty string. |
| information | String | Information to provide customer before they purchase. | No | Empty string. |
| period | String | How often the period cost recurs. "monthly", "quarterly", "annually", or empty string for never. Not used for type=call_time. | No | Empty string. |
| period_buy | Decimal | Cost to reseller each period. Not used for type=call_time. | No | 0.00 |
| period_fee | Decimal | Cost to customer each period. Not used for type=call_time. | No | 0.00 |
| shared | Integer | 1 to share with all customers on system, 0 not to. | No | 0 |
| type | String | Type. "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" |
| validation | Integer | 1 to validate input then return, 0 for full action. | No | 0 |
Responses
| Product | Description |
|---|---|
| 200 | Success. |
| 201 | Input passed validation. Only returned if validation=1. |
| 400 | Invalid input parameters specified. Check the key and message fields for more details. |
| 401 | The authentication details provided are invalid. |
| 402 | Your 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
| Version | Changes |
|---|---|
| 3.13 | Function added. |
