# Freshly Inventory

> Track your Shopify store's inventory batches and expiry dates in Freshly Inventory and record which batch each order used.

App · 9 actions. Web page: https://docs.lodol.com/docs/integrations/freshly-inventory

## Actions

### Assign batch to order item

Record that units of an order's line item came from a batch.

**Inputs**

- Order ID (`order_id`, number, required): The Shopify order ID.
- Line item ID (`line_item_id`, number, required): The Shopify line item ID in that order.
- Batch ID (`inventory_batch_id`, number, required): The batch the units came from, from List batches.
- Quantity (`quantity`, number, required): How many units came from that batch. At least 1.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "created_at": "2024-03-01 05:48:06 UTC",
    "id": 1598,
    "inventory_batch_id": 4050,
    "line_item_id": 13374776201392,
    "order_id": 5443815864496,
    "quantity": 2,
    "updated_at": "2024-03-01 05:48:06 UTC"
  }
}
```

### Create batch

Add an inventory batch for a product variant at a location, with its quantity and dates.

**Inputs**

- Location ID (`location_id`, number, required): The Shopify location ID where the batch is stocked.
- Variant ID (`variant_id`, number, required): The Shopify product variant ID the batch belongs to.
- Quantity (`quantity`, number, required): How many units are in the batch. At least 0.
- Expiry date (`expiry_date`, date): When the batch expires.
- Received date (`received_date`, date): When the batch was received.
- Batch name (`batch_name`, text): A name for the batch.
- Batch number (`batch_number`, text): The batch or lot number.
- Barcode (`barcode`, text): The batch's barcode.
- Invoice number (`invoice_number`, text): The supplier invoice number.
- Description (`description`, text): A description of the batch.
- Adjust Shopify inventory (`enable_shopify_sync`, true/false): Also adjust the variant's Shopify inventory at the batch's location. Works only when the Freshly preference that reflects batch quantities in Shopify is on.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "created_at": "2024-03-01 05:48:06 UTC",
    "discounted": false,
    "expired_at": "2024-09-01 00:00:00 UTC",
    "expiry_date": "2024-09-01 00:00:00 UTC",
    "id": 4041,
    "location_id": 63066407088,
    "metadata": {
      "barcode": "0123456789012",
      "batch_name": "Strawberry Jam March",
      "batch_number": "SJ-2024-03",
      "description": "March restock",
      "invoice_number": "INV-1042"
    },
    "notified_at": "2024-08-25 00:00:00 UTC",
    "quantity": 55,
    "received_date": "2024-03-01 00:00:00 UTC",
    "updated_at": "2024-03-01 05:48:06 UTC",
    "variant_id": 44519466369200
  }
}
```

### Delete batch

Delete an inventory batch.

**Inputs**

- Batch ID (`id`, number, required): The batch's ID, from List batches.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "message": "Inventory batch deleted"
  }
}
```

### Delete batch assignment

Remove a batch assignment from an order's line item.

**Inputs**

- Assignment ID (`id`, number, required): The assignment's ID, from List batch assignments for order item.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "message": "Batch removed"
  }
}
```

### Get batch

Get one inventory batch by its ID.

**Inputs**

- Batch ID (`id`, number, required): The batch's ID, from List batches.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "created_at": "2024-03-01 05:48:06 UTC",
    "discounted": false,
    "expired_at": "2024-09-01 00:00:00 UTC",
    "expiry_date": "2024-09-01 00:00:00 UTC",
    "id": 4041,
    "location_id": 63066407088,
    "metadata": {
      "barcode": "0123456789012",
      "batch_name": "Strawberry Jam March",
      "batch_number": "SJ-2024-03",
      "description": "March restock",
      "invoice_number": "INV-1042"
    },
    "notified_at": "2024-08-25 00:00:00 UTC",
    "quantity": 55,
    "received_date": "2024-03-01 00:00:00 UTC",
    "updated_at": "2024-03-01 05:48:06 UTC",
    "variant_id": 44519466369200
  }
}
```

### Get shop

Get the name and Shopify domain of the store the API key belongs to.

**Inputs**: None.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "name": "Pantry Goods",
    "shopify_domain": "pantry-goods.myshopify.com"
  }
}
```

### List batch assignments for order item

List which batches the units of an order's line item came from.

**Inputs**

- Order ID (`order_id`, number, required): The Shopify order ID.
- Line item ID (`line_item_id`, number, required): The Shopify line item ID in that order.

**Outputs**

- `data` (list): The assignments.

**Example output**

```json
{
  "data": [
    {
      "created_at": "2024-03-01 05:48:06 UTC",
      "id": 1598,
      "inventory_batch_id": 4050,
      "line_item_id": 13374776201392,
      "order_id": 5443815864496,
      "quantity": 2,
      "updated_at": "2024-03-01 05:48:06 UTC"
    }
  ]
}
```

### List batches

List one page of inventory batches, optionally for one location or variant, or matching a search.

**Inputs**

- Location ID (`location_id`, number): Only batches at this Shopify location ID.
- Variant ID (`variant_id`, number): Only batches of this Shopify variant ID.
- Search (`search`, text): Words to find in the batch name, batch number, barcode, invoice number, description, product title or variant title.
- Page (`page`, number): Which page to read, starting at 1. At least 1.

**Outputs**

- `data` (list): The batches.

**Example output**

```json
{
  "data": [
    {
      "created_at": "2024-03-01 05:48:06 UTC",
      "discounted": false,
      "expired_at": "2024-09-01 00:00:00 UTC",
      "expiry_date": "2024-09-01 00:00:00 UTC",
      "id": 4041,
      "location_id": 63066407088,
      "metadata": {
        "barcode": "0123456789012",
        "batch_name": "Strawberry Jam March",
        "batch_number": "SJ-2024-03",
        "description": "March restock",
        "invoice_number": "INV-1042"
      },
      "notified_at": "2024-08-25 00:00:00 UTC",
      "quantity": 55,
      "received_date": "2024-03-01 00:00:00 UTC",
      "updated_at": "2024-03-01 05:48:06 UTC",
      "variant_id": 44519466369200
    }
  ]
}
```

### Update batch

Change a batch's quantity, dates or details. Location, variant and quantity are always needed.

**Inputs**

- Batch ID (`id`, number, required): The batch's ID, from List batches.
- Location ID (`location_id`, number, required): The Shopify location ID where the batch is stocked.
- Variant ID (`variant_id`, number, required): The Shopify product variant ID the batch belongs to.
- Quantity (`quantity`, number, required): How many units are in the batch. At least 0.
- Expiry date (`expiry_date`, date): When the batch expires.
- Received date (`received_date`, date): When the batch was received.
- Batch name (`batch_name`, text): A name for the batch.
- Batch number (`batch_number`, text): The batch or lot number.
- Barcode (`barcode`, text): The batch's barcode.
- Invoice number (`invoice_number`, text): The supplier invoice number.
- Description (`description`, text): A description of the batch.
- Adjust Shopify inventory (`enable_shopify_sync`, true/false): Also adjust the variant's Shopify inventory at the batch's location. Works only when the Freshly preference that reflects batch quantities in Shopify is on.

**Outputs**

- `data` (object): The response from Freshly Inventory.

**Example output**

```json
{
  "data": {
    "created_at": "2024-03-01 05:48:06 UTC",
    "discounted": false,
    "expired_at": "2024-09-01 00:00:00 UTC",
    "expiry_date": "2024-09-01 00:00:00 UTC",
    "id": 4041,
    "location_id": 63066407088,
    "metadata": {
      "barcode": "0123456789012",
      "batch_name": "Strawberry Jam March",
      "batch_number": "SJ-2024-03",
      "description": "March restock",
      "invoice_number": "INV-1042"
    },
    "notified_at": "2024-08-25 00:00:00 UTC",
    "quantity": 55,
    "received_date": "2024-03-01 00:00:00 UTC",
    "updated_at": "2024-03-01 05:48:06 UTC",
    "variant_id": 44519466369200
  }
}
```
