API · v1 · stable
CODEMETA OSDeveloper Center
EN
Open console

Create asset

POST/v1/assets

Creates an asset in the current tenant. The only required field is status (ACTIVE, INACTIVE, RETIRED, IN_REPAIR, ORDERED). All other fields are optional — depending on its kind, an asset carries completely different details: a server has hostname and ipAddress, a domain has registrar and domainExpiresAt, a license has licenseKey and seats. Which fields exist is documented in full in the schema reference.

name is deliberately optional as well: peripherals and small parts often have no meaningful name and are identified via manufacturer + model + serialNumber.

assetNumber and inventoryNumber are assigned by the server from the tenant’s number range. These fields — like all server-managed fields — are discarded from the request rather than rejected as an error. An audit entry (JSON patch) is created in the same transaction as the asset.

Data model

This operation works on the entity Asset (asset). All 230 fields — type, validation, required status, relationships — are listed in the schema reference.

  • Required fields: status
  • Server-managed: _id, schema, schemaVersion, tenantId, version, createdAt, updatedAt, createdBy, updatedBy, deletedAt, deletedBy, assetNumber, currentHandoverId, currentHolderType, currentHolderLabel, currentHolderSince — the platform assigns these fields; they are discarded in the request.

Example

curl -X POST https://api.codemeta-os.de/v1/assets \
  -H "X-Tenant-Id: $TENANT" \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
  "status": "ACTIVE",
  "name": "Notebook Vertrieb 04",
  "manufacturer": "Lenovo",
  "model": "ThinkPad T14 Gen 5",
  "serialNumber": "PF3ABCDE",
  "partyId": "{{sandbox.partyId}}"
}'
const result = await cm.assets.post({
  "status": "ACTIVE",
  "name": "Notebook Vertrieb 04",
  "manufacturer": "Lenovo",
  "model": "ThinkPad T14 Gen 5",
  "serialNumber": "PF3ABCDE",
  "partyId": "{{sandbox.partyId}}"
});

Best practice

Set partyId as early as possible, ideally when creating the asset. The field is not just a link but the anchor of the customer_contact data scope: anyone reading through this scope sees only assets of their own company. An asset without partyId is invisible to these users and has to be filled in later.

If you mirror devices from an inventory or RMM system, carry the foreign ID in sourceRef. Without this anchor, the second run cannot decide whether a device is new or already exists — and you create it a second time.

Response codes

HTTP Meaning
200 Default Response

Search