---
title: "saveSession"
slug: "api/session/operations/savesession"
sidebar:
  order: 153
---

<a id="ref-03aa0461b004"></a>
<a id="ref-cc7e4d5d8203"></a>
<a id="ref-c310712def62"></a>

## Synopsis

```text
string saveSession(SessionId sessionId,
    string uri,
    SaveSessionOptions* options)
throws SessionServiceFault;
```

See also: [SessionId](/pCon/configuratorOnline/specs/api/session/types/sessionid#ref-02e397c8fdb4), [SaveSessionOptions](/pCon/configuratorOnline/specs/api/session/types/savesessionoptions#ref-9ad4a0d05810), [SessionServiceFault](/pCon/configuratorOnline/specs/api/session/faults/sessionservicefault#ref-30a5c7817f4a)

The `saveSession` operation saves the state of the current session into a pCon.basket compatible project (OBK) file. If the `uri` argument is an empty string, the project file is written to the working directory of the current session, and the operation returns an HTTP URL that can be used by the client to download the project file. The URL may be passed to the [`loadSession`](/pCon/configuratorOnline/specs/api/session/operations/loadsession) operation to load the project into the same session. If the project file is no longer needed, the client may use an HTTP DELETE request to delete the project file on the server.

If the `uri` argument is set to a FILE URL, the Online Configurator treats the URL’s path as a path into its local file system, and attempts to save the project file under this path. The `egr.eai.server.file_access` property of the session or server configuration file must be properly configured for this to work (§[Allowed File Access](/pCon/configuratorOnline/specs/guide/configuration/session-start-up-file-options/allowed-file-access#ref-a93b7d824fa6)).

URI schemes other than “file” are currently not supported.

The `suffix` option is ignored if an URI is specified.

A [`SessionServiceFault`](/pCon/configuratorOnline/specs/api/session/faults/sessionservicefault) is returned if one of the following conditions occurs:

- The `sessionId` parameter is not a valid string representation of an UUID or does not represent an open session.

- The `uri` argument is not empty and the syntax of the URI is invalid.

- The `suffix` option is specified (and the `uri` argument is empty), and the suffix contains a character not allowed in file names, or would result in an otherwise invalid file name (like a file name whose length exceeds the maximum length of file names supported by the underlying file system).

- The `uri` argument is not an empty string and the URI uses a scheme other than “file”.

- The FILE URL can not be converted into a path name.

- The server has not been configured to be allowed access to the file referenced by the FILE URL.

- The file already exists and the `overwrite` option has not been set to `true`.

- `legacyCalculationName` is not empty and does not specify the name of a calculation added to the project

- `legacyCalculationName` specifies a calculation added to the project, but the underlying pricing procedure is not considered eligible for export as a legacy calculation.

- `legacyCalculationName` is empty, the project contains at least one calculation, and the operation is unable to identify a single calculation that is eligible for export as a legacy calculation (eligibility of multiple calculations is reason for failure).

- The Online Configurator encountered some other problem while saving the project file (input/output error, file system full, inconsistent session state, …).

For a pricing procedure to be considered eligible for export, all of the following conditions must be met:

- The line tags `GROSS_SALES_PRICE` (preferred) or `PD_SALES_PRICE` and `NET_VALUE` identify a usable range of lines.

- None one of the line tags `GROSS_PURCHASE_PRICE`, `PD_PURCHASE_PRICE` and `PURCHASE_VALUE` identifies a line, or the identify a usable range of lines (`GROSS_PURCHASE_PRICE` is preferred over `PD_PURCHASE_PRICE`).

- The lines identified by the aforementioned tags must be subtotal lines, or price conditions with line insert mode `Always`.

- The lines between the first and last line of the ranges specified above must be subtotal or text lines (both will be ignored by the export), or condition lines with condition classes `Price` or `PriceModifier`. (Condition class `Tax` and line type `CalculationBreak` cause an error.)

All conditions are exported as item discounts, and the rounding of item discounts is disabled that the total net value of the exported legacy calculation is equal to the net value of the original calculation. For taxes this can not be guaranteed due to limitations of the legacy calculation scheme.
