> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/module-development/configuration.md).

# Configuration

Module settings are defined in `configure()` and can be overridden at runtime through `boxlang.json`. Modules can also declare dependencies on other modules.

## Module Settings

Define settings in your descriptor's `configure()` method:

{% tabs %}
{% tab title="ModuleConfig.bx" %}

```js
function configure() {
    settings = {
        apiKey: "",
        timeout: 30,
        debug: false,
        endpoints: {
            primary: "https://api.example.com/v1",
            fallback: "https://api.example.com/v2"
        }
    };
}
```

{% endtab %}

{% tab title="Java IModuleConfig" %}

```java
@Override
public void configure( IBoxContext context, ModuleRecord record ) {
    record.settings.put( Key.of( "apiKey" ), "" );
    record.settings.put( Key.of( "timeout" ), 30 );
    record.settings.put( Key.of( "debug" ), false );

    IStruct endpoints = new Struct();
    endpoints.put( Key.of( "primary" ), "https://api.example.com/v1" );
    endpoints.put( Key.of( "fallback" ), "https://api.example.com/v2" );
    record.settings.put( Key.of( "endpoints" ), endpoints );
}
```

{% endtab %}
{% endtabs %}

## Runtime Overrides

Users can override module settings in `boxlang.json`:

```json
{
  "modules": {
    "myModule": {
      "enabled": true,
      "settings": {
        "apiKey": "sk-abc123",
        "debug": true
      }
    }
  }
}
```

### Merge Behavior

Runtime settings are **deep-merged** on top of `configure()` defaults:

| configure() setting | boxlang.json override | Effective value                       |
| ------------------- | --------------------- | ------------------------------------- |
| `apiKey: ""`        | `apiKey: "sk-abc123"` | `"sk-abc123"` (overridden)            |
| `timeout: 30`       | (not set)             | `30` (default preserved)              |
| `debug: false`      | `debug: true`         | `true` (overridden)                   |
| `endpoints.primary` | (not set)             | `"https://api..."` (nested preserved) |

## Disabling Modules

Modules can be disabled via runtime config:

```json
{
  "modules": {
    "myModule": {
      "enabled": false
    }
  }
}
```

The module is still discovered but skipped during registration — no BIFs, components, or services are loaded.

## Accessing Settings

Access module settings from anywhere:

```js
// From ModuleConfig.bx
var timeout = settings.timeout

// From module code
var moduleService = boxRuntime.getModuleService()
var settings = moduleService.getModuleSettings( "myModule" )
var timeout = settings.timeout
```

## Dependencies

Declare module dependencies to control activation order:

{% tabs %}
{% tab title="ModuleConfig.bx" %}

```js
class {
    this.dependencies = [ "bx-plus", "bx-compat-cfml" ];
}
```

{% endtab %}

{% tab title="Java @BoxModule" %}

```java
@BoxModule( dependencies = { "bx-plus", "bx-compat-cfml" } )
public class MyModuleConfig implements IModuleConfig { }
```

{% endtab %}
{% endtabs %}

**How dependencies work:**

* Dependencies are activated **before** the dependent module
* Resolution is recursive (a dependency's dependencies are also activated first)
* Missing dependencies cause a warning but don't prevent activation
* Use `box.json` `dependencies` for ForgeBox package dependencies

{% hint style="info" %}
`this.dependencies` controls activation order, while `box.json` `dependencies` controls package installation. Both should list your module's dependencies.
{% endhint %}

## Inter-Module Communication

Check for and interact with other loaded modules:

```js
function onLoad() {
    var moduleService = boxRuntime.getModuleService()

    // Check if another module is loaded
    if ( moduleService.hasModule( "bx-spreadsheet" ) ) {
        var spreadsheetSettings = moduleService.getModuleSettings( "bx-spreadsheet" )
        // Read or modify (use cautiously)
    }
}
```

## Next Steps

* [Advanced Collaboration](/boxlang-framework/module-development/advanced-collaboration.md) — System settings providers and class resolvers
* [Packaging & Publishing](/boxlang-framework/module-development/packaging-publishing.md) — Build and distribute your module
* [Testing](/boxlang-framework/module-development/testing.md) — TestBox integration and CI/CD patterns


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/module-development/configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
