> For the complete documentation index, see [llms.txt](https://docs.rishvi.co.uk/linnworks/llms.txt).
> Use it to discover all available pages before exploring further.

# Auto Archive Inventory

Automatically archive Linnworks inventory items where the SKU/item number contains a configured prefix, suffix, or matching text value.

## Overview

Auto Archive Inventory is a scheduled inventory-maintenance solution for Linnworks. The underlying **Inventory Archiving by SKU Match** macro searches inventory item numbers for configured text and archives every matching stock item.

The macro uses the **suffixOrPrefix** parameter as a contains-based search value. Despite the parameter name, the value can appear anywhere within the SKU or item number; it is not limited to the beginning or end.

When the schedule runs, the macro:

1. Searches the Linnworks `stockitem` table for item numbers containing the configured text.
2. Collects the matching `pkStockItemId` values.
3. Converts the returned IDs into inventory item identifiers.
4. Sends the complete list to the Linnworks Inventory API for archiving.

This macro can archive multiple inventory items during one execution and does not provide a preview before submitting the archive request.

> Archive groups of matching inventory items automatically by using a carefully selected SKU text value.

## Who Should Use Auto Archive Inventory

<Columns cols="2">
  <Card title="Inventory Administrators" icon="settings" horizontal="false" target="_self">
    Administrators responsible for inventory maintenance can archive groups of discontinued or legacy SKUs automatically.
  </Card>

  <Card title="Catalogue Management Teams" icon="layers" horizontal="false" target="_self">
    Catalogue teams can remove matching SKU groups from active inventory views without archiving each item individually.
  </Card>

  <Card title="Operations Teams" icon="bar-chart-2" horizontal="false" target="_self">
    Operations teams can schedule recurring inventory-cleanup tasks using consistent item-number rules.
  </Card>

  <Card title="Technical Administrators" icon="cpu" horizontal="false" target="_self">
    Technical teams can review the custom query, parameter handling, archive request, and execution logs.
  </Card>
</Columns>

## Key Features

<Columns cols="2">
  <Card title="Contains-Based SKU Matching" icon="sliders" horizontal="false" target="_self">
    Finds inventory items where the item number contains the configured suffixOrPrefix value anywhere in the text.
  </Card>

  <Card title="Bulk Inventory Archiving" icon="layers" horizontal="false" target="_self">
    Collects all matching stock item IDs and archives them in a single macro execution.
  </Card>

  <Card title="Scheduled Execution" icon="play" horizontal="false" target="_self">
    Supports one-time or recurring execution through Linnworks Macro Configuration.
  </Card>

  <Card title="Custom Stock Item Query" icon="cpu" horizontal="false" target="_self">
    Uses a Linnworks custom script query to search the stockitem table.
  </Card>

  <Card title="Inventory API Integration" icon="zap" horizontal="false" target="_self">
    Archives the matching inventory records through the Linnworks Inventory API.
  </Card>

  <Card title="Execution Logging" icon="bar-chart-2" horizontal="false" target="_self">
    Records macro start, errors, and completion through the macro logger.
  </Card>
</Columns>

## How Auto Archive Inventory Works

Auto Archive Inventory follows a defined sequence whenever its configured schedule runs.

<Steps>
  <Step title="Step 1: Read the configured match value" title-type="p">
    The macro receives the `suffixOrPrefix` parameter from Macro Configuration.
  </Step>

  <Step title="Step 2: Build the inventory query" title-type="p">
    A custom SQL query is built to search the Linnworks `stockitem` table for item numbers containing the configured value.
  </Step>

  <Step title="Step 3: Execute the custom script" title-type="p">
    The query is submitted through the Linnworks Dashboards API.
  </Step>

  <Step title="Step 4: Validate the query response" title-type="p">
    The macro checks whether the custom script completed successfully and returned matching rows.
  </Step>

  <Step title="Step 5: Collect matching inventory IDs" title-type="p">
    Each returned `pkStockItemId` is converted into the identifier format required by the archive request.
  </Step>

  <Step title="Step 6: Build the archive request" title-type="p">
    An `InventoryParametersRequest` is created using the complete list of matching stock item IDs.
  </Step>

  <Step title="Step 7: Archive matching items" title-type="p">
    The macro calls `ArchiveInventoryItems` to archive the matching Linnworks inventory records.
  </Step>

  <Step title="Step 8: Record completion" title-type="p">
    Errors are logged where applicable, and the macro records that inventory archiving has finished.
  </Step>
</Steps>

## Configure the Macro

Once the app is installed, you need to set up the macro configuration so the system knows which SKU text value should be used when searching for inventory items to archive.

This setup can be adjusted anytime based on your operational requirements.

### Steps to Configure

<Tabs>
  <Tab title="Step 1">
    **Go to Apps > Macro Configuration and click + Add new configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779282410096-8uzsc4jpyb-pasted-image-1779282405125.png?fm=auto&auto=compress%2Cformat" width="1368" height="568" alt="" style="width: 1368px; height: auto; cursor: pointer; margin: 0 auto;" priority={true} fetchPriority="high" />
  </Tab>

  <Tab title="Step 2">
    **Select the Auto Archive Inventory macro and click Create Configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779283122607-wu8p60vbhi-pasted-image-1779283118006.png?fm=auto&auto=compress%2Cformat" width="1424" height="650" alt="" priority={true} fetchPriority="high" />

    This creates a new configuration where you can define the schedule and required parameter value.
  </Tab>

  <Tab title="Step 3">
    **In the Macro Configuration screen, go to the Schedules tab and click New Schedule.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779283162216-e49bilw49nb-pasted-image-1779283157877.png?fm=auto&auto=compress%2Cformat" width="1012" height="736" alt="" />
  </Tab>

  <Tab title="Step 4">
    **Configure the schedule settings.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779283185788-sekd73b05sa-pasted-image-1779283180966.png?fm=auto&auto=compress%2Cformat" width="896" height="832" alt="" />

    - In the **Schedule Config** window, enter the **Name**
    - Select **Schedule type** from the dropdown:
      - **One time** runs only once
      - **Recurring** runs repeatedly based on the configured schedule
    - If **Recurring** is selected:
      - In **Frequency**, choose **Occurs** from the dropdown:
        - **Daily**
        - **Weekly**
    - Set **Recurs every** value, for example 1 day or 1 week
    - Set the **Starting on** date and time
    - Under **Daily frequency**, choose one option:
      - **Occurs once at** → specify the exact time
      - **Occurs every** → enter the interval in hours and define:
        - **Starting time**
        - **Ending time**
    - Review the **Summary** section
    - Click **Save**

    <Callout kind="warning" collapsed="false">
      **Note:** Use the schedule carefully. This macro can archive multiple inventory items in one run.
    </Callout>
  </Tab>

  <Tab title="Step 5">
    **Navigate to the Parameters tab and enter the required value.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779283207491-fih92tepy0d-pasted-image-1779283201647.png?fm=auto&auto=compress%2Cformat" width="904" height="753" alt="" />

    Configure the following parameter:

    - **suffixOrPrefix**

    This value is used to search inventory item numbers.

    For example:

    `-OLD`

    or

    `DISCONTINUED`

    <Callout kind="warning" collapsed="false">
      **Important:** The macro searches for item numbers that contain the configured value anywhere in the SKU/item number. It does not only check the start or end of the SKU.
    </Callout>
  </Tab>

  <Tab title="Step 6">
    **Make sure to enable the macro to continue with the schedule Engine configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1781346378793-i2airt5batf-pasted-image-1781346375248.png?fm=auto&auto=compress%2Cformat" width="598" height="634" alt="" />
  </Tab>

  <Tab title="Step 7">
    **Make sure to enable the macro so it can run from the configured schedule.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779283226983-eyn9r0d1moq-pasted-image-1779283222847.png?fm=auto&auto=compress%2Cformat" width="1562" height="30" alt="" />

    <Image src="REPLACE_WITH_IMAGE_URL" width="1494" height="30" alt="" />
  </Tab>
</Tabs>

## Key Benefits

Archiving inventory items by SKU pattern can be repetitive and time-consuming when performed manually. Auto Archive Inventory applies a consistent item-number rule and processes every matching record together.

> Reduce manual inventory cleanup while maintaining a repeatable, scheduled archiving process.

<Columns cols="2">
  <Card title="Reduce Manual Inventory Cleanup" icon="trending-down" horizontal="false" target="_self">
    Removes the need to locate and archive each matching stock item individually.
  </Card>

  <Card title="Archive by SKU Text" icon="sliders" horizontal="false" target="_self">
    Finds inventory items where the item number contains the configured matching value.
  </Card>

  <Card title="Support Bulk Archiving" icon="layers" horizontal="false" target="_self">
    Sends all matching stock item IDs to the archive operation during one execution.
  </Card>

  <Card title="Improve Inventory Maintenance" icon="check-circle" horizontal="false" target="_self">
    Helps remove discontinued, legacy, or unwanted SKU groups from active inventory views.
  </Card>

  <Card title="Automate Repeated Cleanup" icon="play" horizontal="false" target="_self">
    Allows the archiving process to run automatically through a one-time or recurring schedule.
  </Card>

  <Card title="Use Linnworks APIs" icon="cpu" horizontal="false" target="_self">
    Uses Linnworks custom script querying and inventory archiving functionality.
  </Card>
</Columns>

## Usage of App

Auto Archive Inventory is designed to run through the **Linnworks Macro Schedule Engine**.

It does not use selected order IDs. Each scheduled execution searches Linnworks inventory directly using the configured `suffixOrPrefix` value.

### Execution

<Card title="Trigger via Schedule" icon="play" horizontal="false" target="_self">
  Configure a one-time or recurring schedule, enter the required suffixOrPrefix value, and enable the macro configuration.
</Card>

### Outcome

When the scheduled macro runs, it:

<Steps>
  <Step title="Searches inventory item numbers" title-type="p">
    Queries the stockitem table for item numbers containing the configured value.
  </Step>

  <Step title="Collects matching stock item IDs" title-type="p">
    Reads the pkStockItemId value from each returned row.
  </Step>

  <Step title="Builds the bulk archive request" title-type="p">
    Adds all matching identifiers to an InventoryParametersRequest.
  </Step>

  <Step title="Archives matching items" title-type="p">
    Submits the complete list through the Linnworks Inventory API.
  </Step>

  <Step title="Records the result" title-type="p">
    Logs errors and macro completion.
  </Step>
</Steps>

## Input Parameters

Auto Archive Inventory requires the following configuration:

| Parameter          | Required | Description                                                                 |
| ------------------ | -------- | --------------------------------------------------------------------------- |
| **suffixOrPrefix** | Yes      | Text used to find inventory item numbers containing the configured value.   |
| **Schedule**       | Yes      | One-time or recurring schedule used to trigger the macro.                   |
| **OrderIds**       | No       | The macro searches inventory directly and does not process selected orders. |

Example match values:

| Value          | Example Matching Item Numbers          |
| -------------- | -------------------------------------- |
| `-OLD`         | `ABC-OLD`, `ABC-OLD-01`, `OLD-ABC-OLD` |
| `DISCONTINUED` | `DISCONTINUED-100`, `ABC-DISCONTINUED` |

<Callout kind="warning" collapsed="false">
  **Important:** The search uses contains behaviour. A short or common value may match more inventory items than intended.
</Callout>

The macro has the following documented behaviour:

| Condition                                   | Macro Behaviour                                                                        |
| ------------------------------------------- | -------------------------------------------------------------------------------------- |
| Item number contains suffixOrPrefix         | Adds the stock item ID to the archive request.                                         |
| Item number does not contain suffixOrPrefix | Does not include the item.                                                             |
| Multiple items match                        | Archives all matching items in one run.                                                |
| No items match                              | No stock item IDs are available to archive.                                            |
| Item may already be archived                | The macro does not perform a documented pre-check before building the archive request. |
| Matching items are found                    | No preview or confirmation stage is provided before archiving.                         |

The search is based only on the inventory item number. The documented logic does not evaluate:

- Product title
- Barcode
- Category
- Supplier
- Stock level
- Sales activity
- Other inventory fields

## Best Practices

> Treat the configured match value as a bulk archive rule and validate it carefully before enabling the schedule.

<Columns cols="2">
  <Card title="Use precise match text" icon="sliders" horizontal="false" target="_self">
    Choose a distinctive SKU pattern that is unlikely to appear in unrelated inventory items.
  </Card>

  <Card title="Review matches manually first" icon="check-circle" horizontal="false" target="_self">
    Search Linnworks inventory using the intended value before allowing the scheduled macro to run.
  </Card>

  <Card title="Avoid short common values" icon="trending-down" horizontal="false" target="_self">
    Short text can match many unrelated SKUs because the search is not limited to prefixes or suffixes.
  </Card>

  <Card title="Use cautious scheduling" icon="settings" horizontal="false" target="_self">
    Prefer a controlled one-time execution while testing and use recurring schedules only when the rule is well understood.
  </Card>

  <Card title="Avoid unsafe characters" icon="cpu" horizontal="false" target="_self">
    Avoid commas, quotes, wildcards, or special SQL characters unless the macro has been updated to handle them safely.
  </Card>

  <Card title="Review execution logs" icon="bar-chart-2" horizontal="false" target="_self">
    Check the logs after each run for query errors, archive failures, and completion status.
  </Card>
</Columns>

## FAQ

**How is Auto Archive Inventory triggered?**

The macro is triggered through a one-time or recurring schedule configured in Linnworks Macro Configuration.

**Does the macro use OrderIds?**

No. It searches Linnworks inventory directly.

**What configuration parameter is required?**

The macro requires `suffixOrPrefix`.

**Does suffixOrPrefix have to be at the start of the SKU?**

No. The macro checks whether the item number contains the value anywhere.

**Does suffixOrPrefix have to be at the end of the SKU?**

No. It can appear at the beginning, middle, or end.

**Which inventory field is searched?**

The inventory item number in the Linnworks `stockitem` table is searched.

**Which database value is collected?**

The macro collects `pkStockItemId` from each matching row.

**Can multiple items be archived in one execution?**

Yes. All matching stock item IDs are sent in one archive request.

**Does the macro show a preview before archiving?**

No preview behaviour is described in the supplied documentation.

**Does the macro ask for confirmation before archiving?**

No confirmation stage is documented.

**Does it check whether an inventory item is already archived?**

The supplied documentation states that the macro does not perform that check before sending IDs to the archive request.

**Does the macro search product titles?**

No. The search is based on item number only.

**Does the macro search barcodes or categories?**

No. Barcode and category matching are not described.

**Does the macro add notes to archived items?**

No inventory-note behaviour is described.

**Which Linnworks operation archives the items?**

The macro uses `Api.Inventory.ArchiveInventoryItems`.

**What happens when no items match?**

No matching stock item IDs are available for the archive request.

**What should be checked when no items are archived?**

Confirm that active inventory item numbers contain the configured value exactly as expected.

**What should be checked when too many items are archived?**

Review whether the configured suffixOrPrefix value was too broad or common.

**Why can a middle section of a SKU cause a match?**

The query uses contains matching rather than strict prefix or suffix matching.

**Should SQL special characters be used in the parameter?**

The source advises avoiding commas, quotes, wildcards, or special SQL characters unless the macro has been updated to handle them safely.

**What should be checked when the macro does not run?**

Confirm that the configuration is enabled and the schedule has been saved correctly.

**What should be checked when the macro reports an error?**

Review the message logged after `Error occurred:` and verify the query value and Linnworks API permissions.

## Legal Information

- **Privacy Policy:** [https://rishvi.co.uk/privacy-policy/](https://rishvi.co.uk/privacy-policy/)
- **Terms and Conditions:** [https://rishvi.co.uk/terms-conditions/](https://rishvi.co.uk/terms-conditions/)

Please review these pages to understand how data is handled and the terms governing the use of this application.

Because this macro can archive multiple inventory items without a preview stage, access to its configuration and schedule should be limited to authorised users.

## Summary

Auto Archive Inventory automates the archiving of Linnworks inventory items that match a configured SKU text value.

Once scheduled and enabled, the macro searches the `stockitem` table for item numbers containing `suffixOrPrefix`, collects the matching stock item IDs, and submits them to the Linnworks Inventory API for archiving.

<Columns cols="2">
  <Card title="Contains-based SKU search" icon="sliders" horizontal="false" target="_self">
    The configured value can match anywhere within the inventory item number.
  </Card>

  <Card title="Bulk inventory archiving" icon="layers" horizontal="false" target="_self">
    Every matching stock item ID is included in the archive operation.
  </Card>

  <Card title="Scheduled automation" icon="play" horizontal="false" target="_self">
    One-time and recurring schedules can trigger the inventory cleanup process.
  </Card>

  <Card title="Operational caution" icon="check-circle" horizontal="false" target="_self">
    Precise match values and pre-run review are important because no preview step is provided.
  </Card>
</Columns>

For unexpected results, review the configured suffixOrPrefix value, confirm the matching inventory item numbers, inspect the macro logs, and verify that the scheduled configuration is enabled.
