Skip to main content
Question

Why is Get Catalog Categories returning an empty array via API?


Forum|alt.badge.img

Hi everyone,

I previously created a catalog using this guide, formatting the data in JSON.
Here’s an example of a first product in my custom feed:

{
  "id": 322442,
  "title": "Bench",
  "description": "Bench",
  "link": "https://sample-url.com/bench",
  "price": "50.0",
  "categories": ["Test"],
  "image_link": "https://sample-url.com/files/8/288/2/326092/640x640.jpg",
  "inventory_quantity": 9,
  "sku": "BENCH123"
}

All products were successfully synced.

The API Get Catalog Items returns the list of items as expected.
Here’s an example of one of the items in the array:

{
  "type": "catalog-item",
  "id": "$custom:::$default:::322442",
  "attributes": {
    "external_id": "322442",
    "title": "Bench",
    "description": "Bench",
    "price": 50.0,
    "url": "https://sample-url.com/bench",
    "image_full_url": "sample-url.com/files/8/288/2/326092/640x640.jpg",
    "image_thumbnail_url": "sample-url.com/files/8/288/2/326092/640x640.jpg",
    "images": [],
    "custom_metadata": {},
    "published": true,
    "created": "2025-02-07T16:08:16.206000+00:00",
    "updated": "2025-02-20T08:09:04.202000+00:00"
  },
  "relationships": {
    "variants": {
      "links": {
        "self": "https://a.klaviyo.com/api/catalog-items/$custom:::$default:::322442/relationships/variants/",
        "related": "https://a.klaviyo.com/api/catalog-items/$custom:::$default:::322442/variants/"
      }
    }
  },
  "links": {
    "self": "https://a.klaviyo.com/api/catalog-items/$custom:::$default:::322442/"
  }
}

However, Get Catalog Categories returns an empty array, and even Get Category IDs for Catalog Item for this item also returns an empty array.

Interestingly, the categories are visible in the UI.


But I need the Category IDs for further item management—updating  and creating new ones.

Has anyone encountered this issue before? Any suggestions on how to retrieve the category IDs via API?

Thanks in advance!

Did this topic or the replies in the thread help you find an answer to your question?

4 replies

Forum|alt.badge.img+2
  • Contributor I
  • 4 replies
  • February 20, 2025

Hi ​ Vlad Sokov,

It looks like the categories are not being properly associated with your catalog items in the API response, even though they appear correctly in the UI. Here are a few troubleshooting steps you can take:

1. Check If Categories Exist in the API

Since Get Catalog Categories returns an empty array, this suggests that either:

  • Categories were not created properly.
  • The API endpoint is not returning existing categories correctly.

Try calling Get Catalog Categories again and inspect the response for any errors or missing data.

2. Verify Category Assignment

Use Get Category IDs for Catalog Item for an existing item like your Bench. If it returns an empty array, it might indicate that categories are not linked to products correctly in the API.

  • Check how you are assigning categories when creating the catalog items.
  • Ensure the categories array in your JSON feed is properly structured (e.g., using valid category IDs instead of just names).

3. Check How Categories Are Stored in Klaviyo

Klaviyo may require category associations to be explicitly defined in a separate API call. Check if your categories are stored as:

  • Independent entities that need to be linked separately.
  • Part of the custom_metadata field.

4. Manually Create and Link Categories

If the API does not automatically link products to categories, you may need to:

  1. Use the Create Catalog Category API to manually create categories.
  2. Use the Update Catalog Item API to assign products to their categories.

Forum|alt.badge.img
  • Author
  • Contributor I
  • 1 reply
  • February 20, 2025

 ​@Faidat Thanks for your response!

Faidat wrote:

​​​1. Check If Categories Exist in the API

Since Get Catalog Categories returns an empty array, this suggests that either:

  • Categories were not created properly.
  • The API endpoint is not returning existing categories correctly.

Try calling Get Catalog Categories again and inspect the response for any errors or missing data.

I used Postman to check Get Catalog Categories and received the following response:

{
  "data": [],
  "links": {
    "self": "https://a.klaviyo.com/api/catalog-categories",
    "next": null,
    "prev": null
  }
}
Faidat wrote:

2. Verify Category Assignment

Use Get Category IDs for Catalog Item for an existing item like your Bench. If it returns an empty array, it might indicate that categories are not linked to products correctly in the API.

  • Check how you are assigning categories when creating the catalog items.
  • Ensure the categories array in your JSON feed is properly structured (e.g., using valid category IDs instead of just names).

The Get Category IDs for Catalog Item API returned:

{
  "data": [],
  "links": {
    "self": "https://a.klaviyo.com/api/catalog-items/$custom:::$default:::322442/relationships/categories",
    "next": null,
    "prev": null
  }
}

When creating the JSON feed, I included category names in the categories field since those were the only category-related data available to me. I followed this example as a reference for formatting the custom catalog feed. I expected that during synchronization, Klaviyo would automatically create and associate categories with items. This assumption seemed correct because, in the UI, I can see the full list of categories and filter items by category.
 

Faidat wrote:

3. Check How Categories Are Stored in Klaviyo

Klaviyo may require category associations to be explicitly defined in a separate API call. Check if your categories are stored as:

  • Independent entities that need to be linked separately.
  • Part of the custom_metadata field.

As I showed earlier, the custom_metadata field in the "Bench" item is empty ({}), meaning no additional category data is stored there.
 

Faidat wrote:

4. Manually Create and Link Categories

If the API does not automatically link products to categories, you may need to:

  1. Use the Create Catalog Category API to manually create categories.
  2. Use the Update Catalog Item API to assign products to their categories.

I specifically used custom catalog feed to sync products because of the large data volume - over 11,000 products and 100+ categories. Making individual API calls for each item would likely cause performance issues.


Byrne C
Community Manager
Forum|alt.badge.img+14
  • Community Manager
  • 88 replies
  • February 26, 2025

Hi ​@Vlad Sokov,

You may be seeing an empty array for the categories if those categories don’t have an external ID associated with them. If they only have a name, and no ID, the categories can’t be retrieved through API requests. Our engineers are looking into this to see if getting the categories can be achieved in another way, and if not, to possibly create a new solution that addresses this issue.

Let me know if I can clarify things or answer any additional questions.

-Byrne


Adunni
Problem Solver II
Forum|alt.badge.img+1
  • Problem Solver II
  • 29 replies
  • February 27, 2025

Hey ​@Vlad Sokov,

You're on the right track, but the issue likely comes from how Klaviyo handles custom catalog categories in the API. If categories are visible in the UI but not showing via API, here’s what you can try:

1. Confirm Category Syncing in API

Before retrieving categories, verify if your categories were actually synced via API. Try calling:

GET https://a.klaviyo.com/api/catalog-categories/

If this returns an empty array, your categories may not be indexed properly for API retrieval.

2. Use the Correct Relationship Endpoint

Since categories are linked as relationships to catalog items, fetch them using:

GET https://a.klaviyo.com/api/catalog-items/{catalog_item_id}/relationships/categories/

If this returns empty, Klaviyo might not have linked them properly via API, despite being visible in the UI.

3. Manually Assign Categories via API (if they aren’t linking correctly)

Try explicitly setting the category for an item using the PATCH request:

 

json

CopyEdit

{ "data": { "type": "catalog-item", "id": "$custom:::$default:::322442", "relationships": { "categories": { "data": [ { "type": "catalog-category", "id": "$custom:::$default:::test-category-id" } ] } } } }

This forces the association and should make the categories retrievable via API.

Next Steps:

  • Double-check if the category syncing issue is account-wide or just for specific items.
  • If nothing works, reach out to Klaviyo Support—they may need to reindex your catalog for API access.

🚀 Let me know if you need help testing API responses further!

Best,
Adunni