@bates-solutions/squareup API Reference - v3.2.0
    Preparing search index...

    Class CatalogService

    Catalog service for managing Square catalog items

    // Create an item with variations
    const item = await square.catalog.createItem({
    name: 'Coffee',
    variations: [
    { name: 'Small', price: 350 },
    { name: 'Large', price: 450 },
    ],
    });

    // Search items
    const results = await square.catalog.search({
    objectTypes: ['ITEM'],
    query: 'coffee',
    });
    Index
    • Batch retrieve multiple catalog objects

      Parameters

      • objectIds: string[]

        Array of object IDs to retrieve

      Returns Promise<CatalogObject[]>

      Array of catalog objects

      const items = await square.catalog.batchGet(['ITEM_1', 'ITEM_2', 'ITEM_3']);
      
    • Create a category

      Parameters

      • options: CreateCategoryOptions

        Category creation options

      Returns Promise<CatalogObject>

      Created category

      const category = await square.catalog.createCategory({
      name: 'Beverages',
      });
    • Create a catalog item with variations

      Parameters

      • options: CreateCatalogItemOptions

        Item creation options

      Returns Promise<CatalogObject>

      Created catalog object

      const item = await square.catalog.createItem({
      name: 'Latte',
      description: 'Espresso with steamed milk',
      variations: [
      { name: 'Small', price: 400, sku: 'LATTE-S' },
      { name: 'Medium', price: 500, sku: 'LATTE-M' },
      { name: 'Large', price: 600, sku: 'LATTE-L' },
      ],
      });
    • Create a pricing rule that applies a discount to a product set, optionally restricted to members of given customer groups.

      Parameters

      • options: CreatePricingRuleOptions

      Returns Promise<CatalogObject>

      const rule = await square.catalog.createPricingRule({
      name: 'Wholesale 20% off',
      matchProductsId: productSet.id,
      discountId: discount.id,
      customerGroupIdsAny: [wholesaleGroup.id],
      });
    • Create a product set — a named collection of catalog objects used as the match target of a pricing rule.

      Parameters

      • options: CreateProductSetOptions

      Returns Promise<CatalogObject>

      const set = await square.catalog.createProductSet({
      name: 'Wholesale items',
      productIdsAny: ['VAR_1', 'VAR_2'],
      });
    • Create a time period (RFC 5545 iCalendar VEVENT) for use in time-bounded pricing rules, e.g. happy-hour discounts.

      Parameters

      • options: CreateTimePeriodOptions

      Returns Promise<CatalogObject>

      const happyHour = await square.catalog.createTimePeriod({
      event: 'DTSTART:20260101T170000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
      });
    • Create a complete wholesale pricing configuration in a single atomic batch upsert: a product set, a discount, and a pricing rule that links them to the given customer group.

      The three objects are created together with temporary IDs so the pricing rule can reference the just-created product set and discount. The customer group must already exist — create it via square.customerGroups.create.

      Parameters

      • options: CreateWholesalePricingOptions

      Returns Promise<WholesalePricingResult>

      const group = await square.customerGroups.create({ name: 'Wholesale' });
      const result = await square.catalog.createWholesalePricing({
      name: 'Wholesale 20% off',
      customerGroupId: group.id!,
      itemVariationIds: ['VAR_1', 'VAR_2'],
      discount: { percentage: '20' },
      });
    • Delete a catalog object

      Parameters

      • objectId: string

        Catalog object ID to delete

      Returns Promise<void>

      await square.catalog.delete('ITEM_123');
      
    • Find item variations by UPC (barcode) or SKU, without listing the whole catalog. Pages through every match, and returns the parent items too.

      Codes are matched exactly, not normalized: a UPC-A 012345678905 won't find the same barcode stored as EAN-13 0012345678905. Pass both forms if the catalog may hold either.

      Parameters

      Returns Promise<FindVariationsByCodeResult>

      The matching variations and their parent items

      const { variations, items } = await square.catalog.findVariationsByCode({
      upcs: ['012345678905'],
      skus: ['PICKLE-DILL-500'],
      });
      for (const v of variations) {
      const item = items.find((i) => i.id === v.itemVariationData?.itemId);
      console.log(item?.itemData?.name, v.itemVariationData?.upc);
      }
    • Get a catalog object by ID

      Parameters

      • objectId: string

        Catalog object ID

      Returns Promise<CatalogObject>

      Catalog object

      const item = await square.catalog.get('ITEM_123');
      
    • List all catalog objects of a specific type

      Parameters

      • objectType: CatalogObjectType

        Type of objects to list

      • Optionaloptions: { limit?: number }

        List options

      Returns Promise<CatalogObject[]>

      Array of catalog objects

      const items = await square.catalog.list('ITEM', { limit: 50 });
      
    • Search the catalog

      Parameters

      • Optionaloptions: SearchCatalogOptions

        Search options

      Returns Promise<{ cursor?: string; data: CatalogObject[] }>

      Matching catalog objects with pagination

      // Search for items
      const results = await square.catalog.search({
      objectTypes: ['ITEM'],
      query: 'coffee',
      });

      // Get all categories
      const categories = await square.catalog.search({
      objectTypes: ['CATEGORY'],
      });
    • Upsert (create or update) a catalog object

      Parameters

      • catalogObject: CatalogObject

        The catalog object to upsert

      • OptionalidempotencyKey: string

        Optional idempotency key

      Returns Promise<CatalogObject>

      The upserted catalog object

      // Update an existing item's custom attributes
      const updatedItem = await square.catalog.upsert({
      type: 'ITEM',
      id: 'EXISTING_ITEM_ID',
      version: existingItem.version,
      customAttributeValues: {
      'Square:some-key': { stringValue: 'new value' }
      },
      itemData: existingItem.itemData,
      });

      // Update a variation price
      const updatedVariation = await square.catalog.upsert({
      type: 'ITEM_VARIATION',
      id: 'EXISTING_VARIATION_ID',
      version: existingVariation.version,
      itemVariationData: {
      ...existingVariation.itemVariationData,
      priceMoney: { amount: BigInt(500), currency: 'USD' },
      },
      });