How to: Create a Container type

For information about prerequisites, see Creating Containers.

Containers have two modes leaf: and non-leaf:

  • Leaf Containers cannot contain other Containers.
  • Non-leaf Containers can contain other Containers.

To add a Container type, call the Create Container Type endpoint.

In the response body, the required member elements are:

MemberDescriptionRemarks
nameA name for the type.Container type names consist of upper and lower case alpha characters. The minimum length is 3 characters and the maximum length is 64 characters.
ttlThe time to live for a container of this container type in the transaction database.Valid ttl values are a string that specifies the ttl value as days, hours, minutes, and seconds. For example, 10d5h3m0s.

You use the isLeaf member to specify that the Container can contain other Containers. The isLeaf member is not required when creating a Container Type. If it is omitted, the default value of false is used during the creation, and the Containers created using the type cannot contain other Containers.

The Container API is asynchronous and event-driven. When creating a Container Type, we recommend that you specify a callback URL on which you can receive a notification of the success of the creation of the Container Type and notifications of the success of operations performed on Containers based on the Type.

To create a leaf Container, you must include the isLeaf member and set it to true.

For illustration purposes, this how-to uses the example of a pallet and a box.

📘

Once created, Container types cannot be deleted. Keep in mind when you are creating Container types for the purpose of testing.

To create a non-leaf Container, call the Create Container Type and pass a request body similar to the following:

{
  "name": "pallettwo",
  "isLeaf": false,
  "ttl": "10d5h3m0s"
}

The response body will be similar to the following and returns the Container Type ID as id in the data object.

{
    "request": {
        "uri": "/core/api/v1/containers/container-types",
        "method": "POST",
        "body": {
            "name": "pallettwo",
            "isLeaf": false,
            "ttl": "10d5h3m0s"
        }
    },
    "data": {
        "id": "container:9b83fc9f-decd-4a8d-a6d1-2b496df0a1a5"
    }
}

To create a leaf Container, call the Create Container Type endpoint and pass a request body similar to the following:

{
  "name": "boxtwo",
  "isLeaf": true,
  "ttl": "10d5h3m0s"
}

The response body will be similar to the following and returns the Container Type ID as id in the data object.

{
    "request": {
        "uri": "/core/api/v1/containers/container-types",
        "method": "POST",
        "body": {
            "name": "boxtwo",
            "isLeaf": true,
            "ttl": "10d5h3m0s"
        }
    },
    "data": {
        "id": "container:582d435d-5af1-4442-a095-e9b729ff4020"
    }
}