Array of documents error: "Unknown type: adBanner" in Sanity schema

10 replies
Last updated: Nov 29, 2025
Hey guysI have two schemas marketing and adBanner in simple terms marketing is an array of adBanners. I have defined the schemas as bellow.


_export_ default {

title: "Marketing",

name: "marketing",

type: "array",

of: [{ type: "adBanner" }],

};


_export_ default {

title: "Ad Banner",

name: "adBanner",

type: "document",

fields: [

{

title: "Promo Banner type",

name: "promoType",

type: "string",

},

{

title: "Promo Heading",

name: "promoHeading",

type: "string",

},

{

title: "Promo Text",

name: "promoText",

type: "array",

of: [{ type: "block" }],

},

{

title: "Affiliate marketing link",

name: "promoLink",

type: "url",

},

{

title: "Promo product image",

name: "promoImage",

type: "image",

},

],

};

but when i compile and run i can only see adBanner but not marketing section. When i debug it says

Unknown type: adBanner. Valid types are: marketing, array, block, boolean, datetime, date, document, email, file, geopoint, image, number, object, reference, slug, string, telephone, text and url

Any explanation/fixes for this.
Cheers
AI Update

I can see the issue! The problem is that you're trying to use adBanner as a document type, but then referencing it directly in an array's of property. When you use type: "document", you're creating a top-level document type that appears in your Studio's main navigation. However, you can't directly embed document types in arrays - you need to either use references or change adBanner to an object type.

Here are two ways to fix this:

If you want adBanner items to be embedded directly within the marketing array, change it from a document to an object:

export default {
  title: "Ad Banner",
  name: "adBanner",
  type: "object", // Changed from "document" to "object"
  fields: [
    {
      title: "Promo Banner type",
      name: "promoType",
      type: "string",
    },
    {
      title: "Promo Heading",
      name: "promoHeading",
      type: "string",
    },
    {
      title: "Promo Text",
      name: "promoText",
      type: "array",
      of: [{ type: "block" }],
    },
    {
      title: "Affiliate marketing link",
      name: "promoLink",
      type: "url",
    },
    {
      title: "Promo product image",
      name: "promoImage",
      type: "image",
    },
  ],
};

Then you'll need a parent document to hold the marketing array:

export default {
  title: "Marketing Page",
  name: "marketingPage",
  type: "document",
  fields: [
    {
      title: "Marketing",
      name: "marketing",
      type: "array",
      of: [{ type: "adBanner" }],
    },
  ],
};

Option 2: Use references to keep adBanner as a document

If you want adBanner to remain a standalone document type (appearing in your Studio navigation), use references:

export default {
  title: "Marketing Page",
  name: "marketingPage",
  type: "document",
  fields: [
    {
      title: "Marketing",
      name: "marketing",
      type: "array",
      of: [
        {
          type: "reference",
          to: [{ type: "adBanner" }],
        },
      ],
    },
  ],
};

The key difference: Object types are embedded content that only exist within their parent document. Document types are standalone entries that can be referenced from multiple places. For your use case, Option 1 (object type) is probably what you want unless you need to reuse the same ad banners across multiple marketing campaigns.

Make sure both schema files are properly exported in your schema configuration file (usually schema/index.ts or similar) so Sanity knows about both types!

Show original thread
10 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?