# Instructions for Fluent AliasTemplate API
Always reference the AliasTemplate API specifications for more details.
1. Import `AliasTemplate` from `@servicenow/sdk/core`. The `$id` field is mandatory and must be unique (use `Now.ID['kebab-name']`). `name`, `dynamicDataSchema`, and `defaultDataTemplate` are all mandatory. Assign the result to an `export const` so an `Alias` can reference it via `configurationTemplate`.
2. Use an AliasTemplate to define a **reusable, guided setup form** for connection aliases — it controls which fields appear in the Connection & Credential wizard and what values are pre-filled. This standardizes how administrators create connections for your integration.
3. In `dynamicDataSchema`, put connection inputs (URL, host, port) in `connectionFields`, credential inputs (username, password, token, API key) in `credentialFields`, and anything else in `additionalFields`.
4. Each field needs a `name` and a `type`. `type` is a **discriminated union**: `'text'`/`'date'`/`'number'`/`'password'`/`'checkbox'`/`'file'` need no extra props; `'radio'` takes `groups`; `'choice'` takes `choices`; `'reference'` requires `table` (and optional `query`). Add `label`, `hint`, `defaultValue`, and `mandatory` as needed.
5. In `defaultDataTemplate`, set `connection.table` to the backing connection table (`'http_connection'`, `'jdbc_connection'`, `'orch_Jms_ds'`, or `'sys_connection'`) and `credential.table` to the backing credential table (e.g. `'basic_auth_credentials'`, `'api_key_credentials'`). `connection` requires `name` and `connectionUrl`.
6. Use `additional` in `defaultDataTemplate` to pass freeform data into the `postProcessScript` for creating related records after setup.
7. For `preEditScript`, `onEditScript`, and `postProcessScript`, prefer the **app_modules pattern**: write functions in `src/server/*.js`, import them with a relative `.js` path, and pass the function reference directly. Alternatively use `Now.include('./file.js')` or an inline string. Each script receives `(aliasId, connectionSysId, jsonDefaultData, jsonDynamicData)`; parse the JSON args with `JSON.parse()`. Omit a script to let the build write a harmless no-op stub.
8. Use `testAction` to wire a Flow Designer action that validates a connection created from the template; pass a sys_id, a `Record()` reference, or an `Action()` call.
