# App building rules

This page covers, in full, the rules you follow when you prepare the resources and site to include in a *Market App*. It covers what carries over on install and how, how to write values in your build output and resource definitions, which resources you must include together, the values the installer enters, what blocks bundling, and how the plan required to install is decided. If you're new to building an app, start with [Building an app](/getting-started/core-concepts/market-app/app-building.md), which covers what building an app means and the order you do it in.

When you create a version of a *Market App*, the resources you selected in your source *Space* are bundled into that version. This page calls that process "bundling". The rules for creating versions and submitting them for review are in [App publishing and review rules](/manual/market-app/app-publish.md), and the rules on the installing side are in [App install rules](/manual/market-app/app-install.md).

## Rules {#rules}

### Installing creates the included resources fresh in the installer's Space {#installed-as-new-resources}

When someone installs an app, the resources included in the version are created fresh in the installer's *Space*. The installer manages the installed resources ([The installer manages installed copies](/manual/market-app/app-install.md#installed-copies)).

::diagram[Diagram showing how values carry over when an app is installed. It compares three columns, the source Space, the app version, and the installer's Space, across four rows. In the first row, a resource ID (an ID written in site files, a Script, Content, or a Webhook, such as the source Content Type's ID 3trmXRkRjC…58Nv) goes into the app version as the original ID, and in the installer's Space it changes to the new ID of the installed copy. Only resources you include change. In the second row, a token value (a Delivery Access Token written in site files, such as DVRATbQ8mX…Ck3Po) goes into the app version as the original value, and in the installer's Space it changes to a newly issued value. It changes only if you include the token too. In the third row, the Script secret value SMS_API_KEY holds your API key in the source Space, but only its name and description go into the app version, not the value. In the installer's Space, the value is the key the installer entered when installing. In the fourth row, a Webhook URL (such as https://hooks.example.com/new) and the values of regular headers are copied into the app version and the installer's Space as written, so every installed copy sends to the same address. In the legend, purple is a value that changes on install, orange is a value the installer enters, and gray is a value copied as is]{name="app-building-diagram-values"}

- Installed resources get new IDs. Any *Delivery Access Token*s and *Space Access Token*s you included are issued with new values.
- References between resources are reconnected among the installed copies. For example, an installed *Content*'s link *Field* references the installed *Content*, and an installed token is bound to the installed role. What changes for each resource is laid out in [What each resource carries into the installed copy](#what-each-resource-carries).
- For a reference to reconnect, you must also include the resource it points to ([Resources you must include together](#companions)).
- Installed resources are separate from the resources in your source *Space*. Editing or deleting the originals after the install doesn't change the installed copies. For cases where an installed site keeps using values from your source *Space*, see [Values that change in site files](#site-values).

### A version includes what's saved at bundling time {#contents-at-bundling}

- A version includes whatever is saved in your source *Space* at the moment it's bundled. Edits you haven't published are included too.
- Included *Content Type*s and *Content* are created in a published state in the *Space* they're installed in, whatever their status was in the source. The same applies to *Content* that's *Draft* or *Archived* in the source ([What installing creates in your Space](/manual/market-app/app-install.md#what-installation-creates)). Before bundling, clean up drafts in progress and test data that installers shouldn't see.
- Bundling continues for a while after you create the version. Don't edit or delete the included resources until bundling finishes. If you delete an included resource while bundling is in progress, bundling fails for that version ([Version statuses](/manual/market-app/app-publish.md#version-states)).
- Edits to the originals make it into the app only when you create a new version ([One set of app info per app, resources per version](/manual/market-app/app-publish.md#app-and-versions)).

### What each resource carries into the installed copy {#what-each-resource-carries}

Settings such as names, descriptions, rules, run schedules, and on/off states carry over to the installed copy with their original values. The table below lists, for each resource, what changes to the installed copy's values, and what doesn't carry over or is decided by the installer.

| Resource | Changes to the installed copy's values | Doesn't carry over, or the installer decides |
|---|---|---|
| *Content Type* | The *Content Type*s a link *Field* allows | None |
| *Content* | The items a link *Field* references, attached *Tag*s, and resource IDs written in *Field* values ([IDs written in resource definitions](#ids-in-definitions)) | None |
| *Media* | Attached *Tag*s | None |
| *Tag* | None | If the *Space* you install in already has a *Tag* with the same name, that *Tag* is used instead of creating a new one. Only *Tag*s whose names that *Space* doesn't have are created |
| *Locale* | None | The installer decides whether to change the *Space*'s default *Locale* to the app's. For the rules when the *Space* you install in already has a *Locale* with the same code, see [Locales are matched to the app](/manual/market-app/app-install.md#locales) |
| *SpaceRole*, *ServiceUserRole* | The *Content Type*s, *Tag*s, and *Script*s used in their rules | Among *SpaceRole*s, the *Administrator* role isn't created. Places that referenced the *Administrator* role in the source reference the *Administrator* role of the *Space* the app is installed in |
| *Delivery Access Token*, *Space Access Token* | The token value and the bound *SpaceRole*. A token bound to the *Administrator* role in the source is bound to the *Administrator* role of the *Space* the app is installed in | **Allowed referrers** doesn't carry over, so installed tokens are issued with **No restriction**. The installer can set it to the installed site's address ([Allowed referrers decide which sites can use a token](/manual/access-and-permissions/token.md#allowed-referrers)) |
| *Script* | Resource IDs written in **Statement** and **Payload Schema** | The values in **Secrets**. The app holds only the **Key** and **Description** of each secret value, and the installer enters the values ([Values the installer enters](#installer-inputs)) |
| *Webhook* | The *Script* it runs, and resource IDs in **Filters** values and in a shape to send that you wrote yourself | The values of headers whose type is **Secret** and of headers named `Authorization`, and the **Username**<!-- ko: 아이디 / 영어 화면 표기 미확인 --> and **Password**<!-- ko: 비밀번호 / 영어 화면 표기 미확인 --> for **HTTP Basic Auth**. The installer enters all of them ([Values the installer enters](#installer-inputs)) |
| *Scheduler* | The *Script* it runs | None |
| *ServiceLogin* | The default role, and return URLs written as the address of a site you included | The installer enters the client ID and client secret issued by each login provider, and any return URLs written as addresses outside the included site. **Contact email** is set to the installer's account email ([When you include member login](#including-service-login)) |
| *Email Account* | None | Not created. The app holds only the *Email Account*'s name, not the sending server address or the password. The installer selects one *Email Account* in their own *Space*, and installed *Script*s send email through the selected *Email Account* |
| *Web Hosting* | Values written in site files ([Values that change in site files](#site-values)), and the site address written in meta tags ([The site's own address and meta tags](#site-address-and-meta)) | A new Subdomain is set, and your own domain connected to the original site doesn't carry over ([Sites installed from an app](/manual/deployment-and-integration/web-hosting.md#app-installed-sites)) |

### Values that change in site files {#site-values}

An installed site has no server, so the browser calls CDA directly to load content. That means the build output itself has to say which *Space* to read from, what to read, and with which token. The values written in the build output are your source *Space*'s values, but on install, WEEGLOO finds the following values in the site files and replaces them with the values of the *Space* the app is installed in.

- The source *Space*'s ID
- The IDs of the resources you included
- The values of the *Delivery Access Token*s and *Space Access Token*s you included
- The file addresses of the *Media* you included. They change to the file addresses of the installed *Media*.

For these values to change, follow all of these rules.

- **Include the resources and tokens in the app.** If you don't include a resource, token, or *Media*, its ID, value, or file address doesn't change, so the installed site keeps reading your source *Space*.
- **Put the values in text files.** The files whose values change are web pages (`.html`, `.htm`), styles and scripts (`.css`, `.js`, `.mjs`), and data (`.json`, `.map`, `.xml`, `.txt`). Values in image files (including `.svg`) and in files that aren't in the extension table (such as `.webmanifest`) don't change. The extension table is in [Rules for the site file bundle](/manual/deployment-and-integration/web-hosting.md#bundle-rules).
- **Save text files in UTF-8.** Values in files saved in another character encoding don't change.
- **Write each value as one whole string, without splitting it.** The entire value must appear unbroken in the build output.

Example code that writes the values in the site's config file is in [Putting values into the build as they are](/getting-started/core-concepts/market-app/app-building.md#inlining-the-values-as-literals).

Values written in the following ways don't remain as whole strings in the build output, so they don't change.

- **Reading an environment variable.** An installed site has no server to inject the value.

  ```js
  // Doesn't work: this environment variable doesn't exist where the app is installed
  deliveryAccessToken: process.env.DELIVERY_ACCESS_TOKEN
  ```

- **Fetching at runtime.** The value doesn't remain in the build output.
- **Splitting the string.** The value doesn't appear as one piece.

  ```js
  // Doesn't work: the whole token doesn't remain as one string in the output
  deliveryAccessToken: "DVRAT" + "bQ8mX2vK9pLs7Rf1Zt0Nc4Wd6Hg5Ua2Ee9Ck3PoYx8Bj6Hg5Ua2Ee9Ck3Po"
  ```

- **A placeholder or a blank.** There's no real value to replace.

A bundler can split or change strings while it builds, so check the build output, not the source ([Checking the build output before bundling](#checking-the-build-output)).

Don't write the text and images that installers will change in Content Studio directly into site files. Have the site load them from *Content* instead. Installers can't change the files of a site installed from an app ([Sites installed from an app](/manual/deployment-and-integration/web-hosting.md#app-installed-sites)).

### The site's own address and meta tags {#site-address-and-meta}

An installed site opens at a different Subdomain address from the original site ([Sites installed from an app](/manual/deployment-and-integration/web-hosting.md#app-installed-sites)). The original site's address written in site files is handled differently depending on where you wrote it.

| Where the address is written | On install |
|---|---|
| In the tags below in an HTML file's `<head>`, a value written as the original site's Subdomain address | Changes to the installed site's address |
| In the same tags, a value written as your own domain address connected to the original site | Doesn't change |
| An address written in the page body or in scripts | Doesn't change |

The tags whose addresses change are `<link rel="canonical">`, `<meta property="og:url">`, `og:image`, `og:image:url`, `og:image:secure_url`, `<meta name="twitter:image">`, `<link rel="icon">`, `<link rel="shortcut icon">`, `<link rel="apple-touch-icon">`, and `<link rel="alternate">`.

- If you write links within the site as paths without the address, like `/about`, they lead to the same page whatever address the site opens at. If you need the current address at runtime, get it with `location.origin`.
- The following tags in `<head>` aren't included in the app, so the installed site doesn't have them: search engine crawling instructions (`robots`, `googlebot`), language markers (`og:locale`, `og:locale:alternate`), and site ownership verification (`google-site-verification`, `naver-site-verification`).
- After installing, the installer can edit values such as the title, description, Canonical, and image for each document in **Custom Metadata** ([Custom metadata exists only on sites installed from an app](/manual/market-app/app-install.md#custom-metadata)).

### IDs written in resource definitions {#ids-in-definitions}

Resource IDs written as text in a *Script*, *Content*, or *Webhook* also change to the installed copies' IDs on install, as long as you include those resources. The source *Space*'s ID changes to the ID of the *Space* the app is installed in too. Only certain places have IDs that change.

| Resource | Where IDs change | Where IDs don't change |
|---|---|---|
| *Script* | **Statement**, **Payload Schema** | **Secrets**, **Name** |
| *Content* | The values of all *Field*s | None |
| *Webhook* | **Filters** values (except **Regexp** and **Not Regexp** filters), and the shape to send written with **Customize the Webhook payload** | URL, headers |

- Write an ID as a separate value, with no letters or digits attached before or after it. An ID changes if it's alone inside quotes or set apart by symbols such as `/` or `-`. An ID joined to other characters, like `ct3trmXRLdJF4GBlAjtcuoZ7Pnxj8dlA`, doesn't change.
- If you write the ID of a resource in your source *Space* but don't include that resource, bundling is blocked ([Resources you must include together](#companions)).
- A resource ID you put in **Secrets** doesn't change, so the installer has to look up the installed resource's new ID and enter it.
- Only addresses written in site files change to the installed *Media*'s file addresses. When you use *Media* in *Content*, don't write the file address as text. Reference the *Media* with a link *Field*.

### You can't write the ID of a resource installed later {#install-order}

When an app is installed, resources are created in a set order. A resource that references another resource, or has that resource's ID written in it, is created after that other resource. The following order is also fixed.

- *Web Hosting* is created last, after all other resources.
- *Webhook*s are created after all other resources except *Web Hosting*.
- A *Scheduler* is created after the *Script* it runs.

So if a resource's definition contains the ID of a resource that's created after it, no order works, and bundling fails. That happens in these cases.

- A *Script* or *Content* contains the ID of a *Web Hosting* or a *Webhook*
- A *Script* contains the ID of a *Scheduler*
- A *Webhook* contains the ID of a *Web Hosting*

This problem isn't caught the moment you create the version. It's found later, during bundling, and bundling fails for that version ([Version statuses](/manual/market-app/app-publish.md#version-states)). Remove that ID from the definition and create a new version. For a *Script*, you can change it to receive that ID in `payload` when it runs. For the steps to clean up the failed version, see [Clean up a failed version](/manual/market-app/app-publish.md#clean-up-a-failed-version).

<!-- 서버 수정 대기(2026-11-06, 출시본 1.24.3 065a2788a 에서도 그대로): 지금 서버는 처리에 실패한(FAILED) 버전의 삭제를 거부한다(deleteAppBundle 은 COMPLETED 만). 그래서 실패한 버전을 지우고 새 버전을 만드는 흐름이 막힐 수 있다. app-publish #clean-up-a-failed-version 의 주석과 같은 건, 서버 버그인지 사용자 확인 대기 -->

### Values the installer enters {#installer-inputs}

Put values that differ for each installer, like a payment service's secret key or an external API key, in the places the installer fills in. Values you put there aren't included in the app, and installers enter their own values when installing. Values written directly as text in a definition don't change on install, so a key of yours written that way is copied as is into every installed copy.

| Place | What the app holds | What the installer does |
|---|---|---|
| **Secrets** in a *Script* | The **Key** and **Description** of each secret value | Enters a value for each secret value |
| Headers whose type is **Secret** in a *Webhook* | The header name | Enters the value |
| Headers named `Authorization` in a *Webhook* | The header name | Enters the value, whatever the type. The name isn't case-sensitive |
| **HTTP Basic Auth** in a *Webhook* | The setting that says basic authentication is used | Enters the **Username**<!-- ko: 아이디 / 영어 화면 표기 미확인 --> and **Password**<!-- ko: 비밀번호 / 영어 화면 표기 미확인 --> |
| Login providers in *ServiceLogin* | The list of providers that are turned on | Enters the client ID and client secret issued by each provider |
| Return URLs in *ServiceLogin* written as addresses outside the included site | Nothing | Enters the address ([When you include member login](#including-service-login)) |
| *Email Account* | The *Email Account*'s name | Selects one *Email Account* in their own *Space* |

- A header whose type is **Custom** has its value copied as is, unless its name is `Authorization`.
- The fields the installer fills in are fixed at bundling. You can't add or remove fields after you create the version, so before bundling, set up every value you need from installers as a secret value or as a header whose type is **Secret**.
- You set the name, guidance, and default value shown for each input field when you submit for review ([Input guidance shown to installers](/manual/market-app/app-publish.md#installer-input-settings)).
- For how to put values in a *Script*'s **Secrets**, see [Secret values are stored separately in the definition and called by name](/manual/deployment-and-integration/script.md#secrets). For *Webhook* header types, see [Headers and basic authentication](/manual/deployment-and-integration/webhook.md#headers-and-basic-auth).

For example, in a *Script* that saves notification sign-ups and sends a confirmation text through an external SMS service, you write the ID of the *Content Type* that stores sign-ups as is in **Statement**, and you put the SMS service's API key in **Secrets** as the secret value `SMS_API_KEY`. The example definition is in [Letting the installer enter values for external services](/getting-started/core-concepts/market-app/app-building.md#keep-other-keys-in-secrets).

When this *Script* is included in an app and installed, the two values are handled as follows.

| | Source *Space* | App | Installer's *Space* |
|---|---|---|---|
| Value of `SMS_API_KEY` | Your API key (your source *Space* runs on this value) | Not included. Only the name and description go in | The key the installer entered |
| ID of the "Notification Sign-up" *Content Type* | Original ID | Original ID | ID of the installed *Content Type* |

A *Webhook*'s URL isn't a place the installer fills in, so the address you wrote carries over as is into every installed copy. If the destination address differs for each installer, as in an app that notifies the installer's work messenger every time a new inquiry comes in, have the *Webhook* run a *Script*, and put the address that *Script* calls in a secret value ([When it runs a Script instead of a URL](/manual/deployment-and-integration/webhook.md#script-target)).

### Binding tokens to least-privilege roles {#least-privilege-tokens}

- If you put a *Delivery Access Token* in the build output, anyone who opens the original site can find its value in the site files. Likewise, anyone who opens an installed site can find the installed token's value.
- An installed token is bound to the copy of the role the original token was bound to. If you include a token bound to the *Administrator* role, the installed token is bound to the *Administrator* role of the *Space* it's installed in ([What each resource carries into the installed copy](#what-each-resource-carries)), and if the token value leaks, the installer's entire *Space* is at risk.
- So bind a token you put in a site to a role that can read only the *Content Type*s the site actually needs to read. The same goes when you put a *Space Access Token* in a site. For the rules on choosing a role to bind, see [Roles you can bind](/manual/access-and-permissions/token.md#roles-you-can-bind).

### When you include member login {#including-service-login}

If your app supports its own member sign-up and login, it uses *ServiceLogin* and the [official client SDK](https://www.npmjs.com/package/weegloo-service-user), and the browser calls ACDA with the member's token. The settings are covered in [ServiceLogin settings and rules](/manual/service-users/service-login.md), and how to connect login to your site is covered in [Auth API](/api/reference/auth-api.md). When you include *ServiceLogin* in an app, the following rules apply.

- You must also include the member role used as *ServiceLogin*'s default role ([Resources you must include together](#companions)).
- The login providers' client IDs and client secrets, and **Contact email**, aren't included in the app. For how these values are set on install, see [Values you enter when installing](/manual/market-app/app-install.md#installer-inputs).
- Among the addresses written in **Default Return URL**<!-- ko: 기본 이동 URL / 영어 화면 표기 미확인 --> and **Allowed Return URLs**<!-- ko: 허용할 이동 URL / 영어 화면 표기 미확인 -->, the Subdomain address of a site you included, or your own domain address connected to that site, changes to the installed site's address. The installer enters any other address (such as an app's address).
- If an address you used during development (such as `localhost`) is left in a return URL, the installer has to enter an address to take its place. Remove it in the *ServiceLogin* settings before bundling.
- Signed-up members (*ServiceUser*) aren't included in the app. You can't include resources that reference a member's ID ([Resources and conditions an app can't include](#what-cannot-be-included)).
- An app that includes *ServiceLogin* can be installed only in a *Space* that has no *ServiceLogin* ([Each Space has one ServiceLogin](/manual/service-users/service-login.md#one-per-space)).

### Resources you must include together {#companions}

You must also include every resource that an included resource references. If even one is missing, bundling is blocked.

| Included resource | Resources you must include with it |
|---|---|
| *Content* | Its *Content Type*, the *Content* and *Media* its link *Field*s reference, attached *Tag*s, and resources whose IDs are written in *Field* values |
| *Content Type* | Other *Content Type*s its link *Field*s allow |
| *Media* | Attached *Tag*s |
| *Delivery Access Token*, *Space Access Token* | The *SpaceRole* bound to the token |
| *SpaceRole*, *ServiceUserRole* | Resources used in their rules (*Content Type*, *Tag*, *Script*, and so on) |
| *ServiceLogin*, *ServiceUserRole* | The *ServiceUserRole* used as *ServiceLogin*'s default role. If your source *Space* has *ServiceLogin*, you must include the default role even if you include only one *ServiceUserRole* |
| *Locale* | The *Locale* set as its **Fallback Locale**, and every *Locale* further along that **Fallback Locale** chain |
| *Scheduler* | The *Script* it runs |
| *Webhook* | The *Script* it runs, and resources whose IDs are written in **Filters** values or in a shape to send that you wrote yourself |
| *Script* | Resources its definition references (for example, the *Email Account* it sends email with), and resources whose IDs are written in **Statement** or **Payload Schema** |

For when an ID written as text means you must also include its resource, see [IDs written in resource definitions](#ids-in-definitions).

When you select the resources to include in Content Studio, the following two are selected along with them, and you can't deselect them.

- When your source *Space* has *ServiceLogin*, selecting **Include ServiceLogin settings**<!-- ko: ServiceLogin 설정 포함 / 영어 화면 표기 미확인 --> or selecting even one *ServiceUserRole* also selects the *ServiceUserRole* used as *ServiceLogin*'s default role.
- Selecting a *Locale* also selects its **Fallback Locale** and every *Locale* further along that chain.

You must select the rest of the resources in the table yourself. WEEGLOO doesn't add a resource that's missing from the request to create a version. It blocks bundling instead. So when you create a version from a program, you must include the two above yourself too.

<!-- 캡쳐 필요: Market App 생성의 포함할 리소스에서 ServiceLogin 설정 포함을 선택한 뒤 ServiceUserRole 선택 창을 연 모습. 기본 역할 행이 선택되어 잠겨 있고, "ServiceLogin 설정을 포함해 기본 Role이 함께 담기고, 선택을 해제할 수 없습니다." 안내가 보이게 / 사전 준비: 원본 Space HnQ32YiH에 ServiceLogin(서비스 이름 "알림 신청 페이지", 기본 Role "알림 신청 회원")이 켜져 있고, 회원 역할 "알림 신청 회원"과 "알림 신청 운영자"가 있는 상태. Market App은 생성하지 않음 -->

### Resources and conditions an app can't include {#what-cannot-be-included}

If any resource falls under the following, bundling is blocked.

**Resources that name a specific person.** Service members and *Space* members don't carry over to another *Space*, so an app can't include resources that name a specific person.

- A *Script*, *Content*, or *Webhook* that references a service member's (*ServiceUser*'s) ID or contains it as text. Remove that ID. For a *Script*, you can change it to receive the member ID in `payload` when it runs.
- A role (*SpaceRole*, *ServiceUserRole*) with a condition that selects a specific user in the creator field. Remove that condition or change it to **The requesting user** ([Narrowing by creator](/manual/access-and-permissions/role-and-permissions.md#narrow-by-author)).
- A *Script* whose `where` in `ResourceFind`, `ResourceForEach`, or `ResourceCount` sets the creator (`createdBy`) to a specific user's ID. Remove that condition or change it to `":self"`. You can also change it to receive the ID of the person to look up in `payload` when it runs.
- A *Webhook* whose **Filters** use the creator (**User ID, created by**) or the last editor (**User ID, updated by**) as a criterion. It's blocked whatever the value, so remove that filter.

**Circular references.** On install, referenced resources are created first, so you can't include a resource whose references lead back to itself.

- A *Content Type* that leads back to itself when you follow the *Content Type*s its link *Field*s allow. This includes a link *Field* that allows its own *Content Type*.
- *Content* that reference one another through link *Field*s so that following them leads back to the start
- A *Locale* that leads back to itself when you follow its **Fallback Locale**, or a *Locale* whose **Fallback Locale** is a *Locale* not included in the app

**Resources still processing, or whose deployment failed.** You can't include *Media* whose file hasn't finished processing. You can include a *Web Hosting* only when its deployment has finished processing and its **State** is **Serving**.

- If a *Web Hosting* is still processing a deployment (*PENDING* or *PROCESSING*), create the version again after processing finishes.
- You also can't include a *Web Hosting* whose deployment failed and whose **State** is *FAILED*. This applies even when a redeployment failed and the previous site is still open. Fix the bundle and upload it again, then create the version once the deployment finishes ([If a deployment fails](/manual/deployment-and-integration/web-hosting.md#when-deployment-fails)).

**Resources created by installing another app.** An app can include only resources you created yourself. You can't include such resources even if you edited them after installing, or after the installation record was deleted. If you're the one who made the original app, create a new version in the *Space* where you made it.

### Checking the build output before bundling {#checking-the-build-output}

Search the build output with `grep` for the source *Space* ID, the token value, and the resource IDs one by one, and check that each one turns up as a single unbroken string.

```sh
grep -r "DVRATbQ8mX2vK9pLs7Rf1Zt0Nc4Wd6Hg5Ua2Ee9Ck3PoYx8Bj6Hg5Ua2Ee9Ck3Po" dist/
grep -r "HnQ32YiH" dist/
grep -r "3trmXRkRjC1x4J9h2om4QZv0jC58Nv" dist/
```

- A value that doesn't turn up won't change on install. Fix it using [Values that change in site files](#site-values).
- Also check that the files it turns up in are text files whose values change (`.html`, `.css`, `.js`, `.json`, and so on, saved in UTF-8).

## Limits {#limits}

### Minimum plan required to install {#required-plan}

Each version has a minimum plan required to install the app. WEEGLOO compares the counts from the app against each plan's limits and sets the minimum plan to the lowest plan whose limits fit them all. If the app doesn't fit within any plan's limits, the highest plan becomes the minimum plan.

| What's counted in the app | Plan limit it's compared against |
|---|---|
| The number included of each resource type (*Content Type*, *Content*, *Media*, *Tag*, *Locale*, *SpaceRole*, *ServiceUserRole*, *Delivery Access Token*, *Space Access Token*, *Script*, *Scheduler*, *Webhook*, *Web Hosting*) | The count limit for the same type |
| The number of *Statement*s in whichever included *Script* has the most *Statement*s | Max statements per Script |
| The number of external service calls (`Http`) and email sends (`EmailSend`) in whichever included *Script* has the most of those *Statement*s | Max external calls per Script |

- The minimum plan assumes that only this app is installed in an empty *Organization*. It doesn't reflect how much the target *Organization* already uses, the size of *Media* and site files, or the *Locale*s and *Tag*s that already exist in the target *Space*. Whether the app can actually be installed depends on the target *Organization*'s usage ([What's checked before you can install](/manual/market-app/app-install.md#installability-checks)).
- The *Administrator* role, *ServiceLogin*, and *Email Account*s aren't counted. The plan needed for the sending server an *Email Account* uses isn't reflected either ([Which sending servers you can use](/manual/deployment-and-integration/email.md#which-servers-you-can-use)).
- The limit values for each plan are in [Pricing](/pricing/pricing.md#plan-comparison). For how *Statement*s are counted, see the limits section of [Script settings and rules](/manual/deployment-and-integration/script.md#limits).

Size your app with the plans your installers mostly use in mind. If a single *Script* with many *Statement*s is pushing the minimum plan up, splitting that *Script* can bring the minimum plan down.

## Required permissions {#permissions}

The permissions needed to create a *Market App* and its versions are covered in [Organization settings and rules](/manual/access-and-permissions/organization.md#permissions).

For the following types of resources, you can see their list only if you have the matching settings permission in your source *Space*. Without it, you can't include resources of that type in an app. If an included resource references such a resource, you can't include the referenced resource with it, so bundling is blocked. <!-- TODO: 화면 흐름 확인: 설정 권한이 없는 종류가 Market App 생성과 새 버전 생성의 리소스 선택에서 어떻게 표시되는지 -->

| Resource to include | Settings permission needed in the source *Space* |
|---|---|
| *Delivery Access Token* | **Manage Delivery Access Tokens** |
| *Space Access Token* | **Manage Space Access Tokens** |
| *Email Account* | **Manage Email Accounts** |
| *Webhook* | **Manage Webhooks** |
| *Scheduler* | **Manage Schedulers** |
| *ServiceLogin*, *ServiceUserRole* | **Manage ServiceLogin** |
| *Web Hosting* | **Manage Web Hostings** |

For how to turn on settings permissions, see [Settings permissions on the Settings tab](/manual/access-and-permissions/role-and-permissions.md#permission-tab).

<!-- 캡쳐 필요: Market App 생성의 포함할 리소스 부분에서, 설정 권한이 없는 종류(Webhook)가 선택할 수 없는 행으로 표시되고 나머지 종류는 선택할 수 있는 모습 / 사전 준비: Organization의 Admin이고, 원본 Space에서 App 관리는 있지만 Webhook 관리는 없는 역할을 받은 계정. 원본 Space에 Webhook "새 문의 알림"과 Content Type "알림 신청"이 있는 상태 -->

## Tasks in Content Studio {#tasks}

The tasks you do in Content Studio while preparing an app are laid out on each resource's page.

- [Issue a Delivery Access Token](/manual/access-and-permissions/token.md#issue-a-delivery-access-token): Steps for issuing the token that goes in your site, bound to a narrow role.
- [Create a Script](/manual/deployment-and-integration/script.md#create-a-script): Steps for creating a *Script* that keeps the values installers enter in **Secrets**.
- [Edit a Script](/manual/deployment-and-integration/script.md#edit-a-script): Steps to follow when you move a key written as text in **Statement** to **Secrets**.
- [Send the translation program's key in a Secret header](/manual/deployment-and-integration/webhook.md#add-a-secret-header): Steps for setting a *Webhook* header as a header whose type is **Secret**.
- [Create a Webhook that runs a Script](/manual/deployment-and-integration/webhook.md#create-a-script-webhook): Steps for making a *Webhook* run a *Script* when you want the installer to set the destination address.
- [Create a Market App](/manual/market-app/app-publish.md#create-a-market-app): Steps for creating a *Market App* and its first version by selecting the resources to include.
- [Create a new version](/manual/market-app/app-publish.md#create-a-new-version): Steps for selecting the resources to include again after you edit the originals, and creating a new version.
- [Test-install a version](/manual/market-app/app-publish.md#test-install-a-version): Steps for installing a version you created in a test *Space* and checking that the installed copy works as intended. The rules are in [A test install lets you check ahead](/manual/market-app/app-publish.md#test-install).

## Troubleshooting {#troubleshooting}

Problems you hit when creating a version are at the top of the table, and problems that show up after installing are further down. You can catch the after-install problems with a test install before you submit for review ([A test install lets you check ahead](/manual/market-app/app-publish.md#test-install)).

| Problem | Cause | What to do |
|---|---|---|
| You can't create a version because a required resource is missing | You didn't include a resource that an included resource references. This also covers IDs of source *Space* resources written as text in a *Script*, *Content*, or *Webhook* | Include the referenced resources too ([Resources you must include together](#companions)) |
| You can't select a resource you need to include | You don't have the settings permission to see that type in your source *Space* | Ask a member with **Manage Roles** for that settings permission ([Required permissions](#permissions)) |
| You can't create a version because a resource was deleted | A resource was deleted from your source *Space* after you selected it | Select the resources to include again |
| You can't create a version because a resource hasn't finished processing | An included *Media* file or *Web Hosting* deployment hasn't finished processing, or a *Web Hosting* deployment failed | Create the version again after processing finishes. For a *Web Hosting* whose deployment failed, fix the bundle and deploy it again ([Resources and conditions an app can't include](#what-cannot-be-included)) |
| You can't create a version because a resource names a specific user | Something references a service member's ID, a condition sets the creator to a specific user, or a *Webhook*'s **Filters** use the creator or the last editor as a criterion | Remove or change that condition ([Resources and conditions an app can't include](#what-cannot-be-included)) |
| You can't create a version because of a problem with references between resources | References among *Content Type*s or *Content* go in a circle, a *Locale*'s **Fallback Locale** goes in a circle, or a *Locale* you didn't include is set as a **Fallback Locale** | Break the circular reference, or include the *Locale* used as the **Fallback Locale** too ([Resources and conditions an app can't include](#what-cannot-be-included)) |
| You can't create a version because a resource was created by installing another app | An app can include only resources you created yourself | Leave that resource out and build the app from resources you created yourself |
| You created a version, but bundling fails | A definition contains the ID of a resource installed after it, or an included resource was deleted during bundling | Remove that ID and create a new version ([You can't write the ID of a resource installed later](#install-order)) |
| The installed site reads content from your source *Space* | You didn't include a resource or token the site reads, a value didn't remain as a whole string in the build output, or you wrote a value in a file whose values don't change | Check [Values that change in site files](#site-values) and create a new version |
| Images on the installed site load from your source *Space*'s files | The *Media* whose addresses are written in the site isn't included in the app | Include that *Media* and create a new version |
| An installed *Script* calls an external service with your key | You wrote the key as text in **Statement** | Move the key to **Secrets** and create a new version ([Values the installer enters](#installer-inputs)) |
| An installed *Webhook* sends requests to your server | A *Webhook*'s URL and headers whose type is **Custom** are copied as written | To let the installer set the destination address, have the *Webhook* run a *Script* ([Values the installer enters](#installer-inputs)) |
| You can't add installer input fields to a version you already created | Input fields are fixed at bundling | Add a secret value or a header whose type is **Secret** to the original, then create a new version |
| The installed site's addresses for search and sharing still point to the original site | You wrote that address as your own domain connected to the original site, or you wrote it in the page body or a script instead of a meta tag | Write it as the Subdomain address, or as a path without the address. The installer can edit it in **Custom Metadata** ([The site's own address and meta tags](#site-address-and-meta)) |
| Installers get a field asking them to enter a return URL for member login | An address outside the included site (such as a development address) is left in a return URL | Remove the address you don't use in the *ServiceLogin* settings and create a new version ([When you include member login](#including-service-login)) |
| Drafts in progress are published in the *Space* the app was installed in | Whatever was saved at bundling is created in a published state | Clean up the originals, then create a new version ([A version includes what's saved at bundling time](#contents-at-bundling)) |
| The required minimum plan is higher than you expected | The number of resources, or the single *Script* with the most *Statement*s or external calls, goes over a lower plan's limits | Include fewer resources or split the large *Script* ([Minimum plan required to install](#required-plan)) |

## Related docs {#related}

- [Building an app](/getting-started/core-concepts/market-app/app-building.md): Covers what building an app means and the order you build one in.
- [App publishing and review rules](/manual/market-app/app-publish.md): Covers the rules for creating versions, checking them with a test install, and submitting them for review.
- [App install rules](/manual/market-app/app-install.md): Covers the conditions under which installers can install an app, and the rules after installing.
- [Web Hosting settings and rules](/manual/deployment-and-integration/web-hosting.md): Covers the rules for site file bundles and sites installed from an app.
- [API reference](/api/reference/cda.md): Covers the technical specifications, such as the request format your site sends when it reads content.
