Reference > SDK > Overview
Webiny SDK Reference
API reference for the Webiny SDK — a type-safe JavaScript/TypeScript client for interacting with Webiny.
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
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
Create a Webiny instance with your endpoint and API token:
Configuration
| Option | Type | Required | Description |
|---|---|---|---|
endpoint | string | Yes | The URL of your Webiny API endpoint |
token | string | No | API token for authentication |
tenant | string | No | Tenant ID. Defaults to "root" |
headers | Record<string, string> | No | Additional HTTP headers sent with every request |
fetch | typeof fetch | No | Custom fetch implementation. Defaults to the global fetch |
Sub-SDKs
| Property | Class | Description |
|---|---|---|
sdk.cms | CmsSdk | Query and mutate Headless CMS entries |
sdk.fileManager | FileManagerSdk | Upload and manage files |
sdk.tenantManager | TenantManagerSdk | Create and manage tenants |
Error Handling
All SDK methods return a Result<TValue, TError> type. Use result.isOk() and result.isFail() to branch on success or failure:
Error Types
| Error class | code | When thrown |
|---|---|---|
HttpError | HTTP_ERROR | The API responded with a non-2xx HTTP status |
GraphQLError | GRAPHQL_ERROR | The API returned a GraphQL-level error |
NetworkError | NETWORK_ERROR | The fetch call itself threw (e.g. no connectivity) |