# Project files

Source: https://docs.autessa.com/docs/cdk/project

> The files in an Autessa CDK project: the resource config, autessa.stages.yaml with stages, variables and fan-out, secret references, and the .autessa build output.

# Project files

(Preview)

The deploy API and the Autessa CDK are in preview and not yet released. Names and shapes may change before they are generally available.

An Autessa CDK project is a normal folder in Git. One file lists your resources. One file lists where they deploy. Everything else is source code.

## The resource config

Write resources in one of these:

- `autessa.config.py` (Python). It must create one `Project`, ideally named `project`.
- `autessa.config.ts` (TypeScript; `.mts`, `.js` and `.mjs` also work). It must `export default` the `Project`.
- A Java class that implements `com.autessa.cdk.AutessaProject` (see [Autessa CDK](/docs/cdk.md)).
- `autessa.yaml` (or `autessa.yml`), if you prefer plain data. `pull` writes one for you.

`autessa.yaml` uses the same shape as the manifest: `metadata`, `resources`, `permissions`, `firewallPolicies` and `variables`, with resources grouped by kind.

```yaml
# autessa.yaml
metadata:
  name: support-desk
resources:
  tables:
    - logicalId: tickets
      columns:
        - { name: subject, type: SHORT_TEXT }
        - { name: body, type: LONG_TEXT }
      vectorize: [body]
  tools:
    - logicalId: lookupTicket
      source: tools/lookup_ticket.as
  agents:
    - logicalId: supportAgent
      agent:
        instructions: You answer questions about support tickets.
      toolRefs: [lookupTicket]
      autessaDbTableRef: tickets
```

Every resource has a `logicalId`. It must be unique in the project and should never change. It starts with a letter and uses letters, digits, `-` and `_` (at most 128 characters).

## Resource kinds

| Kind | `autessa.yaml` section | What it is |
| --- | --- | --- |
| `Table` | `resources.tables` | An AutessaDB table: columns, indexes, knowledge base and vector search settings, seed rows. |
| `Type` | `resources.types` | A shared AutessaScript type from a `.as` file. |
| `Tool` | `resources.tools` | A tool. Script tools point at a `.as` file. Inputs and outputs are JSON Schema. |
| `Agent`, `Manager` | `resources.agents`, `resources.managers` | Agents and multi-agent managers. |
| `Trigger`, `ScheduledEvent`, `Webhook` | `resources.triggers`, `resources.scheduledEvents`, `resources.webhooks` | Things that start work: table triggers, schedules, inbound webhooks. |
| `McpServer` | `resources.mcpServers` | A connected MCP server. |
| `App` | `resources.customApps` | A hosted React app from `apps/<name>/`, with optional custom domain and sign-in settings. |
| `PhoneNumber` | `resources.phoneNumbers` | A number requirement (country, area code, capabilities) and its routing: an Autessa agent or your own agent. |
| `SecretRef` | `resources.secretRefs` | A secret by name. The value never goes in code. |
| `FirewallPolicy` | `firewallPolicies` | A named AI Application Firewall policy. |
| `Role`, `Grant`, `RowLevelSecurity`, `ApiKeyScope` | `permissions.roles`, `permissions.grants`, `permissions.rowLevelSecurity`, `permissions.apiKeyScopes` | Permissions. See [Permissions in code](/docs/cdk/permissions.md). |
| `Variable` | `variables` | A placeholder filled in per stage. |

The Java CDK has no constructs for `Manager`, `Trigger`, `ScheduledEvent`, `Webhook` or `McpServer`. In TypeScript, row-level security is the `rowLevelSecurity` setting of a `Table`.

## Variables

Declare a variable with `project.variable("name")` (Python and TypeScript) or `p.variable("name")` (Java), and use what it returns wherever a string goes. Each stage fills it in from its `variables`. A required variable with no value stops `diff` and `deploy`.

The placeholder each language's CDK writes into the manifest is different. If you write `autessa.yaml` by hand, use the one for the tool you run:

| Runner | Placeholder |
| --- | --- |
| Python (`autessa-cdk`) | `{{name}}` |
| TypeScript (`npx autessa-cdk`, the deploy action) | `{{var.name}}` |
| Java (Maven, Gradle) | `${var.name}` |

## Referring to other resources

Fields that hold an id, such as `toolId` or `targetRef`, take a logicalId and become the tenant's id. Other text is never changed, even if it happens to equal a logicalId.

Inside tool source and app files, write `{{ref:LogicalId}}`. The deploy fills in the tenant's id once everything exists, so tools can call each other in a circle, and the same code works in every stage:

```js
const people = '{{ref:PeopleTable}}';
```

A name that isn't in the project stops the deploy. When a resource's id changes, the tools and apps that name it are deployed again.

## Apps and roles

An app's `entry`, `customDomain` and `auth`, and a role's `permissions`, are applied by deploy, previewed in the diff and undone by rollback.

- `entry` ships as `index.html`, because apps are served from there.
- An app's `grants` (the tools, agents, managers and tables its visitors may reach) are applied by every deploy. Leave them out and the app's grants stay as they are. See [App grants](/docs/cdk/permissions.md#app-grants).
- Role strings are `<table>_READ`, `<table>_WRITE` or `TABLE_*` for all the project's tables.
- A deploy can't turn on `AUTH_CODE`, because the code would sit in the project. Turn it on in the app's settings first.
- Dropping `auth` or `customDomain` from a project undoes only what the project set. A domain added by hand stays.

## Secrets

Use `SecretRef` to point at a secret by name. Set the value once in each tenant, in **Secrets** or with the [CLI](/docs/cli/secrets.md). The secret value never goes in your project or the manifest.

```yaml
resources:
  secretRefs:
    - logicalId: crmToken
      name: crm-api-token
```

## The stages file

`autessa.stages.yaml` lists the tenants you deploy to.

```yaml
stages:
  - name: dev
    tenant: Ab12Cd34Ef                 # the tenant (company) ID
    deployKeyEnv: AUTESSA_DEPLOY_KEY_DEV
    variables: { model: "small", greeting: "Hi from dev" }
  - name: prod
    tenant: Gh56Ij78Kl
    deployKeyEnv: AUTESSA_DEPLOY_KEY_PROD
    variables: { model: "large" }
    permissions: { drift: report }     # report (default) | reset
fanout:                                # optional: many tenants, one project
  - name: customers
    tenants: [Mn90Op12Qr, St34Uv56Wx]
    deployKeyEnv: AUTESSA_DEPLOY_KEY_FANOUT_{TENANT}
    variables: { model: "large" }
```

| Field | Meaning |
| --- | --- |
| `stages[].name` | The stage name you pass to commands, like `--stage dev`. |
| `stages[].tenant` | The ID of the company to deploy into. |
| `stages[].deployKeyEnv` | The environment variable that holds this stage's deploy key. Defaults to `AUTESSA_DEPLOY_KEY`. |
| `stages[].variables` | Values for this stage's variables. |
| `stages[].permissions.drift` | `report` (the default) or `reset`. See [Drift](/docs/cdk/permissions.md#drift). |
| `fanout[]` | A group of tenants that get the same project: `name`, `tenants`, `deployKeyEnv` (with `{TENANT}`), and optional `variables` and `permissions`. See [Multiple tenants](/docs/cdk/tenants.md). |

The file is also read as `autessa.stages.yml` by the TypeScript CDK.

## Build output

`build` writes `.autessa/`:

```text
.autessa/
  manifest.json      # every resource, as Manifest v2 (schemaVersion: 2)
  files/             # tool sources and app files that the manifest lists by content hash
```

`build` checks the manifest against the Manifest v2 schema and checks that every reference points at a resource in the project. Add `.autessa/` to `.gitignore`. It is rebuilt on every run. The manifest's JSON Schema is also served by the [Deploy API](/docs/reference/deploy.md).

## Example

See [autessa-as-code-tenant](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/autessa-as-code-tenant) for full projects with an `autessa.stages.yaml`.

## Related

- [Autessa CDK](/docs/cdk.md)
- [Commands](/docs/cdk/commands.md)
- [Multiple tenants](/docs/cdk/tenants.md)
- [Secrets](/docs/guide/agentic/secrets.md)
- [Deploy API](/docs/reference/deploy.md)

