Project resource API
The project resource API is the authenticated HTTP surface for managing a project and the objects that make its automation work. It keeps projects, membership, access grants, source data, execution definitions, event triggers, and project backups within one project scope.
This page extends the shared HTTP and access rules in HTTP API and access control. Authentication, sessions, and security controls are described in Identity, sessions, and security. Task execution and runner behavior are described in Task and runner API.
API boundary
Project context
Every project resource request uses /api/project/{project_id}. The request first confirms that the project exists and that the caller is a member. A global administrator can enter a project without membership, while normal callers receive only data that their project access allows. The collection route /api/projects lists the caller's projects and creates new projects. api/router.go• L200-212, api/…/project.go• L19-85
Project resource reads are member-facing. Lists and object lookups apply the caller's visibility before returning data. A project-wide identifier is not proof that an object is visible.
The request path moves from the shared session boundary to the project boundary and then to the resource or object boundary.
flowchart LR
A[Authenticated request] --> B[Project membership]
B --> C[Project permission]
C --> D[Object visibility or resource lookup]
D --> E[Read or change project data]
References: api/router.go• L327-355 api/…/project.go• L19-85 api/…/templates.go• L16-43
Permission layers
The API combines global administrator access with project permissions. Project roles provide the base permissions. Template and workflow grants can add permissions for one object. Read access is also the gate for seeing a template or workflow, so an object without read access behaves as absent to that caller. api/…/project.go• L47-79, api/…/templates.go• L32-40
The main permission groups are:
| Scope | Purpose | Representative routes |
|---|---|---|
| Project | Read or change the project itself | GET /project/{project_id}, PUT and DELETE /project/{project_id} |
| Resources | Manage keys, repositories, inventories, environments, templates, schedules, and integrations | /project/{project_id}/... resource routes |
| Members | Add, remove, or change project members | /project/{project_id}/users |
| Workflow execution | Edit or run workflows and resolve approvals | /project/{project_id}/workflows/... |
| Object grants | Give a project role access to one template or workflow | /{template_id}/perms, /{workflow_id}/perms |
The API also uses object ownership checks. A resource ID in a path is resolved inside the project before the handler runs. This prevents a valid ID from crossing project boundaries.
References: api/…/project.go• L88-115 api/router.go• L362-428 api/router.go• L517-577
Resource audit records
Project resource changes produce event and audit records that identify the project, resource, action, and outcome. These records support review without copying secrets or sensitive values into the audit trail. Partial operations remain visible as successful resource changes with a reason that explains the incomplete part. api/…/resources_audit_test.go• L168-211, api/…/resources_audit_test.go• L632-698
Inventory variable changes record only top-level names that were added, removed, or changed. Host changes use the same rule and record host identity without variable values. Credential, integration alias, repository URL, environment secret, and MCP token values are also kept out of the records. MCP audit metadata reports server and token change counts instead. api/…/inventory.go• L141-192, api/…/resources_audit_test.go• L237-275, api/…/resources_audit_test.go• L708-840
References: api/…/inventory.go• L141-203 api/…/inventory_hosts.go• L46-85 api/…/resources_audit_test.go• L237-275 api/…/resources_audit_test.go• L708-840
Project lifecycle
Project records
Project creation establishes a usable automation space. It adds the creator as owner and creates the basic project key and view. An optional demo request adds sample source, inventory, environment, and template content. If setup fails, the API attempts to remove the incomplete project. api/…/projects.go• L324-429
Project updates and deletion require the project update permission. A caller can also leave the project through /me and clear its temporary cache without changing project data. api/router.go• L423-436
References: api/router.go• L210-212 api/router.go• L327-336 api/router.go• L423-436 api/…/projects.go• L324-429 api/…/project.go• L141-235
Members and roles
Membership links a user to a project through one or more project or shared roles. The member API lists users with their role slugs and mapped roles, adds a user, changes role assignments, and removes a user. A user can leave through the project /me route. api/…/users.go• L106-139, api/…/users.go• L142-199
The API protects project continuity by refusing a non-admin change that would remove the only Owner. Group-mapped membership cannot be removed from the project member view because its access comes from the external mapping. api/…/users.go• L202-262
Project roles have their own management routes. Template and workflow grants refer to these project or shared role slugs and attach a limited permission set to one object. A non-zero object grant also includes read access so the grantee can find the object. api/router.go• L415-421, api/…/templates.go• L448-509, api/…/workflow_perms.go• L47-110
References: api/router.go• L346-356 api/router.go• L438-450 api/router.go• L415-421 api/…/users.go• L58-95 api/…/workflow_perms.go• L59-110
Resource catalog
Source resources
Repositories define where project automation files come from. The API supports repository lists and individual changes, reference lookup, remote branch lookup, and playbook browsing. Host configurations support the connection settings used while accessing remote sources and hosts. api/router.go• L376-380, api/router.go• L470-485, api/…/repository.go• L41-50
Repository removal is blocked while a template still uses the repository. A repository update can invalidate its cached checkout, so later branch and playbook reads use the new source state. api/…/repository.go• L283-371
References: api/router.go• L376-380 api/router.go• L470-485 api/…/repository.go• L216-235 api/…/repository.go• L237-280 api/…/repository.go• L337-371
Inventories and environments
Inventories describe the targets or workspaces used by project automation. The API supports static, file-based, managed, Terraform or OpenTofu workspace, and MCP inventory forms, plus reference lookup and Terraform state and alias routes. An MCP inventory describes remote MCP servers and manages each server's enabled state and write-only token through the inventory resource. api/…/inventory.go• L61-84, api/…/inventory.go• L91-123, api/…/inventory.go• L206-311, api/router.go• L487-505
Managed inventories store structured variables and expose a child host API for listing, creating, reading, changing, enabling, disabling, and deleting hosts. Host lists support search and bounded paging, and a new host is enabled unless the request says otherwise. The dedicated variable update replaces only the variables and requires the field to be present. api/…/inventory_hosts.go• L98-163, api/…/inventory_hosts.go• L186-317, api/…/inventory.go• L453-498, api/…/inventory_hosts_test.go• L77-97
MCP server lists are optional on update. An omitted list keeps the current servers, while an empty list removes them and their tokens. Server identity must remain inside the parent inventory. api/…/inventory.go• L78-84, api/…/inventory.go• L413-430, api/…/inventory_mcp_test.go• L224-262
Environment records hold runtime values and can manage related secrets through a secret store. Templates connect repositories, inventories, environments, and keys. The API blocks deletion of an inventory or environment that a template still uses. Environment secret changes can be partly successful, and the API records that state for audit and returns the error. api/…/environment.go• L186-205, api/…/environment.go• L301-346, api/…/inventory.go• L501-532
Managed inventory variables must remain a mapping. Their dedicated update path replaces only the variables and requires the field to be present, so an omitted field cannot clear them by accident. The managed inventory type cannot change to or from another inventory type. MCP inventory type also cannot change to or from another inventory type. api/…/inventory.go• L126-138, api/…/inventory.go• L362-399, api/…/inventory_hosts_test.go• L188-242, api/…/inventory_mcp_test.go• L323-348
References: api/router.go• L382-386 api/router.go• L487-513 api/…/inventory.go• L61-123 api/…/inventory.go• L206-311 api/…/inventory.go• L335-499 api/…/inventory_hosts.go• L98-317 api/…/inventory_mcp_test.go• L74-173 api/…/inventory_mcp_test.go• L224-348 api/…/environment.go• L207-379
Keys and secret storage
Project keys are the credential records used by repositories, inventories, environments, and integrations. The key API lists, creates, updates, deletes, and reports references for project keys. It hides task-bound internal keys and MCP server tokens from these generic routes. MCP tokens are managed only through their parent inventory. The API does not accept a plain secret as a normal request field. api/…/keys.go• L27-65, api/…/keys.go• L88-123
Key changes preserve synchronized-key limits and can clear repository caches that use the changed key. Deletion is blocked while a template still references the key. api/…/keys.go• L165-235, api/…/keys.go• L261-293
Secret storages provide a separate place to synchronize environment secrets. They follow the same project-scoped resource pattern and expose list, object, reference, update, delete, and sync operations. api/router.go• L373-375, api/router.go• L462-468
References: api/router.go• L370-375 api/router.go• L454-468 api/…/keys.go• L27-123 api/…/keys.go• L165-293 api/…/keys_mcp_test.go• L34-93
Templates and views
Templates are the project definitions that turn source files and target data into runnable automation. The collection supports visibility-filtered reads and creation. An individual template supports changes, description edits, references, task history, schedules, statistics, task stopping, and object-level permission grants. api/…/templates.go• L60-135, api/router.go• L517-535
Views organize templates for the project interface. Their routes manage view records, ordering, and the templates visible in a view. The view list can filter by custom or all. A caller can request include=template_stats to add status counts for views configured to show them; counts still follow the caller's template visibility. api/…/views.go• L33-127, api/…/views_test.go• L16-68, api/…/views_template_stats_test.go• L18-127
Inventory attachment routes maintain the link between a template and a compatible inventory. Templates for Terraform or OpenTofu may create or attach a matching workspace inventory. The API checks the application and inventory type before it sets that relationship. api/router.go• L353-360, api/router.go• L537-541, api/…/templates.go• L138-236, api/…/templates.go• L360-445
References: api/router.go• L353-360 api/router.go• L388-395 api/router.go• L517-541 api/…/templates.go• L119-236 api/…/views.go• L48-249 api/…/views_template_stats_test.go• L63-127
Automation controls
Project tasks
Project tasks are project-scoped requests to run a template. The API resolves a template by project-local ID or unique name, then passes the request to the task and runner system. Client requests cannot supply fields owned by a workflow run or runner. api/…/tasks.go• L41-84, api/…/tasks.go• L86-130
Task visibility combines project access with grants on the task's template or workflow run. A task that the caller cannot read behaves as absent. Recent task history uses a bounded page and an older-task cursor, with X-Has-Next showing whether another page exists. Detailed output and runner behavior belong to Task and runner API. api/…/tasks.go• L132-175, api/…/tasks.go• L184-226, api/…/tasks.go• L234-287, api/…/tasks_test.go• L207-249
Task control covers approval, rejection, stopping, deletion, and template-wide stopping. These actions remain project-scoped and record meaningful control changes in the audit stream. Agent task requests also follow the prompt rules declared by the template. api/…/tasks.go• L439-577, api/…/tasks.go• L629-650, api/…/tasks_agent_test.go• L32-62
References: api/…/tasks.go• L41-84 api/…/tasks.go• L86-130 api/…/tasks.go• L132-175 api/…/tasks.go• L184-287 api/…/tasks.go• L439-650 api/…/tasks_test.go• L21-64 api/…/tasks_test.go• L207-310 api/…/tasks_agent_test.go• L32-62
Workflows
Workflows provide a project-level automation path with its own edit, run, approval, revision, and object-grant surface. Any workflow operation first resolves the workflow inside the project and applies the caller's visibility and workflow permission. api/router.go• L545-577, api/…/workflows.go• L22-67
Workflow runs are the hand-off to execution behavior. This page covers the project resource boundary only. Run output, task control, and runner behavior belong with the task and runner API. See Task and runner API.
Workflow grants are available only when the account plan supports custom roles. The API checks the plan before it writes or removes a grant. api/…/workflow_perms.go• L29-45, api/…/workflow_perms.go• L113-192
References: api/router.go• L545-577 api/…/workflows.go• L22-67 api/…/workflow_perms.go• L19-45
Schedules
Schedules trigger a template or workflow on a time rule within a project. The API supports project schedule lists, template schedule lists, creation, update, activation changes, deletion, and a cron format validation request. Each schedule has one target and can use a future one-time run or a cron rule. api/router.go• L390-392, api/router.go• L527, api/…/schedules.go• L61-70, api/…/schedules.go• L187-234
Schedule changes refresh the scheduler's active set after a successful create, update, activation change, or delete. Invalid cron data, unsupported schedule types, and past one-time times are rejected before storage. A workflow-targeting schedule requires the workflow schedules feature. An existing workflow target can still be edited without changing that target if the feature later expires. api/…/schedules.go• L31-58, api/…/schedules.go• L73-125, api/…/schedules.go• L144-175, api/…/schedules.go• L237-313, api/…/schedule_pro_test.go• L33-186
References: api/router.go• L390-392 api/router.go• L527 api/router.go• L590-595 api/…/schedules.go• L31-58 api/…/schedules.go• L73-125 api/…/schedules.go• L144-313 api/…/schedule_pro_test.go• L33-214
Integrations
Integrations expose project automation to external events. An integration targets one template or workflow and can use a project key that matches its authentication method. The API supports integration records, aliases, references, matchers, and extracted values. api/…/integration.go• L59-99, api/router.go• L603-631
The public webhook route receives an integration alias outside the authenticated project resource routes. Creating or changing an integration validates its target and authentication secret before storage. A workflow-targeting integration requires the workflow integrations feature. An existing workflow target can still be edited without changing that target when the feature later expires, but switching to another workflow or adding a new workflow target remains blocked. api/router.go• L184-187, api/…/integration.go• L161-263, api/…/integration_pro_test.go• L64-173
References: api/router.go• L184-187 api/router.go• L397-400 api/router.go• L603-631 api/…/integration.go• L15-57 api/…/integration.go• L161-287 api/…/integration_pro_test.go• L64-173
Project portability
Backups
Project backup is the portability boundary for project configuration. GET /api/project/{project_id}/backup exports project data as JSON. POST /api/projects/restore verifies that JSON and creates a new project from it. The backup can include templates, repositories, keys, views, inventories, managed inventory hosts, environments, integrations, schedules, roles, runners, and workflows. api/…/backup_restore.go• L94-121, api/…/backup_restore.go• L123-214, api/…/backup_restore_test.go• L132-163
Restore is controlled like project creation. It checks the caller's ability to create projects, validates the full backup before creating objects, and checks plan features for workflow integrations, workflow schedules, and workflow grants before restore starts. A successful restore can report roles that were not assigned because their role definition was not in the file. api/…/backup_restore.go• L135-182, api/…/backup_restore_test.go• L44-67, api/…/schedule_pro_test.go• L188-214, api/…/resources_audit_test.go• L125-211
If setup fails after project creation, the API attempts cleanup. When cleanup also fails, the response tells the caller that the new project must be removed by hand without exposing store error details. api/…/backup_restore_test.go• L79-118
Project export and successful restore create audit records. A restore record counts the main resource groups and integration aliases that it brings into the new project. Validation failures and plan refusals do not create a restore record. api/…/backup_restore.go• L106-132, api/…/backup_restore.go• L174-226, api/…/integration_pro_test.go• L175-202, api/…/schedule_pro_test.go• L188-214, api/…/resources_audit_test.go• L168-211
References: api/router.go• L210-212 api/router.go• L397-400 api/…/backup_restore.go• L20-226 api/…/backup_restore_test.go• L28-163 api/…/integration_pro_test.go• L175-202 api/…/schedule_pro_test.go• L188-214 api/…/resources_audit_test.go• L125-211
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the route middleware order aligned with the permission model. Object lookup must occur inside the project scope before a write handler runs.
- Keep list visibility and single-object visibility aligned. A new resource route must not expose an object that its project or object grant would hide.
- When adding a resource that templates can reference, update deletion checks, reference responses, and backup export and restore together.
- When changing a credential type or owner, check repository, environment, integration, task-secret, and MCP-token boundaries. Generic key routes must not expose internal credentials.
- When changing workflow grants or workflow integrations, keep the plan feature checks consistent in direct API calls and backup restore.
- When changing schedule fields or targets, keep one-target validation, plan checks, audit metadata, and scheduler pool refresh coupled.
- When changing managed or MCP inventory fields, keep host and server routes limited to their parent inventory and keep token backup or audit behavior secret-safe.
- When changing task lookup or task fields, keep template and workflow-grant checks separate from client-supplied run fields. Keep page limits and cursor behavior aligned with the response header.
- When changing view filters or template statistics, keep the response shape tied to view settings and template visibility.
- When changing resource audit metadata, keep secret values and variable values out of both audit records and event descriptions.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A body uses a different project or object ID from the URL | The write is rejected with a bad-request response | Resource handlers compare body IDs with the project-scoped object loaded by middleware |
| A caller lacks project or object read access | The object is not returned, often as not found | Project permissions and template or workflow visibility are applied before the handler |
| A repository, inventory, environment, or key is still referenced | Delete fails and the resource remains | The API returns an in-use error until references are removed |
| A host is requested through a non-managed inventory or a different inventory | The request fails and the host is not changed | Host handlers require a managed parent and resolve the host within that inventory |
| An MCP server token is sent through generic key routes or returned in an inventory response | The request is rejected or the token stays hidden | MCP tokens are managed only by the inventory API and are write-only |
| An MCP server list contains a foreign server ID or invalid token operation | The inventory is not changed | Server IDs are checked against the parent inventory and token operations are validated before storage |
| A non-admin removes the only project Owner | Membership change is rejected | Owner continuity is checked before role removal |
| A task has no project-local template or names a hidden template | Task creation or lookup fails | Template resolution and read grants use the current project before execution |
| A task request supplies workflow-run or runner-owned fields | The fields do not bind to the new task | Client task input is sanitized before permission checks and task creation |
| A task page requests more than the allowed size | The response is limited and the next-page header remains authoritative | The API caps the page and uses an older-task cursor |
| A schedule has an invalid cron rule, past run time, or zero or two targets | Schedule creation or update fails | Payload and target validation run before storage and scheduler refresh |
| A workflow schedule or integration is sent without the required plan feature | The request is forbidden before creation or change | Schedule and integration controllers check the matching plan feature |
| A workflow target changes after its feature expires | The change is rejected, while an edit that keeps the same target remains allowed | The controller compares the requested target with the stored target |
| A view uses an unknown type or include value | The view request returns a bad-request response | Query filters accept only the supported view types and template_stats include |
| A backup contains invalid or unsupported data | Restore stops before project creation, or cleanup may be required after partial setup | Backup verification and feature checks run first and restore reports cleanup failures explicitly |
Key files
| File | Why to read it |
|---|---|
| api/router.go | Shows the project route tree, middleware boundaries, and resource methods. |
| api/…/project.go | Defines project loading, permission checks, project updates, deletion, and cache actions. |
| api/…/users.go | Explains membership, role changes, mapped access, and Owner protection. |
| api/…/templates.go | Shows how templates connect project resources and how template grants work. |
| api/…/workflows.go | Shows workflow and workflow-run project scoping. |
| api/…/workflow_perms.go | Shows workflow grant rules and plan gating. |
| api/…/repository.go | Defines repository lifecycle and source browsing behavior. |
| api/…/inventory.go | Defines inventory forms, managed variables, MCP servers, references, and deletion protection. |
| api/…/inventory_hosts.go | Defines the managed-inventory host resource and its paging, state, and audit boundary. |
| api/…/environment.go | Defines environment lifecycle and secret synchronization boundaries. |
| api/…/keys.go | Defines project credential access, synchronized-key rules, and internal-key protection. |
| api/…/views.go | Defines project views, filters, ordering, template visibility, and optional statistics. |
| api/…/tasks.go | Defines project task creation, template resolution, visibility, paging, and task controls. |
| api/…/schedules.go | Defines schedule targets, validation, feature checks, audit records, and scheduler refresh behavior. |
| api/…/integration.go | Defines external event targets, aliases, authentication, and feature gating. |
| api/…/backup_restore.go | Defines project export, restore validation, feature checks, audit records, and portability checks. |