API Reference

Kits and packagings are made of components. These components need to be added in line items when you create or update a document, and to link components with the kit or the packaging.

Creation of a document with kits and packagings

To link the kit and its components, you need to add a temporary_id number (because at this step we do not have the final ID of the kit), which is a random number, in the kit line item, and use the same number as kit_line_item_id for the components. Here is an example of the mutation for the creation of a purchase with a Bike kit, made of a frame and 2 wheels :

mutation CreatePurchase($input: PurchaseInput!) {
  CreatePurchase(input: $input) {
    id
    label
    line_items {
      id
      kit_line_item_id
      is_kit
      variant {
        label
      }
    }
  }
}

Here is the input data:

{
  "input": {
    "id": null,
    "label": "P00000023",
    "notes": null,
    "total_units": null,
    "status": "active",
    "dated_at": null,
    "shipping_at": null,
    "update_incoming": true,
    "exchange_rate": 1,
    "currency": "EUR",
    "supplier": null,
    "line_items": [
      {
        "temporary_id": 1713253211104,
        "is_kit": true,
        "quantity": 1,
        "cost": 100,
        "weight": 0,
        "description": "",
        "location": {
          "id": 100009,
          "label": "Default location"
        },
        "variant": {
          "id": 100102,
          "label": "Bike"
        }
      },
      {
        "kit_line_item_id": 1713253211104,
        "is_kit": false,
        "quantity": 2,
        "cost": 25,
        "weight": 1,
        "description": "",
        "location": {
          "id": 100009,
          "label": "Default location"
        },
        "variant": {
          "id": 100097,
          "label": "Wheel"
        }
      },
      {
        "kit_line_item_id": 1713253211104,
        "is_kit": false,
        "quantity": 1,
        "cost": 50,
        "weight": 2,
        "description": "",
        "location": {
          "id": 100009,
          "label": "Default location"
        },
        "variant": {
          "id": 100098,
          "label": "Frame"
        }
      }
    ]
  }
}

Here is the result of this mutation:

{
  "data": {
    "CreatePurchase": {
      "id": 100023,
      "label": "P00000023",
      "line_items": [
        {
          "id": 100259,
          "kit_line_item_id": null,
          "is_kit": true,
          "variant": {
            "label": "Bike"
          }
        },
        {
          "id": 100260,
          "kit_line_item_id": "100259",
          "is_kit": false,
          "variant": {
            "label": "Wheel"
          }
        },
        {
          "id": 100261,
          "kit_line_item_id": "100259",
          "is_kit": false,
          "variant": {
            "label": "Frame"
          }
        }
      ]
    }
  }
}

Update documents with kits and packagings

In that case, you just have to add kit_line_item_id, with the ID of the kit, for each component of the kit

mutation UpdatePurchase($id: ID!, $input: PurchaseInput!) {
  UpdatePurchase(id: $id, input: $input) {
    id
    label
    line_items {
      id
      kit_line_item_id
      is_kit
      variant {
        label
      }
    }
  }
}
{
  "id": 100023,
  "input": {
    "id": 100023,
    "label": "P00000023",
    "notes": null,
    "total_units": 21,
    "status": "active",
    "dated_at": "2024-04-16",
    "shipping_at": null,
    "update_incoming": true,
    "exchange_rate": 1,
    "currency": "EUR",
    "supplier": null,
    "line_items": [
      {
        "id": 100259,
        "is_kit": true,
        "quantity": 1,
        "cost": 100,
        "weight": 0,
        "description": null,
        "location": {
          "id": 100009,
          "label": "Default location"
        },
        "variant": {
          "id": 100102,
          "label": "Bike"
        }
      },
      {
        "id": 100260,
        "kit_line_item_id": 100259,
        "is_kit": false,
        "quantity": 2,
        "cost": 25,
        "weight": 1,
        "description": null,
        "location": {
          "id": 100009,
          "label": "Default location"
        },
        "variant": {
          "id": 100097,
          "label": "Wheel"
        }
      },
      {
        "id": 100261,
        "kit_line_item_id": 100259,
        "is_kit": false,
        "quantity": 3,
        "cost": 50,
        "weight": 1,
        "description": null,
        "location": {
          "id": 100009,
          "label": "Default location"
        },
        "variant": {
          "id": 100098,
          "label": "Frame"
        }
      }
    ]
  }
}