Create Product
Create goods or services.
If the product is goods, use Create SKU to add a SKU to the product.
This method triggers the Product Created webhook. This webhook contains the same information as the response.
active
Indicates whether the product is currently available for purchase.
true
attributes
Array of up to 5 alphanumeric strings defined by the merchant. Each string defines the key in a key-value pair in the
attributes
object in the correspondingsku
objects.
description
Full text description of the product.
id
Unique string for identification of the product. Legal input includes all the English alphanumeric characters and the underscore (_) character. If the merchant does not define an ID, Rapyd generates it with a string that starts with product_.
name
The name of the product or service that is displayed to the customer.
shippable
Indicates whether the product is physically shipped to the customer. Relevant when
type
is goods.false
statement_descriptor
A text description that appears in the customer's invoice. Limited to 22 characters. Relevant when
type
is service.
type
One of the following:
services
goods
unit_label
A label that represents units of this product on customers’ invoices, such as views or downloads. Relevant when
type
is service.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { var metadata = new { merchant_defined = true }; var attributes = new string[] { "location", "size" }; var requestObj = new { id = "", name = "Monthly parking", type = "services", active = true, attributes, description = "Monthly parking - covered area, compact car", metadata, shippable = false, statement_descriptor = "", unit_label = "", }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", "/v1/products", request); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const body = { id: '', name: 'Monthly parking', type: 'services', active: true, attributes: ['location', 'size'], description: 'Monthly parking - covered area, compact car', metadata: { merchant_defined: true }, shippable: false, statement_descriptor: '', unit_label: '' }; const result = await makeRequest('POST', '/v1/products', body); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); $body = [ "id" => "", "name" => "Monthly parking", "type" => "services", "active" => true, "attributes" => [ "location", "size" ], "description" => "Monthly parking - covered area, compact car", "shippable" => false, "statement_descriptor" => "", "unit_label" => "" ]; try { $object = make_request('post', '/v1/products', $body); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
product = { "id": "", "name": "Monthly parking", "type": "services", "active": True, "attributes": [ "location", "size" ], "description": "Monthly parking - covered area, compact car", "metadata": { "merchant_defined": True }, "shippable": False, "statement_descriptor": "monthly_parking", "unit_label": "", } result = make_request(method='post', path='/v1/products', body=product) pprint(result)
/v1/products
Create Services
curl -X post https://sandboxapi.rapyd.net/v1/products -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here' -d '{ "id": "", "name": "Monthly parking", "type": "services", "active": true, "attributes": [ "location", "size" ], "description": "Monthly parking - covered area, compact car", "metadata": { "merchant_defined": true }, "shippable": false, "statement_descriptor": "", "unit_label": "" } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "62541e52-3097-4967-81c9-883fe0531685" }, "data": { "id": "product_ab9599d248f6d4d4311148aea68e20d0", "active": true, "attributes": [ "location", "size" ], "created_at": 1592299027, "description": "Monthly parking - covered area, compact car", "metadata": { "merchant_defined": true }, "name": "Monthly parking", "package_dimensions": { "height": 0, "length": 0, "weight": 0, "width": 0 }, "shippable": false, "skus": [], "statement_descriptor": "", "type": "services", "unit_label": "", "updated_at": 1592299027 } }
Create Goods
curl -X post https://sandboxapi.rapyd.net/v1/products -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here' -d '{ "id": "", "name": "Gamer's Chair", "type": "goods", "active": true, "attributes": [ "color", "arm rest" ], "description": "The ultimate in comfort for the dedicated gamer.", "metadata": { "merchant_defined": true }, "package_dimensions": { "height": 10, "length": 20, "weight": 30, "width": 40 }, "shippable": true, "statement_descriptor": "", "unit_label": "" } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "7e25c2bf-92d7-42ac-88aa-5b56c218a5ef" }, "data": { "id": "product_0d9dc6be69c769560fe913f3b086d8ca", "active": true, "attributes": [ "arm rest", "color" ], "created_at": 1592299157, "description": "The ultimate in comfort for the dedicated gamer.", "metadata": { "merchant_defined": true }, "name": "Gamer's Chair", "package_dimensions": { "height": 10, "length": 20, "weight": 30, "width": 40 }, "shippable": true, "skus": [], "statement_descriptor": "", "type": "goods", "unit_label": "", "updated_at": 1592299157 } }