> For the complete documentation index, see [llms.txt](https://raia-software-inc.gitbook.io/tacview-2-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://raia-software-inc.gitbook.io/tacview-2-documentation/api-reference/api-reference/telemetry/save-telemetry-as.md).

# SaveTelemetryAs()

Saves the current telemetry document to the specified file.

The save operation is asynchronous. Tacview starts the operation in the background and returns immediately.

## Syntax

```lua
operationHandle = SaveTelemetryAs(fileName [, fileFormat])
```

## Parameters

### `fileName`

Type: `string`

Full path of the file to save.

### `fileFormat`

Type: `string`

Optional telemetry file format to use.

The format must match one of the currently available exporters, such as `acmi` or `acmiz`.

If omitted, Tacview tries to select the most appropriate exporter from the file extension.

## Return value

Type: `integer`

Returns the handle of the save operation.

The operation handle can be used to check progress, retrieve the final result, inspect errors, or cancel the operation.

You can ignore the returned handle if the add-on does not need to track the save operation.

## Remarks

`SaveTelemetryAs()` asks Tacview to save the current telemetry to a specific file.

This is equivalent to a regular **Save As** command after the user has chosen a file name and format.

If `fileFormat` is specified, it must match an exporter currently available in Tacview.

If `fileFormat` is omitted, Tacview tries to find the best matching exporter from the file extension. If no matching exporter can be found, the operation fails.

When the save operation succeeds, Tacview sets the current telemetry document name to the saved file path and adds the file to the recent files list, provided that the saved format can also be opened by one of the currently available importers.

Because saving is performed asynchronously, the add-on can continue running while the file is being written.

Use `IsTelemetryEmpty()` before enabling or triggering a save command, so the user cannot try to save when no telemetry is loaded.

## Example

```lua
local operationHandle = SaveTelemetryAs("C:/Tacview/Exports/mission.acmi", "acmi")
```

This starts saving the current telemetry as an ACMI file.

## See also

* [SaveTelemetry()](/tacview-2-documentation/api-reference/api-reference/telemetry/save-telemetry.md)
* [LoadTelemetry()](/tacview-2-documentation/api-reference/api-reference/telemetry/load-telemetry.md)
* [ClearTelemetry()](/tacview-2-documentation/api-reference/api-reference/telemetry/clear-telemetry.md)
* [IsTelemetryEmpty()](/tacview-2-documentation/api-reference/api-reference/telemetry/is-telemetry-empty.md)
* [GetTelemetryDocumentName()](/tacview-2-documentation/api-reference/api-reference/telemetry/get-telemetry-document-name.md)
* [GetTelemetryDocumentFormat()](https://github.com/RaiaSoftwareInc/tacview2.documentation/tree/main/api-reference/telemetry/get-telemetry-document-format.md)
