How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Where to place data import file and why documents aren't appearing in Studio

1 replyLast updated: Nov 29, 2025

Hello, I'm following the guide for importing data from an external source (https://www.sanity.io/guides/guide-importing-data-from-external-sources ) but I'm a little confused about where that actual file should be saved in the project structure. I've just put a file called 'dataCall.js' in the schema's folder and made an import call for this within the schema.js file. For the moment, I'm getting an API call to work fine and I'm creating the document but nothing is happening in the studio - there are no documents created (visually at least). On the query side, the data is there, it's just not creating the documents. Perhaps I'm missing a step here? How does Sanity create a component from this procedure? Thanks for any tips and help.
AI Update

Looking at the guide you're following, I can help clarify the confusion about file placement and why your documents aren't appearing in Studio.

Where to put your import script:

Your import script (dataCall.js) should NOT go in the schema folder. The schema folder is specifically for defining your content types. Instead, you should:

For example:

my-sanity-project/
├── schemas/
│   └── schema.js (your schema definitions only)
├── scripts/
│   └── dataCall.js (your import script)
└── sanity.config.js

Why documents aren't showing in Studio:

The most likely issue is that your document _type doesn't match your schema. When you create documents, the _type field must exactly match a document type name defined in your schema. For example:

// In your schema
{
  type: 'document',
  name: 'catBreed',  // This name matters!
  fields: [...]
}

// In your import script
{
  _id: 'imported-cat-1',
  _type: 'catBreed',  // Must match the schema name exactly
  // ... other fields
}

How to properly run the import:

npm install @sanity/client node-fetch
const sanityClient = require('@sanity/client')
const fetch = require('node-fetch')

const client = sanityClient({
  projectId: 'your-project-id',
  dataset: 'your-dataset',
  token: 'your-write-token',
  useCdn: false
})

// Your fetch and transform logic here
// Then use client.createOrReplace() to create documents
node scripts/import.js

Common gotchas:

The guide you're following shows the complete process - the key is that importing is a separate operation from defining schemas. You define the schema first, then run a standalone script to populate data that conforms to that schema.

Show original thread
1 reply

Was this answer helpful?

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.

Related contributions