### Install @storyblok/management-api-client with npm Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Install the package using npm. Requires Node.js LTS (version 22.x recommended) or a modern browser. ```bash npm install @storyblok/management-api-client ``` -------------------------------- ### Create Asset with Metadata Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Example of using client.assets.create() to upload a file and apply metadata such as alt, title, and copyright in a follow-up update. The file argument is a Blob. ```ts const asset = await client.assets.create({ body: { short_filename: "hero.jpg", asset_folder_id: 0, alt: "Hero image", title: "Homepage hero", }, file: fileBlob, }); ``` -------------------------------- ### client.components and client.componentFolders resource clients Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Use the components and componentFolders resource clients to manage block definitions and their folders. The components client supports list, get, create, update, delete, restore, versions, version, and restoreVersion methods. The componentFolders client supports list, get, create, update, and delete methods. ```ts client.components.list(options?); client.components.get(componentId, options?); client.components.create(options); client.components.update(componentId, options); client.components.delete(componentId, options?); client.components.restore(componentId, options?); client.components.versions(componentId, options?); client.components.version(componentId, versionId, options?); client.components.restoreVersion(componentId, versionId, options?); client.componentFolders.list(options?); client.componentFolders.get(componentGroupId, options?); client.componentFolders.create(options); client.componentFolders.update(componentGroupId, options); client.componentFolders.delete(componentGroupId, options?); ``` -------------------------------- ### client.componentFolders.get(componentGroupId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Gets a single component folder by its ID. ```APIDOC ## client.componentFolders.get(componentGroupId, options?) ### Description Gets a single component folder by its ID. ### Method get ### Endpoint client.componentFolders.get(componentGroupId, options?) ### Parameters #### Path Parameters - **componentGroupId** (number) - Required - The ID of the component folder. ### Request Example ```ts const { data } = await client.componentFolders.get(123); ``` ### Response #### Success Response Returns the component folder object. ``` -------------------------------- ### client.components.version(componentId, versionId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Gets a specific version of a component. ```APIDOC ## client.components.version(componentId, versionId, options?) ### Description Gets a specific version of a component. ### Method version ### Endpoint client.components.version(componentId, versionId, options?) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. - **versionId** (number) - Required - The ID of the version. ### Request Example ```ts const { data } = await client.components.version(123, 456); ``` ### Response #### Success Response Returns the version object. ``` -------------------------------- ### client.components.get(componentId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Gets a single component by its ID. ```APIDOC ## client.components.get(componentId, options?) ### Description Gets a single component by its ID. ### Method get ### Endpoint client.components.get(componentId, options?) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. ### Request Example ```ts const { data } = await client.components.get(123); ``` ### Response #### Success Response Returns the component object. ``` -------------------------------- ### client.stories.get(storyId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Gets a single story by its numeric ID. ```APIDOC ## client.stories.get(storyId, options?) ### Description Gets a single story by its numeric ID. ### Method get ### Endpoint client.stories.get(storyId, options?) ### Parameters #### Path Parameters - **storyId** (number) - Required - The numeric ID of the story. ### Request Example ```ts const { data } = await client.stories.get(12345); ``` ### Response #### Success Response Returns the story object. ``` -------------------------------- ### client.components.list(options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists components. ```APIDOC ## client.components.list(options?) ### Description Lists components. ### Method list ### Endpoint client.components.list(options?) ### Request Example ```ts const { data } = await client.components.list(); ``` ### Response #### Success Response Returns a list of components. ``` -------------------------------- ### client.componentFolders.create(options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Creates a new component folder. ```APIDOC ## client.componentFolders.create(options) ### Description Creates a new component folder. ### Method create ### Endpoint client.componentFolders.create(options) ### Request Example ```ts const { data } = await client.componentFolders.create({ body: { componentGroup: { name: "My Folder" } } }); ``` ### Response #### Success Response Returns the created component folder. ``` -------------------------------- ### client.componentFolders.list(options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists component folders. ```APIDOC ## client.componentFolders.list(options?) ### Description Lists component folders. ### Method list ### Endpoint client.componentFolders.list(options?) ### Request Example ```ts const { data } = await client.componentFolders.list(); ``` ### Response #### Success Response Returns a list of component folders. ``` -------------------------------- ### Initialize client and list stories with createManagementApiClient Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Initializes the client with a personal access token, space ID, and region, then lists stories. The response contains data, error, response, and request. Set throwOnError: true to receive data directly and have errors thrown as ClientError. ```ts import { createManagementApiClient } from "@storyblok/management-api-client"; const client = createManagementApiClient({ personalAccessToken: process.env.STORYBLOK_PERSONAL_ACCESS_TOKEN!, spaceId: 12345, region: "eu", }); const { data, error } = await client.stories.list(); if (error) throw error; console.log(data?.stories); ``` -------------------------------- ### client.components.create(options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Creates a new component. ```APIDOC ## client.components.create(options) ### Description Creates a new component. ### Method create ### Endpoint client.components.create(options) ### Request Example ```ts const { data } = await client.components.create({ body: { component: { name: "My Component" } } }); ``` ### Response #### Success Response Returns the created component. ``` -------------------------------- ### Create a story with client.stories.create() Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Creates a new story. The body must include a story object with name, slug, and content. The content should be a valid story content object. ```ts const { data } = await client.stories.create({ body: { story: { name: "Home", slug: "home", content: { component: "page", title: "Welcome" }, }, }, }); ``` -------------------------------- ### client.stories.create(options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Creates a new story. Pass story content as `options.body.story`. ```APIDOC ## client.stories.create(options) ### Description Creates a new story. Pass story content as `options.body.story`. ### Method create ### Endpoint client.stories.create(options) ### Parameters #### Request Body - **body.story** (object) - Required - The story object with `name`, `slug`, and `content`. ### Request Example ```ts const { data } = await client.stories.create({ body: { story: { name: "Home", slug: "home", content: { component: "page", title: "Welcome" }, }, }, }); ``` ### Response #### Success Response Returns the created story. ``` -------------------------------- ### Asset and Asset Folder Resource Methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the methods available on client.assets and client.assetFolders. Use these to upload, read, update, and organize assets and their folders. client.assets.upload() performs the full upload flow in one call, while client.assets.create() wraps upload() and applies metadata. ```ts client.assets.list(options?); client.assets.get(assetId, options?); client.assets.create(options); client.assets.upload(options); client.assets.update(assetId, options); client.assets.delete(assetId, options?); client.assets.deleteMany(options); client.assets.bulkMove(options); client.assets.bulkRestore(options); client.assets.convertToShared(assetId, options); client.assets.signResponseObject(options); client.assets.finalize(signedResponseObjectId, options?); client.assetFolders.list(options?); client.assetFolders.get(assetFolderId, options?); client.assetFolders.create(options); client.assetFolders.update(assetFolderId, options); client.assetFolders.delete(assetFolderId, options?); ``` -------------------------------- ### Preset Resource Methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the methods available on client.presets for managing pre-filled component configurations that editors can choose from in the Visual Editor. ```ts client.presets.list(options?); client.presets.get(presetId, options?); client.presets.create(options); client.presets.update(presetId, options); client.presets.delete(presetId, options?); ``` -------------------------------- ### Manage experiments with client.experiments Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Use the experiments resource client to manage experiments and their lifecycle. Top-level methods cover CRUD plus state transitions (activate, pause, complete, completeWithWinner, selectWinner). Nested stories and storyMappings resource clients attach stories and variant mappings, and results reads or pushes experiment results. ```ts client.experiments.list(options?); client.experiments.get(experimentId, options?); client.experiments.create(options); client.experiments.update(experimentId, options); client.experiments.delete(experimentId, options?); client.experiments.activate(experimentId, options?); client.experiments.pause(experimentId, options?); client.experiments.complete(experimentId, options?); client.experiments.completeWithWinner(experimentId, variantId, options?); client.experiments.selectWinner(experimentId, variantId, options?); client.experiments.stories.create(experimentId, options); client.experiments.stories.delete(experimentId, storyId, options?); client.experiments.storyMappings.create(experimentId, variantId, options); client.experiments.storyMappings.delete(experimentId, variantId, originalStoryId, options?); client.experiments.results.get(experimentId, options?); client.experiments.results.push(experimentId, options); ``` -------------------------------- ### client.assets and client.assetFolders Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Resource clients for managing assets and asset folders. Includes methods for listing, retrieving, creating, uploading, updating, deleting, bulk operations, and converting assets to shared. ```APIDOC ## client.assets and client.assetFolders ### Description Use the `assets` and `assetFolders` resource clients to upload, read, update, and organize assets and their folders. ### Methods #### client.assets.list(options?) - **Description**: Lists assets. - **Parameters**: `options` (object, optional) - Query options. #### client.assets.get(assetId, options?) - **Description**: Retrieves a single asset by ID. - **Parameters**: `assetId` (string/number, required) - The asset ID. `options` (object, optional) - Query options. #### client.assets.create(options) - **Description**: Creates an asset. Wraps `upload()` and applies metadata such as `alt`, `title`, and `copyright` in a follow-up update. - **Parameters**: `options` (object, required) - Options containing `body` and `file`. #### client.assets.upload(options) - **Description**: Performs the full upload flow in one call (sign, upload to S3, finalize) and returns the resulting `Asset`. - **Parameters**: `options` (object, required) - Options containing `body` and `file`. #### client.assets.update(assetId, options) - **Description**: Updates an asset. Accepts an optional `file` argument: when provided together with a `short_filename`, the file is replaced first and metadata is updated afterwards in the same call. - **Parameters**: `assetId` (string/number, required) - The asset ID. `options` (object, required) - Options containing `body` and optionally `file`. #### client.assets.delete(assetId, options?) - **Description**: Deletes an asset. - **Parameters**: `assetId` (string/number, required) - The asset ID. `options` (object, optional) - Query options. #### client.assets.deleteMany(options) - **Description**: Deletes multiple assets in a single request. - **Parameters**: `options` (object, required) - Options for bulk delete. #### client.assets.bulkMove(options) - **Description**: Moves multiple assets in a single request. - **Parameters**: `options` (object, required) - Options for bulk move. #### client.assets.bulkRestore(options) - **Description**: Restores multiple assets in a single request. - **Parameters**: `options` (object, required) - Options for bulk restore. #### client.assets.convertToShared(assetId, options) - **Description**: Transfers an asset from the space into the organization’s shared asset library. - **Parameters**: `assetId` (string/number, required) - The asset ID. `options` (object, required) - Options for conversion. #### client.assets.signResponseObject(options) - **Description**: Lower-level method to sign a response object for custom upload flows. - **Parameters**: `options` (object, required) - Options for signing. #### client.assets.finalize(signedResponseObjectId, options?) - **Description**: Lower-level method to finalize a signed response object for custom upload flows. - **Parameters**: `signedResponseObjectId` (string, required) - The signed response object ID. `options` (object, optional) - Query options. #### client.assetFolders.list(options?) - **Description**: Lists asset folders. - **Parameters**: `options` (object, optional) - Query options. #### client.assetFolders.get(assetFolderId, options?) - **Description**: Retrieves a single asset folder by ID. - **Parameters**: `assetFolderId` (string/number, required) - The asset folder ID. `options` (object, optional) - Query options. #### client.assetFolders.create(options) - **Description**: Creates an asset folder. - **Parameters**: `options` (object, required) - Options for creation. #### client.assetFolders.update(assetFolderId, options) - **Description**: Updates an asset folder. - **Parameters**: `assetFolderId` (string/number, required) - The asset folder ID. `options` (object, required) - Options for update. #### client.assetFolders.delete(assetFolderId, options?) - **Description**: Deletes an asset folder. - **Parameters**: `assetFolderId` (string/number, required) - The asset folder ID. `options` (object, optional) - Query options. ### Example ts const asset = await client.assets.create({ body: { short_filename: "hero.jpg", asset_folder_id: 0, alt: "Hero image", title: "Homepage hero", }, file: fileBlob, }); ### Notes - `client.assets.upload()` performs the full upload flow in one call (sign, upload to S3, finalize) and returns the resulting `Asset`. - `client.assets.create()` wraps `upload()` and additionally applies metadata such as `alt`, `title`, and `copyright` in a follow-up update. - Use the lower-level `signResponseObject()` and `finalize()` methods only when a custom upload flow is needed. - `deleteMany()`, `bulkMove()`, and `bulkRestore()` operate on multiple assets in a single request. - `convertToShared()` transfers an asset from the space into the organization’s shared asset library. - The package exports the `normalizeAssetUrl()` helper for normalizing Storyblok asset URLs across regions. ``` -------------------------------- ### client.experiments Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Manage experiments and their lifecycle, including CRUD operations and state transitions. ```APIDOC ## client.experiments ### Description Manage experiments and their lifecycle, including CRUD operations and state transitions. ### Methods - `client.experiments.list(options?)` - `client.experiments.get(experimentId, options?)` - `client.experiments.create(options)` - `client.experiments.update(experimentId, options)` - `client.experiments.delete(experimentId, options?)` - `client.experiments.activate(experimentId, options?)` - `client.experiments.pause(experimentId, options?)` - `client.experiments.complete(experimentId, options?)` - `client.experiments.completeWithWinner(experimentId, variantId, options?)` - `client.experiments.selectWinner(experimentId, variantId, options?)` ### Nested Resources - `client.experiments.stories.create(experimentId, options)` - `client.experiments.stories.delete(experimentId, storyId, options?)` - `client.experiments.storyMappings.create(experimentId, variantId, options)` - `client.experiments.storyMappings.delete(experimentId, variantId, originalStoryId, options?)` - `client.experiments.results.get(experimentId, options?)` - `client.experiments.results.push(experimentId, options)` ### Parameters - `experimentId` (string) - Required - The ID of the experiment. - `variantId` (string) - Required - The ID of the variant. - `storyId` (string) - Required - The ID of the story. - `originalStoryId` (string) - Required - The ID of the original story. - `options` (object) - Optional - Additional request options. ``` -------------------------------- ### client.components.versions(componentId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the version history of a component. ```APIDOC ## client.components.versions(componentId, options?) ### Description Lists the version history of a component. ### Method versions ### Endpoint client.components.versions(componentId, options?) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. ### Request Example ```ts const { data } = await client.components.versions(123); ``` ### Response #### Success Response Returns a list of versions. ``` -------------------------------- ### client.stories.list(options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists stories. Accepts optional query parameters and per-request space override. ```APIDOC ## client.stories.list(options?) ### Description Lists stories. Accepts optional query parameters and per-request space override. ### Method list ### Endpoint client.stories.list(options?) ### Parameters #### Query Parameters - **path.space_id** (number) - Optional - Overrides the client-level `spaceId` for this request. ### Request Example ```ts const { data } = await client.stories.list({ path: { space_id: 67890 } }); ``` ### Response #### Success Response Returns a list of stories. ``` -------------------------------- ### client.presets Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Resource client for managing presets, which are pre-filled component configurations for the Visual Editor. ```APIDOC ## client.presets ### Description Use the `presets` resource client to manage the pre-filled component configurations that editors can choose from in the Visual Editor. ### Methods #### client.presets.list(options?) - **Description**: Lists presets. - **Parameters**: `options` (object, optional) - Query options. #### client.presets.get(presetId, options?) - **Description**: Retrieves a single preset by ID. - **Parameters**: `presetId` (string/number, required) - The preset ID. `options` (object, optional) - Query options. #### client.presets.create(options) - **Description**: Creates a preset. - **Parameters**: `options` (object, required) - Options for creation. #### client.presets.update(presetId, options) - **Description**: Updates a preset. - **Parameters**: `presetId` (string/number, required) - The preset ID. `options` (object, required) - Options for update. #### client.presets.delete(presetId, options?) - **Description**: Deletes a preset. - **Parameters**: `presetId` (string/number, required) - The preset ID. `options` (object, optional) - Query options. ``` -------------------------------- ### Users Resource Methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the methods available on client.users. me() returns the profile of the authenticated user; updateMe() updates it. ```ts client.users.me(options?); client.users.updateMe(options); ``` -------------------------------- ### client.spaces Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Resource client for listing and managing spaces. ```APIDOC ## client.spaces ### Description Use the `spaces` resource client to list and manage spaces. ### Methods #### client.spaces.list(options?) - **Description**: Returns every space the authenticated user can access. - **Parameters**: `options` (object, optional) - Query options. #### client.spaces.get(options?) - **Description**: Retrieves the space identified by `spaceId`. - **Parameters**: `options` (object, optional) - Query options. #### client.spaces.create(options) - **Description**: Creates a space. - **Parameters**: `options` (object, required) - Options for creation. #### client.spaces.update(options) - **Description**: Updates the space identified by `spaceId`. - **Parameters**: `options` (object, required) - Options for update. #### client.spaces.delete(options?) - **Description**: Deletes the space identified by `spaceId`. - **Parameters**: `options` (object, optional) - Query options. ### Notes - `client.spaces.list()` returns every space the authenticated user can access. - The other methods operate on the space identified by `spaceId`. ``` -------------------------------- ### Spaces Resource Methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the methods available on client.spaces. list() returns every space the authenticated user can access; other methods operate on the space identified by spaceId. ```ts client.spaces.list(options?); client.spaces.get(options?); client.spaces.create(options); client.spaces.update(options); client.spaces.delete(options?); ``` -------------------------------- ### Datasource and Datasource Entry Resource Methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the methods available on client.datasources and client.datasourceEntries. update() issues a PATCH (only fields present change), while replace() issues a PUT (all updatable fields are replaced). ```ts client.datasources.list(options?); client.datasources.get(datasourceId, options?); client.datasources.create(options); client.datasources.update(datasourceId, options); client.datasources.replace(datasourceId, options); client.datasources.delete(datasourceId, options?); client.datasourceEntries.list(options?); client.datasourceEntries.get(datasourceEntryId, options?); client.datasourceEntries.create(options); client.datasourceEntries.update(datasourceEntryId, options); client.datasourceEntries.replace(datasourceEntryId, options); client.datasourceEntries.delete(datasourceEntryId, options?); ``` -------------------------------- ### client.sharedAssetFolders Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Manage shared asset folders, including listing, retrieving, creating, updating, and deleting folders. ```APIDOC ## client.sharedAssetFolders ### Description Manage shared asset folders, including listing, retrieving, creating, updating, and deleting folders. ### Methods - `client.sharedAssetFolders.list(options?)` - `client.sharedAssetFolders.get(folderId, options?)` - `client.sharedAssetFolders.create(options)` - `client.sharedAssetFolders.update(folderId, options)` - `client.sharedAssetFolders.delete(folderId, options?)` ### Parameters - `folderId` (string) - Required - The ID of the shared asset folder. - `options` (object) - Optional - Additional request options. ### Notes - Each shared asset folder carries per-space access, exposed through the `AccessLevel` and `AssetFolderAccess` types. ``` -------------------------------- ### createManagementApiClient(config) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Creates a Management API client with authentication options and configuration settings. ```APIDOC ## createManagementApiClient(config) ### Description Creates a Management API client. Authentication accepts either a personal access token or an OAuth bearer token, never both. ### Method createManagementApiClient ### Endpoint createManagementApiClient(config) ### Parameters #### Configuration Options - **personalAccessToken** (string) - Required unless `oauthToken` is provided. Personal access token used for authentication. - **oauthToken** (string) - Required unless `personalAccessToken` is provided. OAuth bearer token used for authentication. - **spaceId** (number) - Required for space-scoped endpoints. Default space ID; can be overridden per request. - **region** (string) - Region code (`'eu'`, `'us'`, `'ap'`, `'ca'`, `'cn'`). Defaults to `'eu'`. - **baseUrl** (string) - Overrides the regional base URL (useful for testing). - **headers** (object) - Extra request headers merged into every request. - **throwOnError** (boolean) - Throws `ClientError` on HTTP errors instead of returning them. Defaults to `false`. - **retry** (object) - Retry options. Defaults to up to 12 retries on HTTP 429 with exponential backoff. - **timeout** (number) - Request timeout in milliseconds. Defaults to `30_000`. - **rateLimit** (boolean|number|object) - Preventive rate limiting. Defaults to six requests per second. `false` disables it; a number sets `requestsPerSecond`; or pass `{ requestsPerSecond }`. ### Request Example ```ts createManagementApiClient({ personalAccessToken: 'YOUR_TOKEN', spaceId: 12345, region: 'eu' }); ``` ### Response #### Success Response Returns a client instance with resource clients (e.g., `stories`, `components`, `componentFolders`). ``` -------------------------------- ### client.stories.versions(storyId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the version history of a story. ```APIDOC ## client.stories.versions(storyId, options?) ### Description Lists the version history of a story. ### Method versions ### Endpoint client.stories.versions(storyId, options?) ### Parameters #### Path Parameters - **storyId** (number) - Required - The numeric ID of the story. ### Request Example ```ts const { data } = await client.stories.versions(12345); ``` ### Response #### Success Response Returns a list of versions. ``` -------------------------------- ### client.datasources and client.datasourceEntries Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Resource clients for managing datasources and their entries. Includes methods for listing, retrieving, creating, updating, replacing, and deleting. ```APIDOC ## client.datasources and client.datasourceEntries ### Description Use the `datasources` and `datasourceEntries` resource clients to manage datasources and their entries. ### Methods #### client.datasources.list(options?) - **Description**: Lists datasources. - **Parameters**: `options` (object, optional) - Query options. #### client.datasources.get(datasourceId, options?) - **Description**: Retrieves a single datasource by ID. - **Parameters**: `datasourceId` (string/number, required) - The datasource ID. `options` (object, optional) - Query options. #### client.datasources.create(options) - **Description**: Creates a datasource. - **Parameters**: `options` (object, required) - Options for creation. #### client.datasources.update(datasourceId, options) - **Description**: Updates a datasource. Issues a `PATCH`: only the fields present in the body change. - **Parameters**: `datasourceId` (string/number, required) - The datasource ID. `options` (object, required) - Options for update. #### client.datasources.replace(datasourceId, options) - **Description**: Replaces a datasource. Issues a `PUT`: all updatable fields are replaced. - **Parameters**: `datasourceId` (string/number, required) - The datasource ID. `options` (object, required) - Options for replacement. #### client.datasources.delete(datasourceId, options?) - **Description**: Deletes a datasource. - **Parameters**: `datasourceId` (string/number, required) - The datasource ID. `options` (object, optional) - Query options. #### client.datasourceEntries.list(options?) - **Description**: Lists datasource entries. - **Parameters**: `options` (object, optional) - Query options. #### client.datasourceEntries.get(datasourceEntryId, options?) - **Description**: Retrieves a single datasource entry by ID. - **Parameters**: `datasourceEntryId` (string/number, required) - The datasource entry ID. `options` (object, optional) - Query options. #### client.datasourceEntries.create(options) - **Description**: Creates a datasource entry. - **Parameters**: `options` (object, required) - Options for creation. #### client.datasourceEntries.update(datasourceEntryId, options) - **Description**: Updates a datasource entry. Issues a `PATCH`: only the fields present in the body change. - **Parameters**: `datasourceEntryId` (string/number, required) - The datasource entry ID. `options` (object, required) - Options for update. #### client.datasourceEntries.replace(datasourceEntryId, options) - **Description**: Replaces a datasource entry. Issues a `PUT`: all updatable fields are replaced. - **Parameters**: `datasourceEntryId` (string/number, required) - The datasource entry ID. `options` (object, required) - Options for replacement. #### client.datasourceEntries.delete(datasourceEntryId, options?) - **Description**: Deletes a datasource entry. - **Parameters**: `datasourceEntryId` (string/number, required) - The datasource entry ID. `options` (object, optional) - Query options. ### Notes - `update()` issues a `PATCH`: only the fields present in the body change. - `replace()` issues a `PUT`: all updatable fields are replaced. ``` -------------------------------- ### Manage shared assets, folders, and internal tags Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Use sharedAssets, sharedAssetFolders, and sharedInternalTags resource clients to manage shared asset libraries, folders, and internal tags. As with client.assets, sharedAssets.create() runs the full signed-upload flow, while sharedAssets.upload() is the lower-level variant. Each shared asset folder carries per-space access, exposed through the AccessLevel and AssetFolderAccess types. ```ts client.sharedAssets.list(options?); client.sharedAssets.get(assetId, options?); client.sharedAssets.upload(options); client.sharedAssets.create(options); client.sharedAssets.delete(assetId, options?); client.sharedAssetFolders.list(options?); client.sharedAssetFolders.get(folderId, options?); client.sharedAssetFolders.create(options); client.sharedAssetFolders.update(folderId, options); client.sharedAssetFolders.delete(folderId, options?); client.sharedInternalTags.list(options); client.sharedInternalTags.create(options); client.sharedInternalTags.update(tagId, options); client.sharedInternalTags.delete(tagId, options); ``` -------------------------------- ### client.users Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Resource client for reading and updating the authenticated user. ```APIDOC ## client.users ### Description Use the `users` resource client to read and update the authenticated user. ### Methods #### client.users.me(options?) - **Description**: Returns the profile of the authenticated user. - **Parameters**: `options` (object, optional) - Query options. #### client.users.updateMe(options) - **Description**: Updates the profile of the authenticated user. - **Parameters**: `options` (object, required) - Options for update. ### Notes - `me()` returns the profile of the authenticated user; `updateMe()` updates it. ``` -------------------------------- ### client.stories resource client methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Use the stories resource client to read, create, update, publish, duplicate, and version stories. storyId is a numeric ID. Pass story content as options.body.story. Use client.stories.versions(storyId) to list the version history of a story. ```ts client.stories.list(options?); client.stories.get(storyId, options?); client.stories.create(options); client.stories.update(storyId, options); client.stories.delete(storyId, options?); client.stories.duplicate(storyId, options); client.stories.publish(storyId, options?); client.stories.versions(storyId, options?); ``` -------------------------------- ### client.components.restore(componentId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Restores a deleted component by its ID. ```APIDOC ## client.components.restore(componentId, options?) ### Description Restores a deleted component by its ID. ### Method restore ### Endpoint client.components.restore(componentId, options?) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. ### Request Example ```ts await client.components.restore(123); ``` ### Response #### Success Response Returns the restored component. ``` -------------------------------- ### client.components.restoreVersion(componentId, versionId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Restores a specific version of a component. ```APIDOC ## client.components.restoreVersion(componentId, versionId, options?) ### Description Restores a specific version of a component. ### Method restoreVersion ### Endpoint client.components.restoreVersion(componentId, versionId, options?) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. - **versionId** (number) - Required - The ID of the version. ### Request Example ```ts await client.components.restoreVersion(123, 456); ``` ### Response #### Success Response Returns the restored component. ``` -------------------------------- ### client.sharedAssets Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Manage shared asset libraries, including listing, retrieving, uploading, creating, and deleting assets. ```APIDOC ## client.sharedAssets ### Description Manage shared asset libraries, including listing, retrieving, uploading, creating, and deleting assets. ### Methods - `client.sharedAssets.list(options?)` - `client.sharedAssets.get(assetId, options?)` - `client.sharedAssets.upload(options)` - `client.sharedAssets.create(options)` - `client.sharedAssets.delete(assetId, options?)` ### Parameters - `assetId` (string) - Required - The ID of the shared asset. - `options` (object) - Optional - Additional request options. ### Notes - `sharedAssets.create()` runs the full signed-upload flow. - `sharedAssets.upload()` is the lower-level variant. ``` -------------------------------- ### createManagementApiClient() factory Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Creates a Management API client. Authentication requires either a personal access token or an OAuth bearer token, never both. The client accepts options like personalAccessToken, oauthToken, spaceId, region, baseUrl, headers, throwOnError, retry, timeout, and rateLimit. ```ts createManagementApiClient(config); ``` -------------------------------- ### client.componentFolders.update(componentGroupId, options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Updates an existing component folder by its ID. ```APIDOC ## client.componentFolders.update(componentGroupId, options) ### Description Updates an existing component folder by its ID. ### Method update ### Endpoint client.componentFolders.update(componentGroupId, options) ### Parameters #### Path Parameters - **componentGroupId** (number) - Required - The ID of the component folder. ### Request Example ```ts const { data } = await client.componentFolders.update(123, { body: { componentGroup: { name: "Updated Folder" } } }); ``` ### Response #### Success Response Returns the updated component folder. ``` -------------------------------- ### Escape-hatch HTTP methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Raw HTTP methods for endpoints not covered by resource clients, returning the same ApiResponse wrapper. ```APIDOC ## Escape-hatch HTTP methods ### Description Raw HTTP methods for endpoints not covered by resource clients, returning the same ApiResponse wrapper. ### Methods - `client.get(path, options?)` - `client.post(path, options?)` - `client.put(path, options?)` - `client.patch(path, options?)` - `client.delete(path, options?)` ### Parameters - `path` (string) - Required - The endpoint path. - `options` (object) - Optional - Additional request options. ``` -------------------------------- ### Per-request space override with path: { space_id } Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Every space-scoped method accepts an optional path: { space_id } override that takes precedence over the client-level spaceId. This allows a single client instance to operate against multiple spaces. ```ts await client.stories.list({ path: { space_id: 67890 } }); ``` -------------------------------- ### TypeScript: Typed story content with withTypes() Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Use withTypes() to narrow story.content to the project's component union. Accepts either { components: Block } or { blocks: Block } (the latter matches the Schema type from @storyblok/schema). No runtime cost and no schema values added to the bundle. ```ts import { createManagementApiClient } from "@storyblok/management-api-client"; import type { Schema } from "./schema"; const client = createManagementApiClient({ personalAccessToken: "your-token", spaceId: 12345, }).withTypes(); const { data } = await client.stories.get(42); // data.story.content is now a discriminated union of the schema's blocks. ``` -------------------------------- ### client.interceptors Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Underlying request and response middleware hooks for advanced request customization. ```APIDOC ## client.interceptors ### Description Underlying request and response middleware hooks for advanced request customization. ### Usage Access the `client.interceptors` property to customize requests and responses. ``` -------------------------------- ### client.internalTags Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Resource client for managing internal tags that categorize blocks and assets in the Storyblok UI. ```APIDOC ## client.internalTags ### Description Use the `internalTags` resource client to manage the internal tags that categorize blocks and assets in the Storyblok UI. ### Methods #### client.internalTags.list(options?) - **Description**: Lists internal tags. - **Parameters**: `options` (object, optional) - Query options. #### client.internalTags.create(options) - **Description**: Creates an internal tag. - **Parameters**: `options` (object, required) - Options for creation. #### client.internalTags.update(internalTagId, options) - **Description**: Updates an internal tag. - **Parameters**: `internalTagId` (string/number, required) - The internal tag ID. `options` (object, required) - Options for update. #### client.internalTags.delete(internalTagId, options?) - **Description**: Deletes an internal tag. - **Parameters**: `internalTagId` (string/number, required) - The internal tag ID. `options` (object, optional) - Query options. ``` -------------------------------- ### Escape-hatch HTTP methods: client.get, post, put, patch, delete Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Use these raw HTTP methods as an escape hatch for endpoints the resource clients do not yet cover. They return the same ApiResponse wrapper as the resource clients. The client also exposes client.interceptors, the underlying request and response middleware hooks, for advanced request customization. ```ts client.get(path, options?); client.post(path, options?); client.put(path, options?); client.patch(path, options?); client.delete(path, options?); ``` -------------------------------- ### client.components.update(componentId, options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Updates an existing component by its ID. ```APIDOC ## client.components.update(componentId, options) ### Description Updates an existing component by its ID. ### Method update ### Endpoint client.components.update(componentId, options) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. ### Request Example ```ts const { data } = await client.components.update(123, { body: { component: { name: "Updated Component" } } }); ``` ### Response #### Success Response Returns the updated component. ``` -------------------------------- ### client.stories.publish(storyId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Publishes a story by its numeric ID. ```APIDOC ## client.stories.publish(storyId, options?) ### Description Publishes a story by its numeric ID. ### Method publish ### Endpoint client.stories.publish(storyId, options?) ### Parameters #### Path Parameters - **storyId** (number) - Required - The numeric ID of the story. ### Request Example ```ts await client.stories.publish(12345); ``` ### Response #### Success Response Returns the published story. ``` -------------------------------- ### client.componentFolders.delete(componentGroupId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Deletes a component folder by its ID. ```APIDOC ## client.componentFolders.delete(componentGroupId, options?) ### Description Deletes a component folder by its ID. ### Method delete ### Endpoint client.componentFolders.delete(componentGroupId, options?) ### Parameters #### Path Parameters - **componentGroupId** (number) - Required - The ID of the component folder. ### Request Example ```ts await client.componentFolders.delete(123); ``` ### Response #### Success Response Returns a success indicator. ``` -------------------------------- ### client.sharedInternalTags Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Manage shared internal tags, including listing, creating, updating, and deleting tags. ```APIDOC ## client.sharedInternalTags ### Description Manage shared internal tags, including listing, creating, updating, and deleting tags. ### Methods - `client.sharedInternalTags.list(options)` - `client.sharedInternalTags.create(options)` - `client.sharedInternalTags.update(tagId, options)` - `client.sharedInternalTags.delete(tagId, options)` ### Parameters - `tagId` (string) - Required - The ID of the shared internal tag. - `options` (object) - Required - Additional request options. ``` -------------------------------- ### client.components.delete(componentId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Deletes a component by its ID. ```APIDOC ## client.components.delete(componentId, options?) ### Description Deletes a component by its ID. ### Method delete ### Endpoint client.components.delete(componentId, options?) ### Parameters #### Path Parameters - **componentId** (number) - Required - The ID of the component. ### Request Example ```ts await client.components.delete(123); ``` ### Response #### Success Response Returns a success indicator. ``` -------------------------------- ### Internal Tags Resource Methods Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Lists the methods available on client.internalTags for managing internal tags that categorize blocks and assets in the Storyblok UI. ```ts client.internalTags.list(options?); client.internalTags.create(options); client.internalTags.update(internalTagId, options); client.internalTags.delete(internalTagId, options?); ``` -------------------------------- ### client.stories.duplicate(storyId, options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Duplicates a story by its numeric ID. ```APIDOC ## client.stories.duplicate(storyId, options) ### Description Duplicates a story by its numeric ID. ### Method duplicate ### Endpoint client.stories.duplicate(storyId, options) ### Parameters #### Path Parameters - **storyId** (number) - Required - The numeric ID of the story. ### Request Example ```ts const { data } = await client.stories.duplicate(12345, {}); ``` ### Response #### Success Response Returns the duplicated story. ``` -------------------------------- ### ClientError Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Error type wrapping every non-2xx response, exposing response status, statusText, and parsed data. ```APIDOC ## ClientError ### Description Every non-2xx response is wrapped in a `ClientError`. The error exposes a `response` property containing `status`, `statusText`, and the parsed `data` from the response body. ### Properties - `error.response.status` (number) - HTTP status code. - `error.response.statusText` (string) - HTTP status text. - `error.response.data` (object) - Parsed response body. ### Behavior When `throwOnError` is `true`, `ClientError` instances are thrown instead of returned. ### Constructor ```ts throw new ClientError(message, { status, statusText, data }); ``` ``` -------------------------------- ### client.stories.update(storyId, options) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Updates an existing story by its numeric ID. ```APIDOC ## client.stories.update(storyId, options) ### Description Updates an existing story by its numeric ID. ### Method update ### Endpoint client.stories.update(storyId, options) ### Parameters #### Path Parameters - **storyId** (number) - Required - The numeric ID of the story. #### Request Body - **body.story** (object) - Required - The updated story object. ### Request Example ```ts const { data } = await client.stories.update(12345, { body: { story: { name: "Updated Home", slug: "home", content: { component: "page", title: "Welcome" }, }, }, }); ``` ### Response #### Success Response Returns the updated story. ``` -------------------------------- ### client.stories.delete(storyId, options?) Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Deletes a story by its numeric ID. ```APIDOC ## client.stories.delete(storyId, options?) ### Description Deletes a story by its numeric ID. ### Method delete ### Endpoint client.stories.delete(storyId, options?) ### Parameters #### Path Parameters - **storyId** (number) - Required - The numeric ID of the story. ### Request Example ```ts await client.stories.delete(12345); ``` ### Response #### Success Response Returns a success indicator. ``` -------------------------------- ### Throw ClientError with response details Source: https://www.storyblok.com/docs/libraries/js/management-api-client.md Every non-2xx response is wrapped in a ClientError. The error exposes a response property containing status, statusText, and the parsed data from the response body (error.response.status, error.response.statusText, error.response.data). When throwOnError is true, ClientError instances are thrown instead of returned. ```ts throw new ClientError(message, { status, statusText, data }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.