Creating Products
Learn how to create and configure products in Ductape.
Basic Product Creation
Create a product with just a name and description:
- TypeScript
- Java
- Go
- .NET
import Ductape from '@ductape/sdk';
const ductape = new Ductape({
accessKey: 'your-access-key',
});
const product = await ductape.product.create({
name: 'My Product',
description: 'A complete backend system',
});
console.log('Product created:', product.tag);
import app.ductape.sdk.Ductape;
import app.ductape.sdk.core.EnvType;
import app.ductape.sdk.core.RequestContext;
RequestContext auth = new RequestContext(null, null, null, null, 'your-access-key');
Ductape ductape = new Ductape(EnvType.PRODUCTION, auth);
Map<String, Object> product = ductape.productsService().createProduct(Map<String, Object>.of(
"name", "My Product",
"description", "A complete backend system"
));
System.out.println('Product created:', product.tag);
import (
"context"
"github.com/ductape/ductape/sdk/go/core"
ductapesdk "github.com/ductape/ductape/sdk/go/ductape"
)
auth := core.NewRequestContext("", "", "", "", 'your-access-key')
client, err := ductapesdk.New(core.EnvProduction, auth)
if err != nil {
return err
}
product := client.Product.Create(ctx, map[string]any{
"name": "My Product",
"description": "A complete backend system",
});
fmt.Println('Product created:', product.tag);
using Ductape.Sdk;
using Ductape.Sdk.Core;
var auth = new RequestContext(null, null, null, null, 'your-access-key', null);
var ductape = new Ductape(EnvType.Production, auth);
var product = await await ductape.Products.CreateProductAsync(new Dictionary<string, object?>
{
["name"] = "My Product",
["description"] = "A complete backend system",
});
Console.WriteLine('Product created:', product.tag);
The product tag is automatically generated from the name (e.g., "My Product" becomes "my-product").
Product Creation Fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the product |
description | string | Yes | Product description |
unique | boolean | No | Whether to ensure unique name (default: false) |
All other product resources (apps, environments, features, etc.) are added after product creation using their respective methods.
Initializing a Product
After creating a product, initialize it before use:
- TypeScript
- Java
- Go
- .NET
await ductape.product.init('my-product');
ductape.product.init('my-product');
client.product.init('my-product');
await ductape.product.init('my-product');
This:
- Loads the product configuration
- Sets the active product context
- Prepares resources for operations
- Validates product structure
Complete Example
- TypeScript
- Java
- Go
- .NET
import Ductape from '@ductape/sdk';
async function createProduct() {
const ductape = new Ductape({
accessKey: 'your-access-key',
});
// Create the product
const product = await ductape.product.create({
name: 'E-commerce Platform',
description: 'Complete e-commerce backend with payments, inventory, and shipping',
});
console.log('Product created:', product.tag);
// Product tag is auto-generated: "ecommerce-platform"
// Initialize for use
await ductape.product.init(product.tag);
console.log('Product initialized');
// Now you can add resources
await ductape.product.environment.create({
env_name: 'production',
slug: 'prd',
description: 'Production environment',
active: true,
});
console.log('Environment added');
// Connect an app
await ductape.product.app.connect('stripe');
console.log('App connected');
}
createProduct().catch(console.error);
import app.ductape.sdk.Ductape;
import app.ductape.sdk.core.EnvType;
import app.ductape.sdk.core.RequestContext;
async function createProduct() Map.of(
RequestContext auth = new RequestContext(null, null, null, null, 'your-access-key');
Ductape ductape = new Ductape(EnvType.PRODUCTION, auth);
// Create the product
Map<String, Object> product = ductape.productsService().createProduct(Map<String, Object>.of(
"name", "E-commerce Platform",
"description", "Complete e-commerce backend with payments, inventory, and shipping"
));
System.out.println('Product "created", ", product.tag);
// Product tag is auto-"generated", "ecommerce-platform"
// Initialize for use
ductape.product.init(product.tag);
System.out.println("Product initialized');
// Now you can add resources
ductape.product.environment.create(Map.of(
"env_name", "production",
"slug", "prd",
"description", "Production environment",
"active", true
));
System.out.println('Environment added');
// Connect an app
ductape.product.app.connect('stripe');
System.out.println('App connected');
)
createProduct();
import (
"context"
"github.com/ductape/ductape/sdk/go/core"
ductapesdk "github.com/ductape/ductape/sdk/go/ductape"
)
async function createProduct() {
auth := core.NewRequestContext("", "", "", "", 'your-access-key')
client, err := ductapesdk.New(core.EnvProduction, auth)
if err != nil {
return err
}
// Create the product
product := client.Product.Create(ctx, map[string]any{
"name": "E-commerce Platform",
"description": "Complete e-commerce backend with payments, inventory, and shipping",
});
fmt.Println('Product "created": ", product.tag);
// Product tag is auto-"generated": "ecommerce-platform"
// Initialize for use
client.product.init(product.tag);
fmt.Println("Product initialized');
// Now you can add resources
client.product.environment.create({
"env_name": "production",
"slug": "prd",
"description": "Production environment",
"active": true,
});
fmt.Println('Environment added');
// Connect an app
client.product.app.connect('stripe');
fmt.Println('App connected');
}
createProduct().catch(console.error);
using Ductape.Sdk;
using Ductape.Sdk.Core;
async function createProduct() {
var auth = new RequestContext(null, null, null, null, 'your-access-key', null);
var ductape = new Ductape(EnvType.Production, auth);
// Create the product
var product = await await ductape.Products.CreateProductAsync(new Dictionary<string, object?>
{
["name"] = "E-commerce Platform",
["description"] = "Complete e-commerce backend with payments, inventory, and shipping",
});
Console.WriteLine('Product ["created"] = ", product.tag);
// Product tag is auto-["generated"] = "ecommerce-platform"
// Initialize for use
await ductape.product.init(product.tag);
Console.WriteLine("Product initialized');
// Now you can add resources
await ductape.product.environment.create({
["env_name"] = "production",
["slug"] = "prd",
["description"] = "Production environment",
["active"] = true,
});
Console.WriteLine('Environment added');
// Connect an app
await ductape.product.app.connect('stripe');
Console.WriteLine('App connected');
}
createProduct().catch(console.error);
Best Practices
- Use descriptive names - The product tag is auto-generated from the name
- Write clear descriptions - Explain what the product does and its purpose
- Initialize after creation - Always call
product.init()before adding resources - Add resources incrementally - Create the product first, then add environments, apps, features, etc.
- Use unique flag - Set
unique: trueto ensure no duplicate product names
Common Patterns
Creating Multiple Products
- TypeScript
- Java
- Go
- .NET
const products = [
{ name: 'User Service', description: 'User management and authentication' },
{ name: 'Payment Service', description: 'Payment processing and billing' },
{ name: 'Notification Service', description: 'Email, SMS, and push notifications' },
];
for (const config of products) {
const product = await ductape.product.create(config);
console.log(`Created: ${product.tag}`);
}
Map<String, Object> products = [
Map.of( "name", "User Service", "description", "User management and authentication" ),
Map.of( "name", "Payment Service", "description", "Payment processing and billing" ),
Map.of( "name", "Notification Service", "description", "Email, SMS, and push notifications" ),
];
for (Map<String, Object> config of products) Map.of(
Map<String, Object> product = ductape.product.create(config);
System.out.println(`Created: $Map.of(product.tag)`);
)
products := [
{ "name": "User Service", "description": "User management and authentication" },
{ "name": "Payment Service", "description": "Payment processing and billing" },
{ "name": "Notification Service", "description": "Email, SMS, and push notifications" },
];
for (const config of products) {
product := client.product.create(config);
fmt.Println(`Created: ${product.tag}`);
}
var products = [
{ ["name"] = "User Service", ["description"] = "User management and authentication" },
{ ["name"] = "Payment Service", ["description"] = "Payment processing and billing" },
{ ["name"] = "Notification Service", ["description"] = "Email, SMS, and push notifications" },
];
for (var config of products) {
var product = await ductape.product.create(config);
Console.WriteLine(`Created: ${product.tag}`);
}
Creating with Environments
- TypeScript
- Java
- Go
- .NET
const product = await ductape.product.create({
name: 'API Service',
description: 'Main API backend',
});
await ductape.product.init(product.tag);
// Add environments
const environments = ['dev', 'stg', 'prd'];
for (const slug of environments) {
await ductape.product.environment.create({
env_name: slug === 'prd' ? 'production' : slug === 'stg' ? 'staging' : 'development',
slug,
description: `${slug.toUpperCase()} environment`,
active: true,
});
}
Map<String, Object> product = ductape.productsService().createProduct(Map<String, Object>.of(
"name", "API Service",
"description", "Main API backend"
));
ductape.product.init(product.tag);
// Add environments
Map<String, Object> environments = ['dev', 'stg', 'prd'];
for (Map<String, Object> slug of environments) Map.of(
ductape.product.environment.create(Map.of(
env_name: slug === 'prd' ? 'production' : slug === 'stg' ? 'staging' : 'development',
slug,
description: `$Map.of(slug.toUpperCase()) environment`,
"active", true
));
)
import "context"
product := client.Product.Create(ctx, map[string]any{
"name": "API Service",
"description": "Main API backend",
});
client.product.init(product.tag);
// Add environments
environments := ['dev', 'stg', 'prd'];
for (const slug of environments) {
client.product.environment.create({
env_name: slug === 'prd' ? 'production' : slug === 'stg' ? 'staging' : 'development',
slug,
description: `${slug.toUpperCase()} environment`,
"active": true,
});
}
var product = await await ductape.Products.CreateProductAsync(new Dictionary<string, object?>
{
["name"] = "API Service",
["description"] = "Main API backend",
});
await ductape.product.init(product.tag);
// Add environments
var environments = ['dev', 'stg', 'prd'];
for (var slug of environments) {
await ductape.product.environment.create({
env_name: slug === 'prd' ? 'production' : slug === 'stg' ? 'staging' : 'development',
slug,
description: `${slug.toUpperCase()} environment`,
["active"] = true,
});
}
Error Handling
- TypeScript
- Java
- Go
- .NET
try {
const product = await ductape.product.create({
name: 'My Product',
description: 'Product description',
unique: true, // Ensure unique name
});
console.log('Product created:', product.tag);
} catch (error) {
if (error.message.includes('already exists')) {
console.log('Product already exists');
// Fetch existing product
const existing = await ductape.product.fetch('my-product');
await ductape.product.init(existing.tag);
} else {
throw error;
}
}
try Map.of(
Map<String, Object> product = ductape.productsService().createProduct(Map<String, Object>.of(
"name", "My Product",
"description", "Product description",
"unique", true, // Ensure unique name
));
System.out.println('Product "created", ", product.tag);
) catch (error) Map.of(
if (error.message.includes("already exists')) Map.of(
System.out.println('Product already exists');
// Fetch existing product
Map<String, Object> existing = ductape.product.fetch('my-product');
ductape.product.init(existing.tag);
) else Map.of(
throw error;
)
)
import "context"
try {
product := client.Product.Create(ctx, map[string]any{
"name": "My Product",
"description": "Product description",
"unique": true, // Ensure unique name
});
fmt.Println('Product "created": ", product.tag);
} catch (error) {
if (error.message.includes("already exists')) {
fmt.Println('Product already exists');
// Fetch existing product
existing := client.product.fetch('my-product');
client.product.init(existing.tag);
} else {
throw error;
}
}
try {
var product = await await ductape.Products.CreateProductAsync(new Dictionary<string, object?>
{
["name"] = "My Product",
["description"] = "Product description",
["unique"] = true, // Ensure unique name
});
Console.WriteLine('Product ["created"] = ", product.tag);
} catch (error) {
if (error.message.includes("already exists')) {
Console.WriteLine('Product already exists');
// Fetch existing product
var existing = await ductape.product.fetch('my-product');
await ductape.product.init(existing.tag);
} else {
throw error;
}
}
Next Steps
- Managing Environments - Add dev, staging, and production environments
- Connecting Apps - Link third-party integrations to your product
- Updating Products - Modify product configuration
See Also
- Products Overview - Understand product architecture
- Apps - Create apps to connect to products
- Features - Build features within products