Contentful Personalization & Analytics
API Schema Compatibility Facade
[!WARNING]
@contentful/optimization-api-schemasis deprecated. It remains available as a compatibility facade for the historical combined root schema surface. Do not add new imports from this package.
This package preserves the historical root exports for Contentful CDA, Experience API, and Insights API schemas. The owning packages maintain those contracts.
If you are upgrading an Optimization integration from v1, follow the v1-to-v2 migration guide and use Migrate imports for this deprecated facade.
Table of Contents
Getting started
Install using an NPM-compatible package manager, pnpm for example:
pnpm install @contentful/optimization-api-schemas
Existing applications can continue to import from the package root while they migrate:
import { isResolvedOptimizedEntry } from '@contentful/optimization-api-schemas'
Migrate imports
Move imports according to the contract they use:
| Contract | Import from |
|---|---|
| Experience API, Insights API, and validation schemas | @contentful/optimization-api-client/api-schemas |
| Contentful CDA schemas and helpers | @contentful/optimization-core/api-schemas |
For example, replace a combined historical import with owner-specific imports:
import { ExperienceResponse } from '@contentful/optimization-api-client/api-schemas'
import { isResolvedOptimizedEntry } from '@contentful/optimization-core/api-schemas'
Most application integrations must use an environment SDK instead of importing schemas directly. Use these imports when building or maintaining SDK layers, tooling, or tests.
Compatibility surface
The facade preserves the same combined root surface so existing imports continue to resolve. It does
not provide new schema entry points. @contentful/optimization-core/api-schemas remains the
aggregate entry point for SDK layers that need CDA schemas with the API schema pass-throughs.
Consult Zod's documentation for more information on working with Zod Mini schemas.
Related
- API Client - low-level Experience API and Insights API transport and schema ownership
- Optimization Core SDK - platform-agnostic SDK layer and CDA schema ownership
- Choosing the right SDK - package selection guidance for application integrations