pipe subcommand reads JSON resource data from stdin and upserts it into
Ctrlplane via a resource provider. This is the most flexible sync method — use
it to integrate any data source, script output, or API response without writing
a dedicated provider.
Usage
Flags
| Flag | Short | Required | Description |
|---|---|---|---|
--provider | -p | Yes | Resource provider name. Created automatically if it doesn’t exist. |
--api-key, --workspace, --url)
are also supported.
Input Format
ctrlc sync pipe accepts JSON in two forms:
Array of Resources
Single Resource Object
A single object (without the array wrapper) is also accepted and is automatically normalized to a one-element array:Required Fields
Every resource must include these fields:| Field | Type | Description |
|---|---|---|
name | string | Human-readable display name |
identifier | string | Unique identifier for the resource |
version | string | Resource version or schema version |
kind | string | Resource type (e.g., Server, Database/PostgreSQL) |
Optional Fields
| Field | Type | Description |
|---|---|---|
metadata | object | Key-value pairs used for environment selectors and filtering |
config | object | Configuration data passed to job agents during deployment |
Examples
Pipe from a Discovery Script
Run a custom script that outputs JSON and pipe it directly:Inline JSON
Quick one-liner to register resources:Single Resource
No array wrapper needed for a single resource:Transform API Responses with jq
Fetch data from an internal API and reshape it into the expected schema:Sync from a CMDB with Metadata
Include metadata so resources can be targeted by environment selectors:Database Inventory from PostgreSQL
Query a database and pipe the results:Running on a Schedule with cron
Sync resources every 5 minutes:Running in CI/CD
Usesync pipe in a GitHub Actions workflow to register build artifacts as
resources:
Behavior
- Provider auto-creation — If the named provider doesn’t exist, it is created automatically.
- Upsert semantics — Resources are matched by
identifier. Existing resources are updated; new ones are created. - Stdin required — The command exits with an error if no piped input is detected or if stdin is empty.
- Validation — Each resource is validated for the required fields (
name,identifier,version,kind) before the API call. Missing fields produce a descriptive error message.
Error Handling
| Error | Cause | Fix |
|---|---|---|
no piped input detected | Command was run interactively without piped input | Pipe JSON data to the command |
stdin is empty | Piped input contained no data | Ensure the upstream command produces output |
invalid JSON input | Input is not valid JSON | Check the JSON syntax; a snippet of the input is shown for debugging |
missing required field(s) | One or more resources are missing required fields | Add the missing fields to each resource object |
Best Practices
Use Stable Identifiers
Choose identifiers that won’t change across syncs:Include Rich Metadata
Metadata powers Ctrlplane’s environment selectors. Include attributes that are useful for targeting:Follow the Kind Naming Convention
Use aCategory/Type format for consistency:
Validate Before Syncing
Pipe throughjq to catch malformed JSON early: