> 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-objects/get-object-id.md).

# GetObjectId()

```lua
objectId = GetObjectId(objectHandle)
```

Returns the 64-bit telemetry id of an object.

Object ids are stable values which can be saved and used later to find an object again. This makes them useful for reports, exports, saved settings, shortcuts, and analysis data which must survive outside the current session.

This function returns `nil` if `objectHandle` is invalid.

## Parameters

| Parameter      | Type    | Description           |
| -------------- | ------- | --------------------- |
| `objectHandle` | integer | Handle of the object. |

## Return value

Type: `integer` or `nil`

Returns the 64-bit telemetry id of the object.

Returns `nil` if `objectHandle` is invalid.

## Remarks

A handle is a temporary value which is only valid for the currently loaded telemetry and the current session. It is useful while your add-on is running, because it lets Tacview access the object directly.

Do not save handles in files, reports, shortcuts, settings, or network messages. A handle from one session may not identify the same object in another session, even if the same telemetry file is loaded again.

Object ids are different. They are stable values which can be saved and shared.

However, object ids can be reused over time inside the same telemetry. For example, a multiplayer aircraft may be destroyed and later respawn with the same id. This is not mandatory, but add-ons should be ready for it.

When you need to identify one exact object instance later, save a relevant timestamp with the object id. The timestamp can come from the object active time or from the analysis sample where the object was used. You can then use `FindObjectById()` with that timestamp to retrieve the corresponding object handle.

## Example

```lua
local objectId = GetObjectId(objectHandle)
local activeTimeStart = GetObjectActiveTimeStart(objectHandle)

if objectId ~= nil and activeTimeStart ~= nil then

	-- Save both values in a shortcut, report, or settings.
	-- Later, use FindObjectById(objectId, activeTimeStart)
	-- to retrieve the corresponding object handle.

end
```

## See also

* [FindObjectById()](/tacview-2-documentation/api-reference/api-reference/telemetry-objects/find-object-by-id.md)
* [GetObjectActiveTimeStart()](/tacview-2-documentation/api-reference/api-reference/object-data/get-object-active-time-start.md)
* [GetObjectActiveTime()](/tacview-2-documentation/api-reference/api-reference/object-data/get-object-active-time.md)
