> 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-+-++/modules/bx-plus/built-in-functions/boxlanglicenseactivate.md).

# BoxlangLicenseActivate

Activates a BoxLang+ or BoxLang++ license using an email address and license key. This function connects to the Ortus Solutions licensing server to validate and activate your subscription license.

## Method Signature

```
BoxlangLicenseActivate( email, licenseKey [, serverType ] )
```

### Arguments

| Argument     | Type     | Required | Description                                                            | Default      |
| ------------ | -------- | -------- | ---------------------------------------------------------------------- | ------------ |
| `email`      | `STRING` | `true`   | The email address associated with the license account                  |              |
| `licenseKey` | `STRING` | `true`   | The license key to activate                                            |              |
| `serverType` | `STRING` | `false`  | The server environment type: `Production`, `Staging`, or `Development` | `Production` |

### Return Value

Returns a `STRUCT` with the following keys:

* `success` (BOOLEAN) - Whether the activation was successful
* `message` (STRING) - Status message or error description
* `isValidLicense` (BOOLEAN) - Whether the license is valid
* `isTrialMode` (BOOLEAN) - Whether the system is in trial mode
* `expirationDate` (STRING) - License expiration date (if applicable)

## Examples

### Template Syntax

```js
// Activate a production license
<bx:script>
    result = boxlangLicenseActivate(
        email = "admin@example.com",
        licenseKey = "XXXX-XXXX-XXXX-XXXX",
        serverType = "Production"
    );

    if ( result.success ) {
        writeOutput( "License activated successfully!" );
    } else {
        writeOutput( "Activation failed: " & result.message );
    }
</bx:script>
```

### Script Syntax

```js
// Activate a staging license with error handling
result = boxlangLicenseActivate(
    email = "admin@staging.example.com",
    licenseKey = "XXXX-XXXX-XXXX-XXXX",
    serverType = "Staging"
);

if ( result.success ) {
    systemOutput( "✓ License activated: " & result.message );
    systemOutput( "Expiration: " & result.expirationDate );
} else {
    systemOutput( "✗ Error: " & result.message );
    throw new Exception( result.message );
}
```

### Error Handling Example

```js
try {
    result = boxlangLicenseActivate(
        email = "admin@example.com",
        licenseKey = "INVALID-KEY",
        serverType = "Production"
    );

    if ( !result.success ) {
        systemOutput( "Activation failed: " & result.message );
    }
} catch ( Exception e ) {
    systemOutput( "Exception during activation: " & e.message );
}
```

## Related

* [`BoxlangLicenseInfo()`](/boxlang-+-++/modules/bx-plus/built-in-functions/boxlanglicenseinfo.md) - Get current license status and information
* [`BoxlangLicenseRefresh()`](/boxlang-+-++/modules/bx-plus/built-in-functions/boxlanglicenserefresh.md) - Refresh an existing license token


---

# 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-+-++/modules/bx-plus/built-in-functions/boxlanglicenseactivate.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.
