openapi: 3.0.0
info:
  title: Batches
  description: Batches help you track inventory items by batch numbers, manufacturing dates, and expiration dates.
  contact: {}
  version: 1.0.0
servers:
  - url: https://www.zohoapis.in/erp/v3
    description: API Endpoint
tags:
  - name: batches
    description: Batches Module
paths:
  /items/batches:
    x-mcp-group:
      - Batches
    get:
      tags:
        - batches
      operationId: list_batches
      summary: List all batches
      description: List all batches available for a given item.
      parameters:
        - name: item_id
          in: query
          description: Unique identifier of the item to fetch batches for.
          required: true
          schema:
            type: string
          example: '6780203000000167467'
        - name: include_empty_batches
          in: query
          description: Include batches that have zero quantity. Allowed values <code>true</code> and <code>false</code>.
          schema:
            type: boolean
          example: false
        - name: warehouse_id
          in: query
          description: Filter batches by warehouse ID.
          schema:
            type: string
          example: '6780203000000093215'
        - name: location_id
          in: query
          description: Filter batches by location ID.
          schema:
            type: string
          example: '6780203000000093215'
        - name: batch_ids
          in: query
          description: Comma-separated list of batch IDs to filter the response.
          schema:
            type: string
          example: 6780203000000176162,6780203000000176163
        - name: search_text
          in: query
          description: Search batches by batch number or manufacturer batch number.
          schema:
            type: string
          example: BATCH
        - name: status
          in: query
          description: Filter batches by status. Allowed values <code>active</code> and <code>inactive</code>.
          schema:
            type: string
          example: active
        - name: filter_by
          in: query
          description: Filter batches by status, expiry, type, or stock. For example <code>Status.All</code>, <code>Expiry.Expired</code>, <code>Stock.Empty</code>.
          schema:
            type: string
          example: Status.All
        - name: sort_column
          in: query
          description: Column to sort the response by. Allowed values <code>batch_number</code>, <code>external_batch_number</code>, <code>manufacturer_batch_number</code>, <code>manufactured_date</code>, <code>expiry_date</code>, <code>sales_rate</code>, and <code>label_rate</code>.
          schema:
            type: string
            default: batch_number
          example: batch_number
        - name: sort_order
          in: query
          description: Order of sorting. Allowed values <code>A</code> for ascending and <code>D</code> for descending.
          schema:
            type: string
            default: A
          example: A
        - name: page
          in: query
          description: Page number to be fetched. Default value is 1.
          schema:
            type: integer
            default: 1
          example: 1
        - name: per_page
          in: query
          description: Number of records to be fetched per page. Default value is 200.
          schema:
            type: integer
            default: 200
          example: 200
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/list-all-batches-response'
      deprecated: false
      security:
        - Zoho_Auth:
            - ERP.items.READ
    parameters:
      - $ref: '#/components/parameters/organization_id'
  /items/batches/{batch_id}:
    x-mcp-group:
      - Batches
    get:
      tags:
        - batches
      operationId: retrieve_a_batch
      summary: Retrieve a batch
      description: Fetch the details of a specific batch.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/retrieve-a-batch-response'
      deprecated: false
      security:
        - Zoho_Auth:
            - ERP.items.READ
    parameters:
      - name: batch_id
        in: path
        required: true
        description: Unique identifier of the batch.
        schema:
          type: string
        example: '6780203000000176162'
      - $ref: '#/components/parameters/organization_id'
components:
  parameters:
    organization_id:
      name: organization_id
      description: 'ID of the organization. Note: This value is a set of numeric characters.'
      in: query
      required: true
      schema:
        type: string
      example: '10234695'
  schemas:
    gendoc-attributes-schema:
      $ref: '#/components/schemas/batch-response'
    batch_id:
      description: Unique identifier of the batch.
      type: string
      example: '6780203000001066694'
    batch_in_id:
      description: Unique identifier of the inward batch entry created when stock was received.
      type: string
      example: '6780203000001003281'
    item_id:
      description: Unique identifier of the item the batch belongs to.
      type: string
      example: '6780203000001003147'
    batch_number:
      description: Batch number.
      type: string
      example: BTC-8900
    internal_batch_number:
      description: Internal batch number generated by the system.
      type: string
      example: ''
    manufacturer_batch_number:
      description: Manufacturer-provided batch number.
      type: string
      example: MFR-BTC-8900
    external_batch_number:
      description: External batch number from the manufacturer.
      type: string
      example: MFR-BTC-8900
    manufactured_date:
      description: Manufacturing date of the batch.
      type: string
      example: '2026-05-12'
    manufacturer_date:
      description: Manufacturing date of the batch. Legacy alias retained for backward compatibility; prefer <code>manufactured_date</code>.
      type: string
      example: '2026-05-12'
    expiry_date:
      description: Expiration date of the batch.
      type: string
      example: '2026-10-15'
    in_quantity:
      description: Quantity received into the batch when stock was added.
      type: number
      format: float
      example: 0
    balance_quantity:
      description: Quantity currently available in the batch.
      type: number
      format: float
      example: 0
    balance_quantity_unit:
      description: Unit of measurement for the balance quantity.
      type: string
      example: ''
    location_id:
      description: Unique identifier of the location associated with the batch.
      type: string
      example: '6780203000000093215'
    associated_locations:
      description: Locations where stock for this batch is available, with the inward and balance quantity at each location.
      type: array
      items:
        type: object
        properties:
          location_id:
            $ref: '#/components/schemas/location_id'
          in_quantity:
            $ref: '#/components/schemas/in_quantity'
          balance_quantity:
            $ref: '#/components/schemas/balance_quantity'
    status:
      description: Status of the batch. Allowed values <code>active</code> and <code>inactive</code>.
      type: string
      example: active
    sales_rate:
      description: Sales rate of the batch. Applicable only when batch pricing is enabled.
      type: number
      format: float
      example: 50.4
    label_rate:
      description: Label rate of the batch. Applicable only when batch pricing is enabled.
      type: number
      format: float
      example: 50
    custom_field_id:
      description: Unique identifier of the custom field.
      type: string
      example: '6780203000000176175'
    label:
      description: Label of the custom field.
      type: string
      example: Lot Code
    value:
      description: Value of the custom field.
      type: string
      example: LC-001
    batch_custom_fields:
      description: Custom fields configured for the batch.
      type: array
      items:
        type: object
        properties:
          custom_field_id:
            $ref: '#/components/schemas/custom_field_id'
          label:
            $ref: '#/components/schemas/label'
          value:
            $ref: '#/components/schemas/value'
    batch-response:
      description: Details of a batch.
      type: object
      properties:
        batch_id:
          $ref: '#/components/schemas/batch_id'
        item_id:
          $ref: '#/components/schemas/item_id'
        batch_number:
          $ref: '#/components/schemas/batch_number'
        manufacturer_batch_number:
          $ref: '#/components/schemas/manufacturer_batch_number'
        manufactured_date:
          $ref: '#/components/schemas/manufactured_date'
        expiry_date:
          $ref: '#/components/schemas/expiry_date'
        balance_quantity:
          $ref: '#/components/schemas/balance_quantity'
        status:
          $ref: '#/components/schemas/status'
        batch_custom_fields:
          $ref: '#/components/schemas/batch_custom_fields'
    list-batches-item:
      description: Details of a batch as returned in the list batches response.
      type: object
      properties:
        batch_id:
          $ref: '#/components/schemas/batch_id'
        batch_in_id:
          $ref: '#/components/schemas/batch_in_id'
        batch_number:
          $ref: '#/components/schemas/batch_number'
        internal_batch_number:
          $ref: '#/components/schemas/internal_batch_number'
        external_batch_number:
          $ref: '#/components/schemas/external_batch_number'
        manufacturer_batch_number:
          $ref: '#/components/schemas/manufacturer_batch_number'
        manufacturer_date:
          $ref: '#/components/schemas/manufacturer_date'
        manufactured_date:
          $ref: '#/components/schemas/manufactured_date'
        expiry_date:
          $ref: '#/components/schemas/expiry_date'
        in_quantity:
          $ref: '#/components/schemas/in_quantity'
        balance_quantity:
          $ref: '#/components/schemas/balance_quantity'
        balance_quantity_unit:
          $ref: '#/components/schemas/balance_quantity_unit'
        location_id:
          $ref: '#/components/schemas/location_id'
        associated_locations:
          $ref: '#/components/schemas/associated_locations'
        batch_custom_fields:
          $ref: '#/components/schemas/batch_custom_fields'
        status:
          $ref: '#/components/schemas/status'
    list-all-batches-response:
      type: object
      properties:
        code:
          type: integer
          example: 0
          readOnly: true
        message:
          type: string
          example: success
          readOnly: true
        batches:
          type: array
          items:
            $ref: '#/components/schemas/list-batches-item'
    retrieve-a-batch-response:
      type: object
      properties:
        code:
          type: integer
          example: 0
          readOnly: true
        message:
          type: string
          example: success
          readOnly: true
        batch:
          $ref: '#/components/schemas/batch-response'
  securitySchemes:
    Zoho_Auth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://accounts.zoho.in/oauth/v2/auth
          scopes:
            ERP.items.READ: Read Items
