The api command provides direct access to the Itential Platform REST API, allowing you to perform arbitrary HTTP requests against any API endpoint. This is useful for accessing endpoints that don't have dedicated commands or for advanced automation scenarios.
The api command supports all standard HTTP methods:
get- Retrieve resourcespost- Create new resourcesput- Update existing resourcespatch- Partially update resourcesdelete- Remove resources
All api commands return JSON responses that can be formatted using the standard output options.
The basic syntax for the api command is:
ipctl api <method> <path> [options]Where:
<method>is the HTTP method (get, post, put, patch, delete)<path>is the API endpoint path (e.g.,/api/v2.0/workflows)[options]are additional command-line options
All api commands support the following options:
Specify the expected HTTP status code for the response. If the response status code doesn't match, the command will return an error.
ipctl api get /api/v2.0/workflows --expected-status-code 200Pass custom query parameters to the API request. This option can be specified multiple times to add multiple parameters. Parameters are automatically URL-encoded.
ipctl api get /api/v2.0/workflows --params limit=10 --params offset=20The --params flag supports:
- Special characters and URLs (automatic URL encoding)
- Empty values (
key=) - Values containing equals signs (
key=value=with=equals) - Unicode characters
- Spaces in values (
message=hello world)
For post, put, and patch commands, specify the request body data. The data can be:
- Inline JSON:
-d '{"name": "My Workflow"}' - File reference:
-d @workflow.json(reads from file)
ipctl api post /api/v2.0/workflows -d '{"name": "Test Workflow"}'
ipctl api put /api/v2.0/workflows/123 -d @workflow.jsonUse get to retrieve resources from the API.
Basic Usage:
ipctl api get /api/v2.0/workflowsWith Query Parameters:
# Pagination
ipctl api get /api/v2.0/workflows --params limit=50 --params offset=100
# Filtering
ipctl api get /api/v2.0/automations --params filter="name eq 'test'"
# Sorting
ipctl api get /api/v2.0/projects --params sort=-createdAt
# Multiple parameters
ipctl api get /api/v2.0/workflows \
--params limit=25 \
--params offset=0 \
--params status=active \
--params type=workflowWith Status Code Validation:
ipctl api get /api/v2.0/workflows --expected-status-code 200Use post to create new resources.
Inline JSON Data:
ipctl api post /api/v2.0/workflows -d '{
"name": "New Workflow",
"description": "Created via API",
"type": "automation"
}'From File:
ipctl api post /api/v2.0/workflows -d @new-workflow.jsonWith Query Parameters:
ipctl api post /api/v2.0/workflows \
-d @workflow.json \
--params validate=true \
--params async=falseWith Expected Status:
ipctl api post /api/v2.0/workflows \
-d @workflow.json \
--expected-status-code 201Use put to completely update an existing resource.
Basic Update:
ipctl api put /api/v2.0/workflows/507f1f77bcf86cd799439011 -d '{
"name": "Updated Workflow",
"description": "Modified via API"
}'From File:
ipctl api put /api/v2.0/workflows/507f1f77bcf86cd799439011 -d @workflow.jsonWith Query Parameters:
ipctl api put /api/v2.0/workflows/507f1f77bcf86cd799439011 \
-d @workflow.json \
--params force=trueUse patch to partially update a resource (only specified fields are modified).
Partial Update:
ipctl api patch /api/v2.0/workflows/507f1f77bcf86cd799439011 -d '{
"description": "Updated description only"
}'With Query Parameters:
ipctl api patch /api/v2.0/workflows/507f1f77bcf86cd799439011 \
-d '{"status": "active"}' \
--params partial=trueUse delete to remove resources.
Basic Delete:
ipctl api delete /api/v2.0/workflows/507f1f77bcf86cd799439011With Query Parameters:
ipctl api delete /api/v2.0/workflows/507f1f77bcf86cd799439011 \
--params cascade=true \
--params force=trueWith Expected Status:
ipctl api delete /api/v2.0/workflows/507f1f77bcf86cd799439011 \
--expected-status-code 204Query parameters are specified using the --params flag in key=value format. This flag can be used multiple times to add multiple parameters.
ipctl api get /api/v2.0/workflows --params limit=10ipctl api get /api/v2.0/workflows \
--params limit=25 \
--params offset=50 \
--params status=activeFiltering:
ipctl api get /api/v2.0/automations \
--params filter="name eq 'Production Workflow'"Sorting:
ipctl api get /api/v2.0/projects \
--params sort=-createdAt \
--params limit=10URL Parameters:
ipctl api get /api/v2.0/search \
--params url=https://example.com/api \
--params callback=https://callback.example.comSpecial Characters: All special characters are automatically URL-encoded, so you can pass them directly:
ipctl api get /api/v2.0/search --params query="hello world & goodbye"If your API path already includes query parameters, the --params flag will append to them:
# URL already has ?type=workflow
ipctl api get "/api/v2.0/workflows?type=workflow" --params limit=10
# Results in: /api/v2.0/workflows?type=workflow&limit=10By default, responses are returned as formatted JSON:
ipctl api get /api/v2.0/workflowsOutput:
{
"workflows": [
{
"id": "507f1f77bcf86cd799439011",
"name": "Production Workflow",
"type": "automation"
}
],
"total": 1
}While the api command returns raw JSON responses, you can use jq or other tools for additional formatting:
# Extract specific fields
ipctl api get /api/v2.0/workflows | jq '.workflows[].name'
# Pretty print with jq
ipctl api get /api/v2.0/workflows | jq '.'
# Filter results
ipctl api get /api/v2.0/workflows | jq '.workflows[] | select(.type == "automation")'Use --expected-status-code to validate the response:
ipctl api get /api/v2.0/workflows --expected-status-code 200If the response status code doesn't match, the command exits with an error.
200 OK- Successful GET, PUT, PATCH201 Created- Successful POST204 No Content- Successful DELETE400 Bad Request- Invalid request data401 Unauthorized- Authentication required403 Forbidden- Insufficient permissions404 Not Found- Resource doesn't exist500 Internal Server Error- Server error
# Get first page
ipctl api get /api/v2.0/workflows \
--params limit=50 \
--params offset=0
# Get second page
ipctl api get /api/v2.0/workflows \
--params limit=50 \
--params offset=50ipctl api get /api/v2.0/workflows \
--params filter="name contains 'production'" \
--params limit=10ipctl api post /api/v2.0/workflows \
-d @templates/workflow-template.json \
--params validate=true \
--expected-status-code 201ipctl api patch /api/v2.0/workflows/507f1f77bcf86cd799439011 -d '{
"description": "Updated workflow description",
"status": "active",
"tags": ["production", "critical"]
}'# Delete with cascade to remove dependencies
ipctl api delete /api/v2.0/projects/507f1f77bcf86cd799439011 \
--params cascade=true \
--params force=true \
--expected-status-code 204ipctl api get /api/v2.0/automations \
--params status=active \
--params created_after=2024-01-01 \
--params limit=1000 > active-automations.jsonWhen using -d @file.json, use descriptive names:
ipctl api post /api/v2.0/workflows -d @create-production-workflow.jsonAlways use --expected-status-code for automation scripts:
ipctl api post /api/v2.0/workflows \
-d @workflow.json \
--expected-status-code 201Instead of filtering in code, use API query parameters:
# Good - filter at API level
ipctl api get /api/v2.0/workflows \
--params status=active \
--params type=automation
# Less efficient - retrieve all and filter client-side
ipctl api get /api/v2.0/workflows | jq '.workflows[] | select(.status == "active")'For complex requests, store JSON in files:
# workflow.json
{
"name": "Production Workflow",
"description": "Main production workflow",
"type": "automation",
"steps": [...]
}
ipctl api post /api/v2.0/workflows -d @workflow.jsonFor reusable scripts, use variables:
#!/bin/bash
WORKFLOW_ID="507f1f77bcf86cd799439011"
API_PATH="/api/v2.0/workflows/${WORKFLOW_ID}"
ipctl api get "${API_PATH}" --expected-status-code 200Check exit codes in scripts:
if ipctl api get /api/v2.0/workflows --expected-status-code 200; then
echo "Successfully retrieved workflows"
else
echo "Failed to retrieve workflows" >&2
exit 1
fiCombine with other commands for complex workflows:
# Get all workflows and extract IDs
WORKFLOW_IDS=$(ipctl api get /api/v2.0/workflows --params limit=1000 | \
jq -r '.workflows[].id')
# Process each workflow
for id in $WORKFLOW_IDS; do
ipctl api get "/api/v2.0/workflows/${id}" --expected-status-code 200
done# Create multiple resources from a directory
for file in workflows/*.json; do
echo "Creating workflow from ${file}"
ipctl api post /api/v2.0/workflows -d "@${file}" --expected-status-code 201
done# Get current resource
CURRENT=$(ipctl api get /api/v2.0/workflows/507f1f77bcf86cd799439011)
# Check condition and update
if echo "$CURRENT" | jq -e '.status == "draft"' > /dev/null; then
ipctl api patch /api/v2.0/workflows/507f1f77bcf86cd799439011 \
-d '{"status": "active"}' \
--expected-status-code 200
fiEnsure JSON is properly formatted:
# Validate JSON before sending
cat workflow.json | jq '.' && ipctl api post /api/v2.0/workflows -d @workflow.jsonThe --params flag automatically handles URL encoding, but if you're including parameters directly in the path, ensure they're properly encoded:
# Good - use --params
ipctl api get /api/v2.0/search --params query="hello world"
# Manual encoding needed if in path
ipctl api get "/api/v2.0/search?query=hello%20world"Ensure your profile is configured correctly:
# Check current profile
ipctl config get profile
# Test authentication
ipctl api get /api/v2.0/health --expected-status-code 200For large data files, ensure sufficient timeout:
# Configure timeout in profile
ipctl config set timeout 300 # 5 minutes
ipctl api post /api/v2.0/large-resource -d @large-file.json- Configuration Reference - Configure
ipctlsettings - Commands Quick Reference - Overview of all commands
- Working with Repositories - Git integration