Skip to content

Websites API

The Websites API lets you manage website models and website domains.

Endpoints Overview

MethodEndpointDescription
GET/POST/api/v1/websitesList websites available to API user
POST/api/v1/websites/storeCreate website (admin only)
GET/POST/api/v1/websites/{id}Get single website
POST/api/v1/websites/update/{id}Update website
POST/api/v1/websites/delete/{id}Delete website (admin only)
POST/api/v1/websites/add-domainAdd domain alias to a website
POST/api/v1/websites/remove-domainRemove domain from website

Authentication

All endpoints require api_token.

Feature Switches

Websites API requires both levels to be enabled:

  • Model level: enable_api_website
  • Endpoint level: matching action key (for example wncms_api_website_update)

List Websites

Endpoint

GET|POST /api/v1/websites

Request Parameters

ParameterTypeRequiredDescription
api_tokenstringYesUser API token
keywordstringNoFilter by domain / site_name
page_sizeintNoPagination size (default 20, max 100)

Create Website

Endpoint

POST /api/v1/websites/store

Request Parameters

ParameterTypeRequiredDescription
api_tokenstringYesAdmin API token
site_namestringYesWebsite name
domainstringYesPrimary domain
themestringNoTheme key
remarkstringNoRemark

Get Single Website

Endpoint

GET|POST /api/v1/websites/{id}

Update Website

Endpoint

POST /api/v1/websites/update/{id}

Request Parameters

ParameterTypeRequiredDescription
api_tokenstringYesUser API token
user_idintegerNoWebsite owner user ID
domainstringNoPrimary domain
site_namestring/objectNoSite name (supports translation map)
site_logostringNoSite logo path/url
site_faviconstringNoSite favicon path/url
site_sloganstring/objectNoSite slogan (supports translation map)
site_seo_keywordsstring/objectNoSEO keywords (supports translation map)
site_seo_descriptionstring/objectNoSEO description (supports translation map)
themestringNoTheme key
homepagestringNoHomepage identifier
remarkstringNoRemark
meta_verificationstringNoMeta verification code
head_codestringNoHTML inserted into <head>
body_codestringNoHTML inserted before </body>
analyticsstringNoAnalytics script/config
licensestringNoLicense value
enabled_page_cachebooleanNoEnable full page cache
enabled_data_cachebooleanNoEnable data cache

Delete Website

Endpoint

POST /api/v1/websites/delete/{id}

Admin only.

Add Domain Alias

Add a domain alias (example: demo001.wndhcms.com) to a website.

Endpoint

POST /api/v1/websites/add-domain

Feature Toggle

This endpoint can be disabled via enable_api_website_add_domain setting.

Request Parameters

ParameterTypeRequiredDescription
api_tokenstringYesUser API token
website_idintegerYesTarget website ID
domainstringYesDomain alias to add

Response Example

json
{
  "code": 200,
  "status": "success",
  "message": "Domain alias created",
  "data": {
    "website_id": 1,
    "domain": "demo001.wndhcms.com",
    "domain_alias_id": 8,
    "already_exists": false,
    "is_primary_domain": false
  },
  "extra": []
}

Remove Domain

Remove a primary domain or alias from a website.

Endpoint

POST /api/v1/websites/remove-domain

Request Parameters

ParameterTypeRequiredDescription
api_tokenstringYesUser API token
website_idintegerYesTarget website ID
domainstringYesDomain to remove

Response Example - Remove Alias

json
{
  "code": 200,
  "status": "success",
  "message": "Successfully Deleted",
  "data": {
    "website_id": 1,
    "removed_domain": "demo001.wndhcms.com",
    "new_primary_domain": "main-domain.com"
  },
  "extra": []
}

Response Example - Cannot Remove Last Domain

json
{
  "code": 422,
  "status": "fail",
  "message": "Cannot remove the last domain of a website",
  "data": [],
  "extra": []
}

Behavior Notes

  • Domain input is normalized to hostname only.
  • Domains already used by another website (primary domain or alias) are rejected.
  • Non-admin users can only add domains to websites they can access.
  • Removing the primary domain is allowed only when another alias can be promoted.
  • The API blocks removing the last remaining domain of a website.
  • Cache tag websites is flushed after website/domain mutations.

API Setting Keys

Website API actions are mapped to System Settings -> API toggles via model $apiRoutes:

  • wncms_api_website_index
  • wncms_api_website_show
  • wncms_api_website_store
  • wncms_api_website_update
  • wncms_api_website_delete
  • wncms_api_website_add_domain
  • wncms_api_website_remove_domain

Built with ❤️ for WNCMS