# Main Settings

Main Settings is the set of values that apply to an [application](/en/documentation/platform/applications/) as a whole: its name, the Products enabled on it, Debug Rules, and its status. Azion Console groups them in the **Main Settings** tab of the application, and the API returns them as fields of the application object. For the path a request takes through an application, refer to [How Applications works](/en/documentation/platform/applications/how-it-works/).

---

## Sections and fields

The **Main Settings** tab has four sections: **General**, **Modules**, **Debug Rules**, and **Status**. **General** holds the **Name** of the application. The tab carries **Cancel** and **Save**, and a change is saved with **Save**.

Each section maps to one or more fields of the application in the API. The last column holds the value each field takes when a create request sends only `name` and `active`.

| Section         | Setting                | API field                   | Type    | Value at creation                                                                               |
| --------------- | ---------------------- | --------------------------- | ------- | ----------------------------------------------------------------------------------------------- |
| **General**     | **Name**               | `name`                      | string  | The value the create request sends                                                              |
| **Modules**     | One toggle per Product | `modules.<product>.enabled` | boolean | `true` for `cache` and `functions`, `false` for `application_accelerator` and `image_processor` |
| **Debug Rules** | **Debug Rules**        | `debug`                     | boolean | `false`                                                                                         |
| **Status**      | **Status**             | `active`                    | boolean | The value the create request sends                                                              |

For example, an application you create through the API with only `name` and `active` has Cache and [Functions](/en/documentation/platform/functions/) on from the start, and Application Accelerator stays off until you turn it on.

The **Status** toggle turns the application off and back on without deleting it. The API carries the same state in the `active` boolean.

---

## Products

The **Modules** section turns Products on or off for one application, and each application keeps its own set. Its **Default Modules** group holds one toggle per Product: **Application Accelerator**, **Cache**, **Functions**, and **Image Processor**. A **Subscription modules** group carries a **Contact sales** action, and the section states that "Some modules require subscription."

| Product                 | Key in `modules`          | CLI flag                    | What it covers on the application                                                                                                                                                                                                   |
| ----------------------- | ------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Application Accelerator | `application_accelerator` | `--application-accelerator` | The Rules Engine variables and behaviors that the Console marks `- Required Application Accelerator`. A cache setting needs it for the variations of its **Application Accelerator** section and for a **Max Age** below 60 seconds |
| Cache                   | `cache`                   | `--cache`                   | Caching of the content the application delivers. Cache settings are created in the **Cache Settings** tab and applied by a **Set Cache Policy** behavior                                                                            |
| Functions               | `functions`               | `--functions`               | Function instances, listed in the **Functions Instances** tab and run by a **Run Function** behavior. The Console marks a behavior that needs Functions `- Required Function`                                                       |
| Image Processor         | `image_processor`         | `--image-processor`         | The **Optimize Images** behavior. The Console marks a behavior that needs Image Processor `- Required Image Processor`                                                                                                              |

Cache is on when you create an application, and the Console notes that it is "Automatically enabled in all accounts." You can turn a Product on when your account supports it, and turn it off when nothing on the application depends on it. Turning on a Product can generate usage-related costs. For more information, refer to [Pricing](/en/documentation/fundamentals/pricing/).

A rule or a cache setting that needs a Product the application has off is refused when you save it, with one of the codes in Errors. For example, a request rule whose criterion reads `${request_uri}` is refused while Application Accelerator is off, and the same rule on `${uri}` is accepted. For the variables and behaviors each Product adds, refer to [Rules Engine for Applications](/en/documentation/platform/applications/rules-engine/).

Tiered Cache has no toggle in the **Modules** section. It is a switch inside each cache setting. For more information, refer to [Tiered Cache](/en/documentation/platform/applications/cache/tiered-cache/).

---

## Debug Rules

Debug Rules logs the Rules Engine rules that run on each request to the application. The setting is off when you create an application, and the API holds it in the `debug` boolean. In Azion Console, the **Debug Rules** toggle sets it.

With Debug Rules on, the rules that ran on a request appear in the `$traceback` field of Data Stream and [Real-Time Events](/en/documentation/platform/real-time-events/). The Real-Time Events GraphQL API returns the same rules in the `$stacktrace` variable. A rule that is missing from that list did not run on the request.

For example, when a **Set Cache Policy** rule seems to have no effect on a path, the `$traceback` of a request to that path shows whether the rule ran at all. For the queries that read the field in each tool, refer to [Debug rules created with Rules Engine](/en/documentation/guides/application-development/getting-started/debug-rules/).

---

## Delivery and protocol settings

Main Settings carries no delivery or protocol settings. Domains, protocols, and certificates belong to the [workload](/en/documentation/platform/workloads/) that serves the application, and the **Deployment Settings** of the workload select the **Application** it runs.

In an account that has not migrated to API v4, the application itself holds its delivery protocols, ports, and TLS settings. For those settings, refer to [Main Settings | v3](/en/documentation/platform/applications/main-settings-v3/).

---

## API

The API serves applications at `https://api.azion.com/v4/workspace/applications`. Each call authenticates with a [personal token](/en/documentation/fundamentals/personal-tokens/) in the `Authorization: Token [TOKEN VALUE]` header, and a call with a body also sends `Content-Type: application/json`.

| Operation                            | Method and path                                  | Status                               |
| ------------------------------------ | ------------------------------------------------ | ------------------------------------ |
| Create an application                | `POST /workspace/applications`                   | `202`, with `state` set to `pending` |
| List the applications of the account | `GET /workspace/applications`                    | `200`                                |
| Read one application                 | `GET /workspace/applications/<application-id>`   | `200`                                |
| Change part of an application        | `PATCH /workspace/applications/<application-id>` | `202`, with `state` set to `pending` |

This call creates an application from a name and a status alone:

```bash
curl --request POST \
  --url https://api.azion.com/v4/workspace/applications \
  --header 'Accept: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "my-application",
  "active": true
}'
```

The API answers `202`. In this excerpt of the body, `modules` and `debug` carry the values the platform set at creation:

```text
{"state":"pending","data":{"id":<application-id>,"name":"my-application",…,"modules":{"cache":{"enabled":true},"functions":{"enabled":true},"application_accelerator":{"enabled":false},"image_processor":{"enabled":false}},"active":true,"debug":false,…}}
```

The `id` in `data` identifies the application in every later call, including the paths of its rules, such as `/workspace/applications/<application-id>/request_rules`.

This call turns on Application Accelerator on an existing application:

```bash
curl --request PATCH \
  --url https://api.azion.com/v4/workspace/applications/<application-id> \
  --header 'Accept: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]' \
  --header 'Content-Type: application/json' \
  --data '{
  "modules": {
    "application_accelerator": {
      "enabled": true
    }
  }
}'
```

The API answers `202` with `state` set to `pending`. A body with `functions` in place of `application_accelerator` turns on Functions the same way, and its response repeats the `modules` object with all four keys.

---

## CLI

[Azion CLI](/en/documentation/devtools/cli/) reads and changes an application with three commands under the `application` noun. Each Product flag takes a string, such as `true`.

| Command                      | What it does                                                                                                                                        |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `azion create application`   | Creates an application. `--cache` and `--image-processor` set those Products at creation                                                            |
| `azion update application`   | Changes the application that `--application-id` names. `--application-accelerator`, `--functions`, and `--image-processor` turn a Product on or off |
| `azion describe application` | Returns the application that `--application-id` names, with its `modules` object                                                                    |

This command turns on Application Accelerator:

```bash
azion update application --application-id <application-id> --application-accelerator true
```

```text
Updated Application with ID <application-id>
```

The output of `azion describe application` includes the `modules` object of the application:

```bash
azion describe application --application-id <application-id>
```

On an application with all four Products on, the object reads:

```json
"modules": {
  "application_accelerator": { "enabled": true },
  "cache": { "enabled": true },
  "functions": { "enabled": true },
  "image_processor": { "enabled": true }
}
```

---

## Errors

A Product that is off on the application surfaces as a refusal of the object that needs it, with `400`. Each of these refusals names Application Accelerator. This body answers a request rule on `${request_uri}`:

```json
{
  "errors": [
    {
      "code": "25047",
      "title": "Missing Required Modules",
      "detail": " It requires any of the following modules to be enabled: ['application_accelerator'].",
      "status": "400",
      "source": { "pointer": "/data/criteria/0/0/variable" },
      "meta": {
        "message_prefix": "",
        "owner_modules": "any",
        "missing_required_modules": ["application_accelerator"]
      }
    }
  ]
}
```

`meta.missing_required_modules` lists the keys to turn on in the `modules` object of the application.

| Code    | Title                                                                                             | Status | What causes it                                                                                                                                                                                                                | What to do                                                                              |
| ------- | ------------------------------------------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `25047` | Missing Required Modules                                                                          | 400    | A request rule whose criteria read `${request_uri}`, on an application with Application Accelerator off                                                                                                                       | Turn on Application Accelerator, or match on `${uri}`, which the API accepts without it |
| `21013` | This Configuration Requires The Edge Application's Application Accelerator Module                 | 400    | A cache setting that varies the cache by method or by query string, on an application with Application Accelerator off. The pointer names the variation, such as `/data/modules/application_accelerator/cache_vary_by_method` | Turn on Application Accelerator, then save the cache setting again                      |
| `21021` | Edge Cache Max Age Lower Than The Minimum Allowed By Application's Application Accelerator Module | 400    | A cache setting whose `modules.cache.max_age` is below 60, on an application with Application Accelerator off. `meta.min_value` is `60`                                                                                       | Turn on Application Accelerator, or set **Max Age** to 60 seconds or more               |

---

## Related resources

- [How Applications works](/en/documentation/platform/applications/how-it-works.md): The mechanism behind an application, its rules, and the Products it runs.
- [Application Accelerator settings](/en/documentation/platform/applications/application-accelerator/settings.md): The cache variations and Rules Engine behaviors Application Accelerator adds to an application.
- [Cache settings](/en/documentation/platform/applications/cache/cache-settings.md): The Browser Cache, Cache, and Application Accelerator fields of a cache setting.
- [Debug rules created with Rules Engine](/en/documentation/guides/application-development/getting-started/debug-rules.md): The queries that read the rules each request ran once Debug Rules is on.
