webiny-sdk

Read and write Webiny CMS content from external TypeScript applications using @webiny/sdk.

8.0k|673|Updated Jan 9, 2018
One-click install
npx skills add https://github.com/webiny/webiny-js --skill webiny-sdk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webiny-sdk
Source: https://github.com/webiny/webiny-js/tree/main/skills/user-skills/webiny-sdk
Command: npx skills add https://github.com/webiny/webiny-js --skill webiny-sdk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @webiny/sdk.

What problem does it solve?

Connecting an external application (Next.js, Vue, Node.js) to a Webiny Headless CMS requires knowing the correct SDK setup, method names, the mandatory fields parameter, the values wrapper for writes, and how to diagnose misleading errors like "Content model not found" that actually stem from API key permissions.

Core Features & Use Cases

  • CMS CRUD Operations: List, get, create, update, publish, unpublish, and delete entry revisions with filtering, sorting, pagination, and TypeScript generics for type-safe values.
  • Preview vs Read Mode: Fetch published-only content for public sites or latest drafts for editorial preview tools via the preview flag.
  • File Manager, Languages, Tenants & Background Tasks: Upload files, list enabled languages, manage tenants, and trigger, monitor, or abort background task runs through webiny.tasks.
  • Use Case: A Next.js storefront needs to render products from Webiny. Initialize the SDK with a CMS-scoped API key, call webiny.cms.listEntries<Product>({ modelId: "product", fields: [...] }), check result.isOk(), and render the typed data.

Quick Start

Install @webiny/sdk, initialize the Webiny client with your API token and endpoint, then ask the AI to list entries from a content model with the required fields array and handle the Result object.

Frequently Asked Questions about webiny-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fetch CMS entries from Webiny in a Next.js app?

Install @webiny/sdk, initialize the Webiny client with your API token, endpoint, and tenant, then call webiny.cms.listEntries with a modelId and a fields array. Check result.isOk() to access the typed data or the error message.

How do I create or update a Webiny CMS entry with the SDK?

Use webiny.cms.createEntry or webiny.cms.updateEntryRevision, wrapping all content fields inside a values object in the data payload. Updates require the full revisionId in the form entryId#revisionNumber, plus a fields array.

Why does Webiny SDK return "Content model not found" when the model exists?

This error usually means the API key lacks permission to read the model, since the CMS returns not-found instead of forbidden. Verify the modelId casing, confirm the model is published and public, and grant the key Headless CMS read permissions.

Can I use the Website Builder API key for Headless CMS reads?

No, the NEXT_PUBLIC_WEBSITE_BUILDER_API_KEY only has Website Builder permissions by default and cannot read CMS models. Create a separate CMS-scoped API key and expose it as a different environment variable for SDK calls.

How do I fetch draft or unpublished content with the Webiny SDK?

Pass preview: true to webiny.cms.listEntries or webiny.cms.getEntry to receive the latest revision including drafts. The default preview: false returns only published entries, which suits public-facing apps and static generation.

How do I trigger and monitor background tasks from the Webiny SDK?

Use webiny.tasks.listDefinitions to discover valid definition IDs, then webiny.tasks.triggerTask with the definition and input. Monitor runs with listTasks and listLogs, and stop a run with abortTask using the task run ID.