> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omnilinker.pl/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure the agent with the setup wizard

> Connect the ERP Sync agent to your Omnilinker connection and your ERP database using the tray app's setup wizard.

The setup wizard is part of the tray app. It asks for four things in order: the API key, the connection, the ERP
database and a final check. The step indicator at the top of the window shows **API Key**, **Connection**,
**Database** and **Done**.

## Before you begin

* The Windows service must be installed and running. The wizard sends everything to the service, so it cannot work
  without it. See [Install the agent](/erp/install-agent).
* You must be allowed to change the agent: a member of the local group **Omnilinker ERP Sync Operators**, or an
  administrator running the tray app elevated. Setup adds the person who installed the agent to the group. See
  [Who can change the agent](/erp/install-agent#who-can-change-the-agent).
* Have the connection's agent API key ready. See [Create a connection](/erp/create-connection).
* Have the ERP database server name, database name and, for SQL Server authentication, a user name and password.

## Open the wizard

The wizard opens by itself when the tray app starts and the agent has no saved configuration yet. After
installation, the service starts the tray app for you, so the wizard appears straight away. The window is titled
**Omnilinker ERP Sync - Setup** and starts with **Welcome to Omnilinker ERP Sync**.

If the tray app is not running, start `Omnilinker.ErpSync.Tray.exe` from the `tray` subfolder of the install folder,
by default `C:\Program Files\Omnilinker\ErpSync\current\tray`.

## Complete the wizard

<Steps>
  <Step title="Enter your API key">
    On **Enter Your API Key**:

    * **API URL** is filled in with `https://omnilinker.pl`. Leave it as it is.
    * **API Key**: paste the agent API key.

    Click **Validate & Continue**. The button is available once both fields have a value.

    The agent checks the key with Omnilinker. If the key is valid, the API URL and key are **saved straight away**
    and the wizard moves on. If not, the wizard shows one of these messages:

    | Message                                                                                       | What to do                                                                                                                                                                                                                                                  |
    | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Invalid API key. Please check and try again.                                                  | Copy the key again, without spaces or line breaks. If it was lost, generate a new one on the connection.                                                                                                                                                    |
    | API key doesn't have required permissions. Grant ERP Integration permissions to this API key. | Use a key made with **Generate Agent Key** on the connection, not another API key.                                                                                                                                                                          |
    | No ERP connections found. Create one in Omnilinker first.                                     | [Create a connection](/erp/create-connection) first.                                                                                                                                                                                                        |
    | Connection timed out. Check your internet connection.                                         | Check that the machine can reach `https://omnilinker.pl`.                                                                                                                                                                                                   |
    | Only an administrator of this PC can do that.                                                 | Your Windows account may not change the agent. Ask an administrator to add you to **Omnilinker ERP Sync Operators**, then click the button again. You do not need to sign out. See [Who can change the agent](/erp/install-agent#who-can-change-the-agent). |
    | Failed to connect to service                                                                  | The tray app cannot reach the Windows service. Check that it is running: `Get-Service OmnilinkerErpSyncService`. See [Troubleshooting](/erp/troubleshooting).                                                                                               |

    <Note>
      The wizard says you can find the key "under Settings > API Keys". The agent key actually comes from the
      connection: open **ERP Integration** > **Connections** and choose **Generate Agent Key** in the connection's
      actions. See [Create a connection](/erp/create-connection).
    </Note>
  </Step>

  <Step title="Select the ERP connection">
    On **Select ERP Connection**, the wizard shows **API Key Verified** and your organization's name after
    `Tenant:`.

    In **ERP Connection**, select the connection this agent serves. The first connection in the list is selected for
    you. The line below it shows the connection's provider, for example `Provider: Wapro`.

    Click **Continue**.
  </Step>

  <Step title="Enter the ERP database connection">
    On **ERP Database Connection**, enter how the agent reaches your ERP database:

    | Field                                       | What to enter                                                                         |
    | ------------------------------------------- | ------------------------------------------------------------------------------------- |
    | **Server / Host**                           | The SQL Server name or address, including the instance name if you use one. Required. |
    | **Database Name**                           | The ERP database. Required.                                                           |
    | **Username (leave empty for Windows Auth)** | A SQL Server login. Leave it empty to use Windows authentication.                     |
    | **Password**                                | The password for that login. Leave it empty for Windows authentication.               |

    Under **Advanced Connection Options**:

    | Option                       | Meaning                                                                                                                |
    | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
    | **Encrypt connection**       | Use TLS/SSL encryption for data transfer.                                                                              |
    | **Trust server certificate** | Skip certificate validation, for self-signed certificates. Only enable it if you trust the server and its certificate. |

    Click **Test Connection** to check the settings before you save. The result appears below the button. The test
    is optional.

    Click **Save Configuration**. The button is available once **Server / Host** and **Database Name** have a value.

    <Note>
      With Windows authentication, the agent connects to the database as the service's account, Local System, not
      as you. On a SQL Server on another computer, that is the agent computer's account (`<DOMAIN>\<COMPUTER>$`). The
      test also runs inside the service, so it checks that same account. See
      [Requirements](/erp/requirements#sql-server-login).
    </Note>

    <Tip>
      If the ERP database has more than one company, set **Company ID** after the wizard, in the tray app's
      [Settings window](/erp/tray-app#settings-window). The wizard does not ask for it.
    </Tip>
  </Step>

  <Step title="Finish">
    **Setup Complete!** shows a **Configuration Summary** with the API URL, tenant, connection, ERP server and ERP
    database. Click **Finish**.

    The tray icon appears in the notification area. See [Use the tray app](/erp/tray-app) for what it shows, and
    [Monitoring](/erp/monitoring) to confirm that data is arriving in Omnilinker.
  </Step>
</Steps>

You can go back one step with **Back** on the connection and database steps.

## Skip the wizard

On the first step you can click **Skip for Now**. The wizard asks you to confirm (**Skip Setup?**). The agent stays
unconfigured and does not sync until you enter the same details in **Settings...** from the tray menu.

## What the wizard saves, and where

The Windows service saves the configuration to one file, for the whole computer:

```text theme={null}
%ProgramData%\Omnilinker\ErpSync\credentials.dat
```

That is usually `C:\ProgramData\Omnilinker\ErpSync\credentials.dat`. Only SYSTEM and administrators can open it. The
tray app never reads it: it asks the service instead.

The file holds:

* the API key and API URL,
* the selected connection and its name, and your organization's ID,
* the ERP database settings, including the password, if you entered one,
* the company ID, if you set one in **Settings...**.

The file is encrypted with Windows DPAPI using the machine scope. It can be decrypted only on this computer, so you
cannot copy it to another machine. The ERP database settings stay on this machine and are never sent to
Omnilinker.

Because the API key and URL are saved as soon as step 1 succeeds, the file exists even if you close the wizard
before the end. The wizard then does not open again on the next start. Finish the setup in **Settings...** instead.

## Change the settings later

Use **Settings...** in the tray menu to change the API key, the connection or the database settings. Saving there
takes effect without restarting the service. See [Settings window](/erp/tray-app#settings-window).

To run the wizard again from the start, exit the tray app, delete `credentials.dat` as an administrator, and start
the tray app again. The agent stops syncing until you complete the wizard.
