# Custom Object Models

Define custom LwM2M object models and resources for managed devices.

Many device resources are defined in the [OMA LwM2M Object and Resource Registry](http://www.openmobilealliance.org/wp/OMNA/LwM2M/LwM2MRegistry.html). However, you can also define additional objects by using **Custom Object Models**.

Custom objects are defined in XML or JSON. The following custom object defines three resources:

- a **CurrentX** `read` resource at `/0` which returns a float value.
- a **TargetY** `read` and `write` resource at `/1` which contains a float value.
- a **Execute Command** `execute` resource at `/2` which executes a command.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<LWM2M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://openmobilealliance.org/tech/profiles/LWM2M.xsd">
  <Object ObjectType="MODefinition">
    <Name>Custom Model</Name>
    <Description1>Custom model</Description1>
    <ObjectID>30000</ObjectID>
    <ObjectURN>urn:oma:lwm2m:oma:30000</ObjectURN>
    <MultipleInstances>Single</MultipleInstances>
    <Mandatory>Optional</Mandatory>
    <Resources>
      <Item ID="0">
        <Name>CurrentX</Name>
        <Operations>R</Operations>
        <MultipleInstances>Single</MultipleInstances>
        <Mandatory>Mandatory</Mandatory>
        <Type>Float</Type>
        <RangeEnumeration />
        <Units>m</Units>
        <Description>Current location in X.</Description>
      </Item>
      <Item ID="1">
        <Name>TargetY</Name>
        <Operations>RW</Operations>
        <MultipleInstances>Single</MultipleInstances>
        <Mandatory>Mandatory</Mandatory>
        <Type>Float</Type>
        <RangeEnumeration />
        <Units>m</Units>
        <Description>Target location in Y.</Description>
      </Item>
      <Item ID="2">
        <Name>Execute Command</Name>
        <Operations>E</Operations>
        <MultipleInstances>Single</MultipleInstances>
        <Mandatory>Mandatory</Mandatory>
        <Type />
        <RangeEnumeration />
        <Units />
        <Description>Execute command.</Description>
      </Item>
    </Resources>
    <Description2 />
  </Object>
</LWM2M>
```

When a custom object model definition is added to Soracom Inventory, its resources will be available to all managed devices. However, each device Agent must also be configured or include additional implementation to support the custom object.

## Adding Custom Object Models

1. Sign in to the **[User Console](https://console.soracom.io/?coverage_type=g)**. From the **☰ Menu**, open the **Object Models** screen.

2. Click the **+ Add object model** button.

   ![Add object model](https://docs.soracom.io/_astro/add-object-model.DktYbGBn_ZjtLf4.webp)

3. Enter the object model **Schema**, and ensure that the **Format** matches the definition format. Then click **Save**.

   ![New device object model](https://docs.soracom.io/_astro/new-device-object-model.Dr9Ch8dP_1YP1zh.webp)

The object model will be listed in the Object Models list.

![Custom object model](https://docs.soracom.io/_astro/object-model.Cq5Zw2pB_8TCNx.webp)

The resources for device whose agents have been configured for custom object model will automatically update, and you will be able to see the custom object model resources in the device details view:

![Observing custom object models](https://docs.soracom.io/_astro/observe-custom-object-model.Rq1-e-dG_IjbVJ.webp)
