Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change Site Theme
Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates
Help articles
Overview

  • Array items resolve to same JSON type
  • Studio Performance Issues Caused by legacy HTTP protocols
  • Error: Value of type "object" is not allowed in this array field
  • AVIF
  • Experimental feature: Spaces
  • Client API CDN configuration
  • Total attribute count exceeds limit
  • Desk is now Structure
  • Invalid configuration for cross dataset reference
  • Missing or duplicate context error
  • Sanity Studio v2 is deprecated
  • React Compiler and Sanity
  • Specify API version for studio client
  • Why give schema types a title?
  • Array type has a invalid value for property "of"
  • React 19 and Sanity
  • Schema: Lift anonymous object types
  • Reference type has a invalid value for property "to"
  • Incorrect location for reference options
  • Invalid part syntax
  • Asset metadata field
  • Warning: userStore.currentUser is deprecated
  • CLI errors
  • Renamed plugin sanity-plugin-vision
  • Part name format
  • Array member type name is the same as a global type
  • Changes in block schema customization properties
  • How to migrate from date to richDate
  • Invalid shape of predefined choices
  • JS Client: Promise Polyfill
  • Introducing the document type
  • Unable to get a ref to an input component
  • Authenticating the CLI when running remotely
  • Outdated modules
  • Upgrade studio packages
  • Block Content rendering: Image materializing
  • Structure: Document schema type required
  • Parts: Declare vs implement
  • Incorrect options declaration in reference
  • Block type cannot be used outside of array
  • Structure: Node ID required
  • Structure: List items must be an array
  • Installing Node.js
  • Structure: Action or intent required
  • Object type has a invalid value for fields
  • `studioHost` and `externalStudioHost` properties deprecated
  • Schema type is ES Module but imported through require
  • Structure: Invalid list item
  • Structure: Query provided where filter is expected
  • Structure: List item IDs must be unique
  • Given type name is a reserved type
  • Structure: Schema type not found
  • API versioning
  • Migrating the legacy webhook behavior to GROQ-powered Webhooks
  • Schema type is invalid
  • Input component is missing a required prop
  • Structure: Title is required
  • Structure: Filter is required
  • Import: Asset file does not exist
  • Input component is missing a required method
  • Implementing non-overridable part
  • Structure: Item returned no child
  • How to migrate your block text schema for the new definition of inline objects
  • Structure: Schema type is required
  • How to migrate from blocks spans to block children
  • Array type cannot contain array member
  • Using tokens in the browser
  • GraphQL
  • Array member type name conflicts with built-in type
  • Source vs. compiled paths
  • Import: Asset has different target than source
  • Using global studio client without specifying API version
  • Structure: Action and intent are mutually exclusive
  • Upgrade React
  • Plugin is missing a sanity.json file
  • Structure: Document ID required
  • Incompatible combination of params and filter
  • Using listener with tokens is not supported in browsers
  • Schema type is missing a required property
  • API versioning in Javascript Client
  • Upgrade version of studio package
  • Slug: `slugifyFn` renamed
  • Renamed plugin @sanity/date-input
  • Specify API version when using custom document list filters
  • Migration Cheat Sheet: Studio v2 to v3
  • Migrating from Studio v2
  • Function Timeout
  • Functions rate limit
  • Configure TypeGen
  • Studio v3 to v4
  • Email addresses show [email protection]

On this page

Previous

Schema type is missing a required property

Next

Upgrade version of studio package

Was this page helpful?

On this page

  • Example usage
Help articlesLast updated May 15, 2025

API versioning in Javascript Client

In order to promote incremental changes, the Sanity API is versioned based on ISO dates (YYYY-MM-DD) in the UTC timezone.

Gotcha

The apiVersion property of the JavaScript client is currently optional. If no value is provided, the client will issue a deprecation warning and default to using v1 of the API.

Unless you know of a specific API version you want to use, you'll want to set it to today's UTC date. By doing this, you'll get all the latest bug fixes and features, while preventing any timezone confusion and locking the API to prevent breaking changes.

What does the apiVersion date mean?

Essentially, the date you enter for the apiVersion will use the API as it worked on that date. You can confidently use features that were added on or before that date, and any breaking changes implemented after that date will not affect your use of the API.

Note: While it's tempting to use a date that's been set dynamically as an API version, this can be a risky idea. Using a static (i.e., hard coded) date, you pin your project to a specific version of the API, which prevents any sudden changes that can break your implementation. If you hard code your API to v2021-08-31, and it works, you can be assured it will continue to work even as new API versions are released.

Protip

Recommended: apiVersion: '2021-08-31'

Not recommended: apiVersion: new Date().toISOString().slice(0, 10)

In future versions, specifying an API version will be required. For now, to maintain backward compatibility, not specifying a version will trigger a deprecation warning and fall back to using v1.

Gotcha

When using the HTTP API, the version number is prefixed with the v character (v1, v2021-08-31, etc.). In the JavaScript client, no prefix is needed (apiVersion: '2021-08-31').

Example usage

import sanityClient from '@sanity/client'

const client = sanityClient({
  projectId: 'your-project-id',
  dataset: 'production',
  apiVersion: '2021-08-31', // use a UTC date string
  token: 'sanity-auth-token', // or leave blank for unauthenticated usage
  useCdn: true, // `false` if you want to ensure fresh data
})
import sanityClient from '@sanity/client'

const client = sanityClient({
  projectId: 'your-project-id',
  dataset: 'production',
  apiVersion: '2021-08-31', // use a UTC date string
  token: 'sanity-auth-token', // or leave blank for unauthenticated usage
  useCdn: true, // `false` if you want to ensure fresh data
})