1. Assets
  2. Create & Update Asset

Assets

Create & Update Asset

Create Asset

POST
`/v1/asset`

The only properties you need to create an asset is the item_id, location_id, and layout_id, which identify the item being converted to the asset and the location and layout where it will be placed. However, we recommend adding some more properties to the asset.

item_id string (required) the identifier of the item.
location_id string (required) the identifier of the location at which the asset will be created.
layout_id string the identifier of the layout at which the asset will be stored.
value string
The value of the asset
serial_number string
The serial number of the asset. If one is not provided, it will be autogenerated by the system.
currency string
The currency in which the value is defined, for example 'USD'
barcode string
The barcode of the asset
category string
Category of the asset, for example, Electronics
sub_category string
The subcategory within the asset's category, for example, Smart Phone
warranty_expires_at Date
The date at which the warranty expires
is_warranty_valid string
A flag indicating whether the warranty is valid or not
maintenance_schedule string
How often must the maintenance be performed on the asset. Can be daily, weekly, monthly, quarterly, or yearly
next_maintenance_at Date
Next scheduled maintenance of the asset
disposal_date string
When was the asset disposed off
disposal_reason_code string
Reason code for asset disposal
disposal_comment string
Additional comments for disposal
purchased_at string
The date at which the asset was purchased
initial_value string
The initial value of the asset before any appreciation or depreciation is applied
maintenance_status string
The current maintenance status of the asset. Can be good, upcoming, required, ongoing
manifest_id string
The subcategory within the asset's category, for example, Smart Phone
linked_documents string
Any documents (like warranty_card, user_manual, invoice, transfer_order, POD, asset_request, other) associated to the asset
js
        const data = {
    item_id: "item_5TngYZKdRFTSkcVCvNa885",
    layout_id: "lay_vgM65sMYtakxwfXkTCC8FB",
    location_id: "loc_8axWLqDo9kprqgNmFpCqxo",
    maintenance_schedule: "daily",
    maintenance_status: "good",
  };

const res = await fetch(`https://api.packagex.io/v1/asset`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const asset = res.data; //Refer to the asset model

      

Update Asset

POST
`/v1/assets/:asset_id`

Most of the asset properties can be updated, including

js
        metadata
serial_number
status
maintenance_schedule
maintenance_status
value
disposal_date
disposal_reason_code
disposal_comment
purchased_at
initial_value
item_id
location_id
layout_id
updated_at
updated_by

      

Likewise, linked documents can be added or removed as follows

js
        {
  linked_documents: {
    add: [{
      "document_type": "warranty_card",
      "image": "..." // base64 encoded image
    }, {
      "id": "ast_vgM65sMYtakxwfXkTCC8FB",
      "document_type": "user_manual"
    }]
    remove: [`doc_vgM65sMYtakxwfXkTCC8FB`]
  }
}

      

The objects containing id in add will be updated and the ones without the id will be created. The document ids pased in remove will be deleted. Overall, an update request may look as follows

js
        //Update lead time mins for a delivery and org's DBA name
const data = {
    maintenance_status: "upcoming",
    status: "in_use",
    linked_documents: {
      add: [{
        "document_type": "warranty_card",
        "image": "..." // base64 encoded image
      }]
    }
};

const res = await fetch(`https://api.packagex.io/v1/assets/ast_1tH2ofoBcDbPnyZCYmrSX3`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

      

Bulk Serialize Asset Items

Assets can be bulk created and serialized against items that are marked as assets. For instance, if you have 10 asset items at a location A on a layout B, and you want to generate serial numbers for two of them and move them to layout C, the request will look like this

js
        //Update lead time mins for a delivery and org's DBA name
const data = {
    item_id: "item_5TngYZKdRFTSkcVCvNa885",
    source_layout_id: "lay_vgM65sMYtakxwfXkTCC8FB",
    location_id: "loc_8axWLqDo9kprqgNmFpCqxo",
    destination_layout_id: "lay_bnFvu9BvzfvZxvtuJk6vtQ"
    qty: 2,
  };

const res = await fetch(`https://api.packagex.io/v1/assets/serialize`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

      

If the source and destination layouts are same, destination layout can be omitted from the body.

js
        //Update lead time mins for a delivery and org's DBA name
const data = {
    item_id: "item_5TngYZKdRFTSkcVCvNa885",
    source_layout_id: "lay_vgM65sMYtakxwfXkTCC8FB",
    location_id: "loc_8axWLqDo9kprqgNmFpCqxo",
    qty: 2,
  };

const res = await fetch(`https://api.packagex.io/v1/assets/serialize`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

      

If the assets are being procured from external sources, and any existing item quantities are not to be turned into assets, source layout ID can be omitted. In this case, the user must pass an options object containing check_inventory set to false. Destination layout, however, is required in this case.

js
        //Update lead time mins for a delivery and org's DBA name
const data = {
    item_id: "item_5TngYZKdRFTSkcVCvNa885",
    destination_layout_id: "lay_bnFvu9BvzfvZxvtuJk6vtQ"
    location_id: "loc_8axWLqDo9kprqgNmFpCqxo",
    qty: 2,
    options: {
      check_inventory: false
    }
  };

const res = await fetch(`https://api.packagex.io/v1/assets/serialize`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());