> 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

# SetNamespace

# Package: apps

# Namespace: AppsService

# Method link: https://dev.wix.com/docs/api-reference/wix-backoffice/dev-center-platform/apps/app-service/set-namespace.md

## Introduction

Sets the app namespace using the owning account's slug or company name and the supplied `appName`.
Falls back to the account slug when no company name is available. A namespace can be set only once.
For non-Wix apps, `appName` must not contain `wix` (case-insensitive).
The exact names `google`, `facebook`, and `amazon` require privileged authorization (case-insensitive).
Unlike namespace suggestions, this method does not automatically add a suffix when the derived namespace is already used.
Suggestions are not reservations; on a collision, choose a different `appName` and retry.

---

## REST API

### Schema

```
 Method: setNamespace
 Description: Sets the app namespace using the owning account's slug or company name and the supplied `appName`. Falls back to the account slug when no company name is available. A namespace can be set only once. For non-Wix apps, `appName` must not contain `wix` (case-insensitive). The exact names `google`, `facebook`, and `amazon` require privileged authorization (case-insensitive). Unlike namespace suggestions, this method does not automatically add a suffix when the derived namespace is already used. Suggestions are not reservations; on a collision, choose a different `appName` and retry.
 URL: https://www.wixapis.com/apps/v1/apps/{appId}/set-namespace
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  appName
 Method parameters: 
   param name: appName | type: appName | description: Name used to derive the app's namespace component. Lowercased; runs of non-alphanumeric characters (including spaces and underscores) become hyphens, with leading/trailing separators removed. For example, `Bookings Helper` and `Bookings_Helper` become `bookings-helper`. If no letters or digits remain, uses `untitled`. Subject to the reserved-name restrictions documented on Set Namespace. For permitted Wix-owned apps, `wix` is removed before normalization. | required: true | validation: maxLength 50
   param name: type | type: NamespaceType    
      - enum:
           ACCOUNT - Uses the account slug.
           COMPANY - Uses the company name, falling back to the account slug when unavailable.
 Return type: SetNamespaceResponse
  - name: namespace | type: string | description: Assigned namespace in the format `@account-or-company/app-name`.  


```

### Examples

### Assign an app namespace
Set a namespace once, using the company context and a normalized app name. An existing namespace or a collision causes the request to fail. The request was validated against the test account. The response is representative and contains fictional data.

```curl
curl -X PATCH \
'https://www.wixapis.com/apps/v1/apps/da630f88-1b48-473e-a6a1-d71960c413fb/set-namespace' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "appName": "Bookings Helper",
  "type": "COMPANY"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.appManagement.apps.setNamespace(appId, appName, options)
 Description: Sets the app namespace using the owning account's slug or company name and the supplied `appName`. Falls back to the account slug when no company name is available. A namespace can be set only once. For non-Wix apps, `appName` must not contain `wix` (case-insensitive). The exact names `google`, `facebook`, and `amazon` require privileged authorization (case-insensitive). Unlike namespace suggestions, this method does not automatically add a suffix when the derived namespace is already used. Suggestions are not reservations; on a collision, choose a different `appName` and retry.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  appId, appName
 Method parameters: 
   param name: appId | type: string | description: App GUID. | required: true | validation: format GUID
   param name: appName | type: string | description: Name used to derive the app's namespace component. Lowercased; runs of non-alphanumeric characters (including spaces and underscores) become hyphens, with leading/trailing separators removed. For example, `Bookings Helper` and `Bookings_Helper` become `bookings-helper`. If no letters or digits remain, uses `untitled`. Subject to the reserved-name restrictions documented on Set Namespace. For permitted Wix-owned apps, `wix` is removed before normalization. | required: true | validation: maxLength 50
   param name: options | type: SetNamespaceOptions  none  
        - name: type | type: NamespaceType | description: Whether to derive the namespace from the owning account or company. Default: `ACCOUNT`.  
             - enum:
             -     ACCOUNT: Uses the account slug.
             -     COMPANY: Uses the company name, falling back to the account slug when unavailable.
 Return type: PROMISE<SetNamespaceResponse>
  - name: namespace | type: string | description: Assigned namespace in the format `@account-or-company/app-name`.  


```

### Examples

### Set an app namespace
```javascript
import { apps } from "@wix/app-management";

async function setNamespace() {
  const response = await apps.setNamespace(
    "da630f88-1b48-473e-a6a1-d71960c413fb",
    "Bookings Helper",
    { type: "COMPANY" },
  );
  return response;
}

/* Promise resolves to (representative, fictional values):
 * { "namespace": "@example-company/bookings-helper" }
 */

```

### setNamespace (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 { apps } from '@wix/app-management';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function setNamespace(appId,appName,options) {
  const response = await myWixClient.apps.setNamespace(appId,appName,options);
};
```

---