= get_object_type_by_id()
:description: Resolves the numeric object type ID for a given ECM object ID (dms.GetObjectTypeById). Useful when only the object_id is known and the type must be determined.
:keywords: get_object_type_by_id, GetObjectTypeById, object_id, object type ID, resolve type
:page-tags: api, dms

Resolves the numeric object type ID for a given ECM object ID using
`dms.GetObjectTypeById`. Useful when only the object ID is known but the
type is required — for example before calling `delete()` or `move()` with
a plain integer ID.

== Signature

[tabs]
====
Sync::
+
[source,python]
----
ecm.dms.get_object_type_by_id(object_id: int) -> int
----

Async::
+
[source,python]
----
await ecm.dms.get_object_type_by_id(object_id: int) -> int
----
====

== Parameters

[cols="1,1,3"]
|===
|Parameter |Type |Description

|`object_id`
|`int`
|Numeric ID of the ECM object to look up.
|===

== Return value

The numeric object type ID associated with the given `object_id`.

== Exceptions

[cols="1,3"]
|===
|Exception |Condition

|`ECMNotFoundException`
|No object with the given `object_id` exists on the server.
|===

== Examples

=== Resolve the type of an object by ID

[tabs]
====
Sync::
+
[source,python]
----
type_id = ecm.dms.get_object_type_by_id(12345)
print(type_id)
----

Async::
+
[source,python]
----
type_id = await ecm.dms.get_object_type_by_id(12345)
print(type_id)
----
====

=== Use with delete() when only the ID is known

[tabs]
====
Sync::
+
[source,python]
----
object_id = 12345
object_type_id = ecm.dms.get_object_type_by_id(object_id)
ecm.dms.delete(object_id, object_type_id)
----

Async::
+
[source,python]
----
object_id = 12345
object_type_id = await ecm.dms.get_object_type_by_id(object_id)
await ecm.dms.delete(object_id, object_type_id)
----
====

=== Resolve and look up in the object definition

[tabs]
====
Sync::
+
[source,python]
----
object_id = 12345
type_id = ecm.dms.get_object_type_by_id(object_id)
definition = ecm.system.definition()
obj_def = definition[type_id]
print(obj_def.internal_name, obj_def.maintype)
----

Async::
+
[source,python]
----
object_id = 12345
type_id = await ecm.dms.get_object_type_by_id(object_id)
definition = await ecm.system.definition()
obj_def = definition[type_id]
print(obj_def.internal_name, obj_def.maintype)
----
====

== See also

* xref:api/dms/get.adoc[get()] — Load a single object by ID
* xref:api/dms/delete.adoc[delete()] — Delete an object by ID and type
* xref:api/system/definition.adoc[definition()] — Resolve object type definitions
