WHAT YOU'LL LEARN
  • How to initialize the Webiny SDK?
  • What configuration options are available?
  • What sub-SDKs are available and what they do?

Overview
anchor

The Webiny SDK is a type-safe JavaScript/TypeScript client for interacting with a Webiny instance from external applications — Node.js scripts, Next.js, Vue, SvelteKit, and others.

Install it from npm:

Initialization
anchor

Create a Webiny instance with your endpoint and API token:

Configuration
anchor

OptionTypeRequiredDescription
endpointstringYesThe URL of your Webiny API endpoint
tokenstringNoAPI token for authentication
tenantstringNoTenant ID. Defaults to "root"
headersRecord<string, string>NoAdditional HTTP headers sent with every request
fetchtypeof fetchNoCustom fetch implementation. Defaults to the global fetch

Sub-SDKs
anchor

PropertyClassDescription
sdk.cmsCmsSdkQuery and mutate Headless CMS entries
sdk.fileManagerFileManagerSdkUpload and manage files
sdk.tenantManagerTenantManagerSdkCreate and manage tenants

Error Handling
anchor

All SDK methods return a Result<TValue, TError> type. Use result.isOk() and result.isFail() to branch on success or failure:

Error Types
anchor

Error classcodeWhen thrown
HttpErrorHTTP_ERRORThe API responded with a non-2xx HTTP status
GraphQLErrorGRAPHQL_ERRORThe API returned a GraphQL-level error
NetworkErrorNETWORK_ERRORThe fetch call itself threw (e.g. no connectivity)