# Rule Import

You can import rules individually, entire folders, or import the entire space. You can also update existing rules or create new versions of them.

## How to Import

### **Method 1:  Import as New Rule**

**Import from Rule List:**

1. Navigate to the **Rule Lists** section.
2. Select empty space or folder where you want to import the rule.
3. Click the **Import** button.
4. Select your file: **JSON** or **XLSX**.
5. Click the **Import** button.

<figure><img src="/files/JavIfjAgbdedhpHFj87h" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/sM21Vb9afB5EFszH3v2n" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="warning" %}
The imported rule may have the same name as an existing rule, but it cannot have the same alias. If an alias conflict is detected, you will receive a warning.
{% endhint %}

### **Method 2:  Override Current Version**

1. Open the rule you want to overwrite.
2. Click the **three dots** in the top right corner to open **Rule Actions**.
3. Select **Import Version**.
4. Choose your import **Overwrite latest version** - Replaces the current version.
5. Select your file: **JSON** or **XLSX**.
6. Click the **Import** button.

<figure><img src="/files/4fzVEPvpeRJP2YZmgkZG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/fdWjcxUk7tbTuhonuvzc" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
You can find all previous changes in the [history tab](/doc/rules/common-rule-features/rule-history.md).
{% endhint %}

### **Method 3:  Import as New Version**

1. Open the rule you want to overwrite.
2. Click the **three dots** in the top right corner to open **Rule Actions**.
3. Select **Import Version**.
4. Choose your import **Import as new version** - Creates new version of rule you are importing with name and alias of current one.
5. Select your file: **JSON** or **XLSX**.
6. Click the **Import** button.

<figure><img src="/files/4fzVEPvpeRJP2YZmgkZG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/pvBRtvGrEFYVUW3AHwUX" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/2xU6jG4fWfETZuLVxd6T" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The imported rule's status depends on the `status` field in the exported file. More details about rule statuses, see [Rule Status](/doc/rules/common-rule-features/rule-settings/rule-state.md).
{% endhint %}

## File Format Requirements

### JSON Format

#### Base Schema

Every rule import must include these mandatory fields:

```json
{
    "type": "rule-type",      // See rule-specific types below
    "name": "Rule Name",      // Any string
    "status": "published",    // "published" or "pending"
    "inputSchema": {},        // JSON object defining input structure
    "outputSchema": {}        // JSON object defining output structure
}
```

{% hint style="warning" %}
If no `ruleAlias` is specified in the import file, one will be generated automatically.
{% endhint %}

#### Rule Type-Specific Requirements

In addition to the base schema, each rule type requires specific additional fields:

***

**Decision Table**

```json
{
  "type": "decision-table",
  "decisionTable": {
    "columns": [],      // Array with at least one input column and one output column
    "rows": []          // Array of row data (can be empty)
  }
}
```

**Scripting Rule**

```json
{
    "type": "complex-rule",
    "script": {}         // String containing JavaScript code
}
```

**Lookup Table**

```json
{
    "type": "lookup-table",
    "primaryKeyColumn": {},   // Object defining the primary key column
    "columns": [],            // Array defining all table columns
    "data": {}                // List of objects containing table data rows (can be empty)
}
```

**Decision Flow**

```json
{
    "type": "workflow",
    "workflowData": {}    // Object containing flow structure and nodes
}
```

**Integration Flow**

```json
{
    "type": "integration-flow",
    "workflowData": {}    // Object containing integration flow structure and nodes
}
```

### **XLSX Format**

For detailed XLSX import specifications, see [Managing Decision Table in Excel/Google Sheets](/doc/rules/common-rule-features/rule-export-and-import/managing-decision-table-in-excel-google-sheets.md)

### CSV Format

For detailed CSV import specifications, see [Lookup Table CSV Import](/doc/rules/lookup-table/data-import-and-export.md)


---

# Agent Instructions: 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:

```
GET https://docs.decisionrules.io/doc/rules/common-rule-features/rule-export-and-import/rule-import.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
