Implementation:Langgenius Dify UpdateAppSiteStatus
| Knowledge Sources | Domains | Last Updated |
|---|---|---|
| Dify | LLM_Applications, Frontend, API | 2026-02-12 00:00 GMT |
Overview
Description
updateAppSiteStatus is the frontend service function for toggling the web application (site) publishing status of a Dify application. It sends a POST request to a dynamically constructed URL (typically apps/{appId}/site-enable) with a body that contains the enable_site boolean flag. When enabled, the application becomes accessible to end users through its public web URL.
Three companion functions in the same service module provide additional publishing controls:
updateAppApiStatus(lines 115-117) -- Toggles the API endpoint publishing status by posting toapps/{appId}/api-enablewith anenable_apiflag. This controls whether external systems can interact with the application via REST API.updateAppRateLimit(lines 120-122) -- Configures request throttling by posting toapps/{appId}/rate-limitwith rate limit parameters (api_rpmfor requests per minute,api_rphfor requests per hour).updateAppSiteAccessToken(lines 124-126) -- Regenerates the site access token by posting to the token refresh endpoint. This invalidates the previous public URL and issues a new one, returning the updatedSiteConfig.
All four functions follow the same pattern: they accept a URL and body (or just a URL) and return a promise resolving to the updated application detail or site configuration.
Usage
Call updateAppSiteStatus to enable or disable the web application frontend for end users. Combine with updateAppApiStatus to independently control API access. Use updateAppRateLimit to protect the application from abuse, and updateAppSiteAccessToken to rotate access credentials.
Code Reference
Source Location
web/service/apps.ts, lines 111-113
Signature
export const updateAppSiteStatus = (
{ url, body }: { url: string, body: Record<string, any> }
): Promise<AppDetailResponse> => {
return post<AppDetailResponse>(url, { body })
}
Related: updateAppApiStatus (lines 115-117):
export const updateAppApiStatus = (
{ url, body }: { url: string, body: Record<string, any> }
): Promise<AppDetailResponse> => {
return post<AppDetailResponse>(url, { body })
}
Related: updateAppRateLimit (lines 120-122):
export const updateAppRateLimit = (
{ url, body }: { url: string, body: Record<string, any> }
): Promise<AppDetailResponse> => {
return post<AppDetailResponse>(url, { body })
}
Related: updateAppSiteAccessToken (lines 124-126):
export const updateAppSiteAccessToken = (
{ url }: { url: string }
): Promise<UpdateAppSiteCodeResponse> => {
return post<UpdateAppSiteCodeResponse>(url)
}
Import
import {
updateAppSiteStatus,
updateAppApiStatus,
updateAppRateLimit,
updateAppSiteAccessToken,
} from '@/service/apps'
I/O Contract
Inputs (updateAppSiteStatus)
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string |
Yes | The API endpoint URL, typically apps/{appId}/site-enable.
|
| body | Record<string, any> |
Yes | The request body, containing enable_site: boolean to toggle web app publishing.
|
Inputs (updateAppApiStatus)
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string |
Yes | The API endpoint URL, typically apps/{appId}/api-enable.
|
| body | Record<string, any> |
Yes | The request body, containing enable_api: boolean to toggle API access.
|
Inputs (updateAppRateLimit)
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string |
Yes | The API endpoint URL, typically apps/{appId}/rate-limit.
|
| body | Record<string, any> |
Yes | The request body, containing api_rpm: number (requests per minute) and api_rph: number (requests per hour).
|
Inputs (updateAppSiteAccessToken)
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string |
Yes | The API endpoint URL for regenerating the access token. |
Outputs (updateAppSiteStatus, updateAppApiStatus, updateAppRateLimit)
| Field | Type | Description |
|---|---|---|
| (return) | Promise<AppDetailResponse> |
Resolves to the full App entity with the updated enable_site, enable_api, api_rpm, and api_rph fields reflecting the new publishing state.
|
Outputs (updateAppSiteAccessToken)
| Field | Type | Description |
|---|---|---|
| (return) | Promise<UpdateAppSiteCodeResponse> |
Resolves to { app_id: string } & SiteConfig, containing the new access_token along with the full site configuration.
|
Usage Examples
Enabling the web application for public access
import { updateAppSiteStatus } from '@/service/apps'
const updatedApp = await updateAppSiteStatus({
url: `apps/${appId}/site-enable`,
body: { enable_site: true },
})
console.log(updatedApp.enable_site) // true
console.log(updatedApp.site.access_token) // the public URL token
Enabling API access alongside the web app
import { updateAppSiteStatus, updateAppApiStatus } from '@/service/apps'
// Enable web app
await updateAppSiteStatus({
url: `apps/${appId}/site-enable`,
body: { enable_site: true },
})
// Enable API access
await updateAppApiStatus({
url: `apps/${appId}/api-enable`,
body: { enable_api: true },
})
Setting rate limits for API protection
import { updateAppRateLimit } from '@/service/apps'
await updateAppRateLimit({
url: `apps/${appId}/rate-limit`,
body: {
api_rpm: 120, // 120 requests per minute
api_rph: 5000, // 5000 requests per hour
},
})
Regenerating the site access token
import { updateAppSiteAccessToken } from '@/service/apps'
const newSiteConfig = await updateAppSiteAccessToken({
url: `apps/${appId}/generate-new-token`,
})
console.log(newSiteConfig.access_token) // new access token for the public URL