> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GenerateSiteMediaToken

# Package: richContent

# Namespace: RicosDocument

# Method link: https://dev.wix.com/docs/api-reference/assets/rich-content/ricos-documents/generate-site-media-token.md

## Permission Scopes:
Manage Ricos Document: SCOPE.DC-RICOS.MANAGE-DOCUMENTS

## Introduction

Generates a site media token that lets a Ricos editor open Wix media tools, such as Image Studio, for the current Wix user.

Pass the token as `siteToken` when you open Image Studio from the Ricos image plugin. The token identifies
the site and the Wix user, and is valid only in a browser where that user is logged in to Wix.
It expires after 14 days, so you can reuse it for the editor session.

Only Wix users can call this method. Calls by site members, site visitors, or anonymous callers
fail with a permission error. Wix app calls without a Wix user fail with a `WIX_USER_REQUIRED` error.

---

## REST API

### Schema

```
 Method: generateSiteMediaToken
 Description: Generates a site media token that lets a Ricos editor open Wix media tools, such as Image Studio, for the current Wix user.  Pass the token as `siteToken` when you open Image Studio from the Ricos image plugin. The token identifies the site and the Wix user, and is valid only in a browser where that user is logged in to Wix. It expires after 14 days, so you can reuse it for the editor session.  Only Wix users can call this method. Calls by site members, site visitors, or anonymous callers fail with a permission error. Wix app calls without a Wix user fail with a `WIX_USER_REQUIRED` error.
 URL: https://www.wixapis.com/ricos/v1/ricos-document/generate-site-media-token
 Method: POST
 Return type: GenerateSiteMediaTokenResponse
  - name: token | type: string | description: Site media token to pass to the Wix media tool. Expires after 14 days. Treat the token as a secret. Don't log it or share it.  | validation: maxLength 5000

 Possible Errors:
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: WIX_USER_REQUIRED | Description: The caller isn't a Wix user.


```

### Examples

### Generate a site media token
```curl
curl -X POST \
'https://www.wixapis.com/ricos/v1/ricos-document/generate-site-media-token' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.richContent.ricosDocuments.generateSiteMediaToken()
 Description: Generates a site media token that lets a Ricos editor open Wix media tools, such as Image Studio, for the current Wix user.  Pass the token as `siteToken` when you open Image Studio from the Ricos image plugin. The token identifies the site and the Wix user, and is valid only in a browser where that user is logged in to Wix. It expires after 14 days, so you can reuse it for the editor session.  Only Wix users can call this method. Calls by site members, site visitors, or anonymous callers fail with a permission error. Wix app calls without a Wix user fail with a `WIX_USER_REQUIRED` error.
 Return type: PROMISE<GenerateSiteMediaTokenResponse>
  - name: token | type: string | description: Site media token to pass to the Wix media tool. Expires after 14 days. Treat the token as a secret. Don't log it or share it.  | validation: maxLength 5000

 Possible Errors:
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: WIX_USER_REQUIRED | Description: The caller isn't a Wix user.


```

### Examples

### Generate a site media token
```javascript
import { ricosDocuments } from "@wix/rich-content";

async function generateSiteMediaToken() {
  const response = await ricosDocuments.generateSiteMediaToken();
}

/* Promise resolves to:
 * {
 *   "token": "JWS.<SITE_MEDIA_TOKEN>"
 * }
 */

```

### generateSiteMediaToken (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { ricosDocuments } from '@wix/rich-content';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { ricosDocuments },
  // Include the auth strategy and host as relevant
});


async function generateSiteMediaToken() {
  const response = await myWixClient.ricosDocuments.generateSiteMediaToken();
};
```

---