Skip to main content

Quickstart

This guide will walk you through your first Ductape project, step by step. By the end, you'll have created a product, added an app, set up environments, and run your first action—all using Ductape's consistent, reusable approach.

Step 1: Install the SDK

npm install @ductape/sdk

Step 2: Create a Product

A Product is a logical grouping of apps, resources, and workflows.

FieldTypeRequiredDefaultDescriptionExample
namestringYesName of the productPayments Service
descriptionstringNoDescription of the productHandles payments

Example:

const product = await ductape.product.create({
name: "Payments Service",
description: "Handles all payment processing"
});

Step 3: Add an App

Apps are integrations with third-party or internal services.

FieldTypeRequiredDefaultDescriptionExample
access_tagstringYesUnique tag for app accessemail_app_tag
envsarrayYesList of environment configurationsSee below

Example:

const appAccess = await ductape.product.apps.connect("email_app_tag");
await ductape.product.apps.add({
access_tag: appAccess.access_tag,
envs: [
{
app_env_slug: "dev",
product_env_slug: "dev",
variables: [{ key: "api_key", value: "dev-key" }],
auth: [{ auth_tag: "api_auth", data: { token: "dev-token" } }]
}
]
});

Step 4: Add an Environment

Environments let you run the same logic in different contexts (dev, staging, prod).

FieldTypeRequiredDefaultDescriptionExample
env_namestringYesName of the environmentDevelopment
slugstringYesUnique identifier (lowercase, 3+ chars)dev
descriptionstringNoDescription of the environmentDev environment

Example:

const environment = await ductape.product.environments.create({
env_name: "Development",
slug: "dev",
description: "Development environment"
});

Caching in Ductape allows you to store and quickly retrieve the results of expensive operations, such as API calls or database queries. This improves performance, reduces costs, and is essential for efficient job processing and reliable healthchecks.

Why Enable Caching?

  • Performance: Avoids repeating expensive operations by reusing cached results.
  • Jobs: Scheduled/background jobs can use cached data to avoid redundant work and speed up processing.
  • Healthchecks: Caching helps track the health and responsiveness of your system by storing recent results and reducing load on critical services.

How to Enable Caching

To enable caching, you need to create a cache resource for your product and reference its tag when running actions or jobs.

FieldTypeRequiredDefaultDescriptionExample
namestringYesName of the cacheMain Cache
tagstringYesUnique identifier for the cachemain_cache
expirynumberYesExpiry time in milliseconds60000
descriptionstringNoDescription of the cacheFor API calls

Example:

const cache = await ductape.product.caches.create({
name: "Main Cache",
tag: "main_cache",
expiry: 60000, // 1 minute
description: "Cache for API call results"
});

To use the cache when running an action, include the cache field in your IActionProcessorInput:

const result = await ductape.processor.action.run({
env: "dev",
product: "payments_service",
app: "email_app_tag",
event: "send_email",
cache: "main_cache", // Enable caching for this action
input: {
body: {
to: "user@example.com",
subject: "Hello from Ductape!",
body: "This is a test email."
}
}
});

Tip:

  • Use caching for any operation that is expensive, slow, or called frequently.
  • For jobs and healthchecks, caching helps avoid unnecessary retries and provides a reliable snapshot of recent system state.

Step 5: Run an Action

To run an action, use the processor.action.run method. This method requires an IActionProcessorInput object, which specifies the environment, product, app, event (action tag), and input data.

IActionProcessorInput

FieldTypeRequiredDefaultDescriptionExample
envstringYesEnvironment slug (e.g., 'dev', 'prd')dev
productstringYesProduct tag or IDpayments_service
appstringYesApp access tagemail_app_tag
eventstringYesAction tag (as defined in the app)send_email
inputobjectYesAction input (see below){"body": {"to": "user@example.com"}}
cachestringNoCache tag (if using caching)
retriesnumberNoNumber of retries
sessionobjectNoSession info (tag, token)

IActionRequest (input field)

FieldTypeRequiredDefaultDescriptionExample
queryobjectNoQuery parameters{"page": 1}
paramsobjectNoURL parameters{"id": 123}
bodyobjectNoRequest body{"to": "user@example.com", "subject": "Hello", "body": "Welcome!"}
headersobjectNoHTTP headers{"Authorization": "Bearer token"}
inputobjectNoAdditional input{"meta": "value"}

Example:

const result = await ductape.processor.action.run({
env: "dev",
product: "payments_service",
app: "email_app_tag",
event: "send_email",
input: {
body: {
to: "user@example.com",
subject: "Hello from Ductape!",
body: "This is a test email."
}
}
});

This will execute the send_email action for the specified app in the given environment and product, passing the provided input to the action.

Next Steps