# Configuration

## Sales Channel Parameters

Sales channel parameters are key-value pairs scoped to a specific sales channel. They are stored within the app itself — not in the ERP. Your app is responsible for persisting and managing them. All configuration data must be **scoped by sales channel ID**, so that settings from one channel never affect another.

### Common Parameters

| Key                           | Description                    | Example                  |
| ----------------------------- | ------------------------------ | ------------------------ |
| `LAST_ORDER_IMPORT_TIMESTAMP` | When orders were last imported | `2026-01-15T10:30:00Z`   |
| `API_KEY`                     | Platform API key               | `sk_live_abc123`         |
| `API_SECRET`                  | Platform API secret            | `encrypted_secret`       |
| `SHOP_URL`                    | Platform store URL             | `mystore.myplatform.com` |
| `PLATFORM_VERSION`            | Platform API version           | `2024-01`                |
| `AUTO_ORDER_IMPORT`           | Whether to auto-import orders  | `true`                   |
| `QUEUE_BATCH_SIZE`            | Queue processing batch size    | `10`                     |
| `TRANSFER_TYPES`              | Enabled sync types (JSON)      | `{"product":true}`       |

Set sensible defaults when a new sales channel is created (in your `sales_channel.create` webhook handler).

### Caching

Reading parameters from storage on every request can be slow. Consider an in-memory cache with the sales channel ID as part of the cache key. Invalidate cached values when a parameter is updated and add a TTL for periodic refresh.

### Credential Storage

Never log credentials. Encrypt them at rest and support rotation without downtime.

## Transfer Toggles

Transfer toggles control which sync directions are active per sales channel. Stored as a JSON string in the `TRANSFER_TYPES` parameter.

| Toggle                      | Direction                 | Default |
| --------------------------- | ------------------------- | ------- |
| `UPLOAD_ARTICLE_MASTERDATA` | Product data → platform   | `false` |
| `UPLOAD_ARTICLE_PRICE`      | Prices → platform         | `false` |
| `UPLOAD_ARTICLE_STOCK`      | Stock levels → platform   | `false` |
| `UPLOAD_ARTICLE_IMAGE`      | Product images → platform | `false` |
| `UPLOAD_ORDER_STATUS`       | Order status → platform   | `true`  |
| `DOWNLOAD_ORDERS`           | Orders ← platform         | `true`  |

Outbound article sync is disabled by default — the user enables it after configuring the channel. Order-related flows are enabled by default.

Toggles are checked before creating queue entries, so webhook handlers don't need to check them.
