Overview
Workflow job templates chain multiple job templates, projects updates, and inventory updates together with conditional logic. They enable complex automation workflows with success/failure/always branching.
Endpoints
| Method | Endpoint | Description |
|---|
| GET | /api/v2/workflow_job_templates/ | List workflow templates |
| POST | /api/v2/workflow_job_templates/ | Create workflow template |
| GET | /api/v2/workflow_job_templates/{id}/ | Retrieve workflow template |
| PATCH | /api/v2/workflow_job_templates/{id}/ | Update workflow template |
| DELETE | /api/v2/workflow_job_templates/{id}/ | Delete workflow template |
| POST | /api/v2/workflow_job_templates/{id}/launch/ | Launch workflow |
| POST | /api/v2/workflow_job_templates/{id}/copy/ | Copy workflow template |
List Workflow Templates
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/ \
-H "Authorization: Bearer YOUR_TOKEN"
Create Workflow Template
curl -X POST \
https://awx.example.com/api/v2/workflow_job_templates/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Deploy Full Stack",
"description": "Deploy database, backend, and frontend",
"organization": 1,
"extra_vars": "---\nenv: production",
"allow_simultaneous": false,
"survey_enabled": false,
"ask_variables_on_launch": true,
"ask_inventory_on_launch": false,
"ask_limit_on_launch": false,
"ask_labels_on_launch": false
}'
Workflow-level extra variables
Allow multiple instances to run simultaneously
Prompt for variables at launch
Prompt for inventory at launch
Prompt for limit at launch
Prompt for labels at launch
Enable webhook: github or gitlab
Retrieve Workflow Template
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/ \
-H "Authorization: Bearer YOUR_TOKEN"
Links to related resources:
organization - Parent organization
workflow_jobs - Execution history
workflow_nodes - Workflow node definitions
schedules - Execution schedules
launch - Launch endpoint
webhook_key - Webhook configuration
webhook_receiver - Webhook URL
activity_stream - Activity log
notification_templates_* - Notification templates
survey_spec - Survey specification
access_list - Access list
object_roles - Available roles
labels - Associated labels
copy - Copy endpoint
Workflow Nodes
List Workflow Nodes
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/workflow_nodes/ \
-H "Authorization: Bearer YOUR_TOKEN"
Create Workflow Node
curl -X POST \
https://awx.example.com/api/v2/workflow_job_templates/5/workflow_nodes/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"unified_job_template": 10,
"identifier": "deploy_db"
}'
ID of job template, project, or inventory source
Unique identifier for the node
Node-level extra vars (overrides template vars)
Node-level inventory override
Job type override: run or check
all_parents_must_converge
Whether all parent nodes must complete before this node runs
Associate Node Relationships
Create success/failure/always relationships:
# Success relationship
curl -X POST \
https://awx.example.com/api/v2/workflow_job_template_nodes/100/success_nodes/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": 101
}'
# Failure relationship
curl -X POST \
https://awx.example.com/api/v2/workflow_job_template_nodes/100/failure_nodes/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": 102
}'
# Always relationship
curl -X POST \
https://awx.example.com/api/v2/workflow_job_template_nodes/100/always_nodes/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": 103
}'
Launch Workflow
curl -X POST \
https://awx.example.com/api/v2/workflow_job_templates/5/launch/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"extra_vars": "deploy_version: v2.0",
"limit": "production"
}'
Returns a workflow_job object.
Survey Specification
# Get survey
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/survey_spec/ \
-H "Authorization: Bearer YOUR_TOKEN"
# Create/update survey
curl -X POST \
https://awx.example.com/api/v2/workflow_job_templates/5/survey_spec/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Deployment Survey",
"description": "Parameters for deployment",
"spec": [
{
"question_name": "Environment",
"required": true,
"type": "multiplechoice",
"variable": "environment",
"choices": ["dev", "staging", "production"]
}
]
}'
Workflow Jobs
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/workflow_jobs/ \
-H "Authorization: Bearer YOUR_TOKEN"
Schedules
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/schedules/ \
-H "Authorization: Bearer YOUR_TOKEN"
Labels
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/labels/ \
-H "Authorization: Bearer YOUR_TOKEN"
Notifications
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/notification_templates_started/ \
-H "Authorization: Bearer YOUR_TOKEN"
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/notification_templates_success/ \
-H "Authorization: Bearer YOUR_TOKEN"
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/notification_templates_error/ \
-H "Authorization: Bearer YOUR_TOKEN"
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/notification_templates_approvals/ \
-H "Authorization: Bearer YOUR_TOKEN"
Object Roles
curl -X GET \
https://awx.example.com/api/v2/workflow_job_templates/5/object_roles/ \
-H "Authorization: Bearer YOUR_TOKEN"
Available roles:
- admin_role - Full workflow administration
- execute_role - Launch workflows
- read_role - View workflow details
Copy Workflow
curl -X POST \
https://awx.example.com/api/v2/workflow_job_templates/5/copy/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Deploy Full Stack Copy"
}'
Complete Example
import requests
import json
base_url = "https://awx.example.com/api/v2"
token = "YOUR_TOKEN"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
# Create workflow template
workflow_data = {
"name": "Full Stack Deploy",
"description": "Deploy all components",
"organization": 1
}
response = requests.post(
f"{base_url}/workflow_job_templates/",
headers=headers,
data=json.dumps(workflow_data)
)
workflow = response.json()
workflow_id = workflow['id']
# Create nodes
nodes = [
{"unified_job_template": 10, "identifier": "deploy_db"},
{"unified_job_template": 11, "identifier": "deploy_backend"},
{"unified_job_template": 12, "identifier": "deploy_frontend"},
{"unified_job_template": 13, "identifier": "rollback"}
]
node_ids = {}
for node_data in nodes:
node_response = requests.post(
f"{base_url}/workflow_job_templates/{workflow_id}/workflow_nodes/",
headers=headers,
data=json.dumps(node_data)
)
node = node_response.json()
node_ids[node['identifier']] = node['id']
# Create relationships
# DB -> Backend (on success)
requests.post(
f"{base_url}/workflow_job_template_nodes/{node_ids['deploy_db']}/success_nodes/",
headers=headers,
data=json.dumps({"id": node_ids['deploy_backend']})
)
# Backend -> Frontend (on success)
requests.post(
f"{base_url}/workflow_job_template_nodes/{node_ids['deploy_backend']}/success_nodes/",
headers=headers,
data=json.dumps({"id": node_ids['deploy_frontend']})
)
# Any failure -> Rollback
for node_name in ['deploy_db', 'deploy_backend', 'deploy_frontend']:
requests.post(
f"{base_url}/workflow_job_template_nodes/{node_ids[node_name]}/failure_nodes/",
headers=headers,
data=json.dumps({"id": node_ids['rollback']})
)
print(f"Workflow created: {workflow_id}")
# Launch workflow
launch_response = requests.post(
f"{base_url}/workflow_job_templates/{workflow_id}/launch/",
headers=headers
)
workflow_job = launch_response.json()
print(f"Launched workflow job: {workflow_job['id']}")