Bulk create item categories

Operation ID: bulkCreateItemCategories

Group: Inventory › Item Categories

Open in the interactive reference

POST /inventory/item-categories/bulk

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates multiple item categories in one request. Each category in itemCategories takes the same fields as POST inventory/item-categories. If any category can't be created, none are. The response lists the new categories in the order you sent them, each with only its id.

A parentId must name a category that already exists before this request; a category created in the same request has no id yet, so it cannot be a parent here. To seed a tree, create one level per request.

Parameters

Name In Type Required Description
Api-Version header string · v1 yes The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1.
Idempotency-Key header string no An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored.

Request body

Required, application/json: bulkCreateItemCategoriesInput.

Field Type Required Description
itemCategories array<object> yes The item categories to create. All or nothing: if any row fails, nothing is created. Example: [{"name":"Hardware","description":"Fasteners, fittings and tooling","idealTurnoverRatio":"6.50"},{"name":"Consumables","idealTurnoverRatio":"12.00"}].
itemCategories[].name string yes The display name of the category, for example 'Hardware'. Not checked for uniqueness, within this batch or against existing records.
itemCategories[].description string no A free-form description of what the category covers.
itemCategories[].active boolean no Whether the category can be chosen on new items. Defaults to true.
itemCategories[].idealTurnoverRatio decimal no The target inventory turnover for items in this category, in times per year. For analytics only. A ratio rather than an amount, so it has no currency.
itemCategories[].parentId string no The identifier of an existing category this one sits under. Omit for a top-level category. See id on GET inventory/item-categories/:id.
{
  "itemCategories": [
    {
      "name": "Hardware",
      "description": "Fasteners, fittings and tooling",
      "idealTurnoverRatio": "6.50"
    },
    {
      "name": "Consumables",
      "idealTurnoverRatio": "12.00"
    }
  ]
}

Response

200 Success

Under data (bulkCreateItemCategoriesOutput):

Field Type Required Description
created array<object> yes The created item categories, in input order. Match rows to inputs by index. Example: [{"id":"a2f47b91-0c6d-4e38-95b1-7d3e6a428c50"},{"id":"4e08c752-9b1f-4a63-8d20-c5f7134e9ab8"}].
created[].id string yes The unique identifier for the created item category.
{
  "data": {
    "created": [
      {
        "id": "a2f47b91-0c6d-4e38-95b1-7d3e6a428c50"
      },
      {
        "id": "4e08c752-9b1f-4a63-8d20-c5f7134e9ab8"
      }
    ]
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Response headers

Errors

Code Status
PARENT_NOT_FOUND 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses