picked 0.0.101-next.2 → 0.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +27 -12
  2. package/docs/explanation/conditions-and-the-logic-engine.md +94 -0
  3. package/docs/explanation/content-references.md +99 -0
  4. package/docs/explanation/feature-flag-allocation.md +218 -0
  5. package/docs/explanation/how-picked-works.md +124 -0
  6. package/docs/explanation/how-pickedql-works.md +76 -0
  7. package/docs/explanation/pages-and-flows.md +64 -0
  8. package/docs/explanation/the-content-model.md +87 -0
  9. package/docs/explanation/the-two-apis.md +68 -0
  10. package/docs/explanation/why-server-side-rendering.md +76 -0
  11. package/docs/explanation/workspaces-and-versions.md +71 -0
  12. package/docs/how-to/add-a-step-field-or-action.md +56 -0
  13. package/docs/how-to/analytics/index.md +324 -0
  14. package/docs/how-to/archive-or-delete-a-workspace.md +59 -0
  15. package/docs/how-to/authenticate-the-cli.md +101 -0
  16. package/docs/how-to/authenticate-with-a-magic-link.md +56 -0
  17. package/docs/how-to/authenticate-with-a-password.md +68 -0
  18. package/docs/how-to/authenticate-with-an-api-key.md +60 -0
  19. package/docs/how-to/authenticate-with-oauth.md +49 -0
  20. package/docs/how-to/build-a-flow.md +106 -0
  21. package/docs/how-to/call-an-external-api-from-a-workflow.md +116 -0
  22. package/docs/how-to/connect-the-mcp-server.md +46 -0
  23. package/docs/how-to/create-a-content-entry.md +58 -0
  24. package/docs/how-to/create-a-project.md +40 -0
  25. package/docs/how-to/create-an-experience.md +51 -0
  26. package/docs/how-to/create-and-revoke-an-api-key.md +54 -0
  27. package/docs/how-to/debug-with-the-chrome-extension.md +57 -0
  28. package/docs/how-to/define-a-page-layout.md +54 -0
  29. package/docs/how-to/fill-and-publish-a-page.md +82 -0
  30. package/docs/how-to/install-the-gtm-template.md +84 -0
  31. package/docs/how-to/install-the-sdk.md +93 -0
  32. package/docs/how-to/install-the-vite-plugin.md +69 -0
  33. package/docs/how-to/invite-and-remove-members.md +45 -0
  34. package/docs/how-to/point-one-entry-at-another.md +75 -0
  35. package/docs/how-to/preview-a-workspace.md +39 -0
  36. package/docs/how-to/publish-a-workspace.md +42 -0
  37. package/docs/how-to/read-a-feature-flag.md +113 -0
  38. package/docs/how-to/read-a-referenced-entry.md +109 -0
  39. package/docs/how-to/register-a-component.md +55 -0
  40. package/docs/how-to/register-an-action-handler.md +85 -0
  41. package/docs/how-to/register-an-api-that-uses-oauth2.md +107 -0
  42. package/docs/how-to/render-a-step-form.md +131 -0
  43. package/docs/how-to/render-an-unpublished-preview.md +41 -0
  44. package/docs/how-to/retry-a-failed-call-with-a-loop.md +81 -0
  45. package/docs/how-to/reuse-a-section.md +64 -0
  46. package/docs/how-to/reuse-a-step-field-or-action.md +39 -0
  47. package/docs/how-to/roll-back-a-published-version.md +39 -0
  48. package/docs/how-to/run-an-ab-test.md +59 -0
  49. package/docs/how-to/run-code-on-a-form-submission.md +125 -0
  50. package/docs/how-to/server-render-a-page.md +81 -0
  51. package/docs/how-to/set-a-content-security-policy.md +32 -0
  52. package/docs/how-to/set-up-mfa.md +126 -0
  53. package/docs/how-to/switch-workspaces.md +122 -0
  54. package/docs/how-to/upload-and-use-an-asset.mdx +87 -0
  55. package/docs/how-to/validate-a-field.md +52 -0
  56. package/docs/how-to/wait-for-an-action-response.md +182 -0
  57. package/docs/how-to/write-a-condition.md +57 -0
  58. package/docs/how-to/write-a-predicate.md +60 -0
  59. package/docs/index.md +59 -0
  60. package/docs/reference/dashboard/actions.mdx +65 -0
  61. package/docs/reference/dashboard/api-keys.mdx +47 -0
  62. package/docs/reference/dashboard/conditions.mdx +51 -0
  63. package/docs/reference/dashboard/content/asset-library.mdx +74 -0
  64. package/docs/reference/dashboard/content/blocks.mdx +66 -0
  65. package/docs/reference/dashboard/content/content-entries.mdx +109 -0
  66. package/docs/reference/dashboard/content/models.mdx +119 -0
  67. package/docs/reference/dashboard/content/pages.mdx +72 -0
  68. package/docs/reference/dashboard/experiences.mdx +61 -0
  69. package/docs/reference/dashboard/external-apis.md +182 -0
  70. package/docs/reference/dashboard/features.mdx +165 -0
  71. package/docs/reference/dashboard/fields.mdx +120 -0
  72. package/docs/reference/dashboard/flow-builder/canvas.mdx +58 -0
  73. package/docs/reference/dashboard/flow-builder/condition-builder.md +69 -0
  74. package/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +72 -0
  75. package/docs/reference/dashboard/flow-builder/nodes.md +74 -0
  76. package/docs/reference/dashboard/labels.md +321 -0
  77. package/docs/reference/dashboard/lead-search.md +235 -0
  78. package/docs/reference/dashboard/projects.mdx +53 -0
  79. package/docs/reference/dashboard/reports.mdx +53 -0
  80. package/docs/reference/dashboard/steps.mdx +47 -0
  81. package/docs/reference/dashboard/team-management.md +38 -0
  82. package/docs/reference/dashboard/workflow-runs.md +157 -0
  83. package/docs/reference/dashboard/workflow-templates.md +182 -0
  84. package/docs/reference/dashboard/workflow-test-runs.md +85 -0
  85. package/docs/reference/dashboard/workspace-versioning.mdx +42 -0
  86. package/docs/reference/dashboard/workspaces.mdx +91 -0
  87. package/docs/reference/delivery-api/experience-content.md +152 -0
  88. package/docs/reference/delivery-api/index.md +45 -0
  89. package/docs/reference/delivery-api/preview-caching-crawling.md +79 -0
  90. package/docs/reference/delivery-api/project-config.md +65 -0
  91. package/docs/reference/delivery-api/workspace-schema.md +107 -0
  92. package/docs/reference/glossary.md +201 -0
  93. package/docs/reference/management-api/authentication.md +87 -0
  94. package/docs/reference/management-api/authorization-and-scopes.md +291 -0
  95. package/docs/reference/management-api/error-handling.md +232 -0
  96. package/docs/reference/management-api/pagination.md +192 -0
  97. package/docs/reference/management-api/schema/action.md +261 -0
  98. package/docs/reference/management-api/schema/analytics-session.md +363 -0
  99. package/docs/reference/management-api/schema/analytics.md +73 -0
  100. package/docs/reference/management-api/schema/api-key.md +170 -0
  101. package/docs/reference/management-api/schema/auth.md +1177 -0
  102. package/docs/reference/management-api/schema/cms-fields.md +954 -0
  103. package/docs/reference/management-api/schema/cms-models.md +1155 -0
  104. package/docs/reference/management-api/schema/common.md +362 -0
  105. package/docs/reference/management-api/schema/condition.md +254 -0
  106. package/docs/reference/management-api/schema/design-system.md +199 -0
  107. package/docs/reference/management-api/schema/experience.md +1098 -0
  108. package/docs/reference/management-api/schema/external-api.md +637 -0
  109. package/docs/reference/management-api/schema/feature.md +350 -0
  110. package/docs/reference/management-api/schema/feedback.md +103 -0
  111. package/docs/reference/management-api/schema/field.md +400 -0
  112. package/docs/reference/management-api/schema/index.md +243 -0
  113. package/docs/reference/management-api/schema/integration.md +272 -0
  114. package/docs/reference/management-api/schema/label.md +349 -0
  115. package/docs/reference/management-api/schema/lead.md +340 -0
  116. package/docs/reference/management-api/schema/mcp-server.md +299 -0
  117. package/docs/reference/management-api/schema/metric.md +223 -0
  118. package/docs/reference/management-api/schema/operation.md +96 -0
  119. package/docs/reference/management-api/schema/organization.md +749 -0
  120. package/docs/reference/management-api/schema/project.md +607 -0
  121. package/docs/reference/management-api/schema/report.md +243 -0
  122. package/docs/reference/management-api/schema/saved-view.md +288 -0
  123. package/docs/reference/management-api/schema/shopify.md +795 -0
  124. package/docs/reference/management-api/schema/step.md +273 -0
  125. package/docs/reference/management-api/schema/tenant-branding.md +185 -0
  126. package/docs/reference/management-api/schema/workbench.md +246 -0
  127. package/docs/reference/management-api/schema/workflow-run.md +263 -0
  128. package/docs/reference/management-api/schema/workflow.md +1110 -0
  129. package/docs/reference/management-api/schema/workspace-version.md +823 -0
  130. package/docs/reference/management-api/schema/workspace.md +917 -0
  131. package/docs/reference/pickedql/data-sources.md +174 -0
  132. package/docs/reference/pickedql/dimensions.md +103 -0
  133. package/docs/reference/pickedql/filtering.md +64 -0
  134. package/docs/reference/pickedql/index.md +18 -0
  135. package/docs/reference/pickedql/schema.md +172 -0
  136. package/docs/reference/pickedql/virtual-functions.md +248 -0
  137. package/docs/reference/sdk/actions.md +154 -0
  138. package/docs/reference/sdk/analytics-events.md +453 -0
  139. package/docs/reference/sdk/conditions.md +147 -0
  140. package/docs/reference/sdk/content-security-policy.md +21 -0
  141. package/docs/reference/sdk/content.md +253 -0
  142. package/docs/reference/sdk/experiences.md +51 -0
  143. package/docs/reference/sdk/features.md +256 -0
  144. package/docs/reference/sdk/fields.md +255 -0
  145. package/docs/reference/sdk/index.md +68 -0
  146. package/docs/reference/sdk/plugins/create-experience.md +123 -0
  147. package/docs/reference/sdk/plugins/dynamic-experiences.md +74 -0
  148. package/docs/reference/sdk/plugins/fingerprintjs.md +39 -0
  149. package/docs/reference/sdk/plugins/hotjar.md +60 -0
  150. package/docs/reference/sdk/plugins/index.md +33 -0
  151. package/docs/reference/sdk/plugins/sentry.md +51 -0
  152. package/docs/reference/sdk/plugins/shopify.md +109 -0
  153. package/docs/reference/sdk/plugins/window-object.md +25 -0
  154. package/docs/reference/sdk/predicates.md +43 -0
  155. package/docs/reference/sdk/react.md +61 -0
  156. package/docs/reference/sdk/ssr/index.md +33 -0
  157. package/docs/reference/sdk/ssr/rendering-and-hydration.md +103 -0
  158. package/docs/reference/sdk/ssr/serialize.md +80 -0
  159. package/docs/reference/sdk/ssr/slots-and-placements.md +113 -0
  160. package/docs/reference/sdk/steps.md +86 -0
  161. package/docs/reference/sdk/svelte.md +74 -0
  162. package/docs/reference/sdk/type-generation.md +265 -0
  163. package/docs/reference/tools/admin-api-client.md +89 -0
  164. package/docs/reference/tools/chrome-extension.md +16 -0
  165. package/docs/reference/tools/cli.md +319 -0
  166. package/docs/reference/tools/delivery-api-client.md +60 -0
  167. package/docs/reference/tools/image-optimisation-service.md +104 -0
  168. package/docs/reference/tools/mcp-run.md +121 -0
  169. package/docs/reference/tools/mcp.md +391 -0
  170. package/docs/reference/tools/vite-plugin.md +163 -0
  171. package/docs/tutorials/first-api-call.md +253 -0
  172. package/docs/tutorials/first-experience-in-the-dashboard.mdx +160 -0
  173. package/docs/tutorials/first-experience.mdx +254 -0
  174. package/docs/tutorials/first-server-rendered-page.mdx +186 -0
  175. package/package.json +8 -7
@@ -0,0 +1,319 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # CLI
7
+
8
+ `picked` is the command-line tool for local Picked development. It generates TypeScript
9
+ types from your workspace schema and lets you switch which project or workspace your local
10
+ tooling loads — without hand-editing `picked.config.ts`. It also copies the content of a
11
+ workspace from one project to a different project.
12
+
13
+ ## Installation
14
+
15
+ The [`picked`](/reference/sdk) package holds this command, the client, and the
16
+ `picked.config` helpers:
17
+
18
+ ```bash
19
+ npm install picked
20
+ ```
21
+
22
+ The command reads `picked.config.ts` from the current directory, so run it from your
23
+ project root. See [How to authenticate the CLI](/how-to/authenticate-the-cli) to sign in.
24
+
25
+ `@picked/cli` holds the command on its own, for a project that wants no other part of the
26
+ package.
27
+
28
+ ## Commands
29
+
30
+ | Command | Description |
31
+ | --- | --- |
32
+ | `picked login` | Sign in with your browser (OAuth) to the API origin of the current directory. Stores a session under `~/.picked/auth/`. |
33
+ | `picked logout` | Clear the stored session for the current directory's API origin. |
34
+ | `picked whoami` | Print the identity signed in to the API origin of the current directory. |
35
+ | `picked status` | Print the resolved selection and the committed `picked.config` default. |
36
+ | `picked workspace list` | List each org, project, and workspace that you can read. Alias `ls`. `--json` gives machine output. |
37
+ | `picked workspace use` | Set the active project or workspace. Alias `picked use`. Interactive, or `--project` and `--workspace`. |
38
+ | `picked workspace export` | Write a workspace, or the published version of a project, to a bundle directory. |
39
+ | `picked workspace import` | Create a new draft workspace in a project from a bundle directory. `--publish` also publishes it. |
40
+ | `picked generate types` | Read the workspace schema and write `picked-env.d.ts`. `--check` verifies and writes nothing. |
41
+ | `picked docs list` | List the documentation pages. Words after `list` filter the list. `--type` and `--json` are available. |
42
+ | `picked docs read` | Print one documentation page as Markdown. |
43
+
44
+ ### `picked generate types`
45
+
46
+ Writes the typed schema declaration. See [Type generation](/reference/sdk/type-generation)
47
+ for the `picked.config.ts` reference and the generated output.
48
+
49
+ ```bash
50
+ picked generate types
51
+ ```
52
+
53
+ In CI, `--check` writes nothing and fails when the committed types are stale:
54
+
55
+ ```bash
56
+ picked generate types --check
57
+ # → "Types are up to date (`…/src/picked-env.d.ts`)." (status 0)
58
+ # → "Types are out of date: `…/src/picked-env.d.ts`" (status 1)
59
+ ```
60
+
61
+ ### `picked docs list` and `picked docs read`
62
+
63
+ These commands print this documentation. They read the copy in the `picked` package, at
64
+ `node_modules/picked/docs`. When that copy is not there, they read the index of
65
+ `docs.picked.app`.
66
+
67
+ ```bash
68
+ picked docs list
69
+ picked docs list feature flag
70
+ picked docs list --type how-to --json
71
+ picked docs read /how-to/install-the-sdk
72
+ ```
73
+
74
+ `picked docs list` prints one page on each line: the path, a tab, and the title.
75
+
76
+ | Option | Description |
77
+ | --- | --- |
78
+ | `--type <type>` | Keeps one content type: `tutorial`, `how-to`, `reference` or `explanation`. |
79
+ | `--json` | Gives the path, title, type, description and file of each page. |
80
+
81
+ `picked docs read` accepts a page path, a `docs.picked.app` URL, or a file path below
82
+ `node_modules/picked/docs`. The command `picked docs <path>` does the same thing. The first
83
+ line of the output is a comment with the URL of the page. If no page has that path, the
84
+ command names the closest pages and returns status 1.
85
+
86
+ ### `picked workspace list`
87
+
88
+ ```bash
89
+ picked workspace list
90
+ ```
91
+
92
+ ```
93
+ Acme Corp. (acme-corporation)
94
+ Storefront [proj_a1b2]
95
+ Default Storefront [LIVE] (live)
96
+ Checkout rework [DRAFT]
97
+ ```
98
+
99
+ `--json` gives a machine-readable tree. Each prompt and heading goes to `stderr`, so the
100
+ `stdout` of `--json` stays clean when you send it to another command.
101
+
102
+ ### `picked workspace use`
103
+
104
+ Sets the active selection, then regenerates types. See
105
+ [How to switch workspaces](/how-to/switch-workspaces) for the full set of steps.
106
+
107
+ ```bash
108
+ picked workspace use # interactive picker
109
+ picked workspace use --project proj_a1b2 # the project's published (live) version
110
+ picked workspace use --project proj_a1b2 --workspace ws_id # preview a specific workspace via its token
111
+ ```
112
+
113
+ ```
114
+ Active workspace: Checkout rework [DRAFT] in project proj_a1b2 (source: preview)
115
+ Generated types at /app/src/picked-env.d.ts
116
+ ```
117
+
118
+ `--no-generate` sets the selection and leaves the types as they are.
119
+
120
+ :::warning
121
+ `picked workspace use` regenerates types by default. Types that no longer match the
122
+ workspace give no error, and a developer can fail to see the problem for a long time. Use
123
+ `--no-generate` only when you regenerate the types yourself.
124
+ :::
125
+
126
+ ### `picked workspace export`
127
+
128
+ Writes one workspace of a project to a bundle directory. The bundle holds every part of the
129
+ workspace: features, steps, fields, actions, conditions, experiences, workflows, page
130
+ layouts, sections, and content entries. It also holds a copy of each asset that the content
131
+ entries use.
132
+
133
+ ```bash
134
+ picked workspace export --project proj_a1b2 --live --out ./bundle
135
+ picked workspace export --project proj_a1b2 --workspace ws_id --out ./bundle
136
+ ```
137
+
138
+ ```
139
+ Exported workspace "Snapshot of Default Storefront" with 12 assets to /app/bundle
140
+ ```
141
+
142
+ | Flag | Description |
143
+ | --- | --- |
144
+ | `--project <id>` | The project that holds the workspace. Required. |
145
+ | `--live` | Write the version that the project serves now. The bundle does not include draft changes that you made after you published that version. |
146
+ | `--workspace <id>` | Write this workspace, with its draft changes. The command stops with status 1 when you use `--live` and `--workspace` together. |
147
+ | `--out <dir>` | The bundle directory. It must be in the current directory, and be empty or not exist. Required. |
148
+
149
+ The command stops with status 1 when:
150
+
151
+ - `--live` is used and the project has no published version.
152
+ - The workspace is not in `--project`.
153
+ - The API rejects the request. The message shows the error code and one line for each
154
+ problem.
155
+ - The size of a downloaded asset, or its `sha256` hash, is different from the value in the
156
+ bundle manifest.
157
+
158
+ The error code `UNRESOLVED_REFERENCE` shows that a part of the workspace refers to a part that
159
+ the workspace does not have. For example, a content entry uses a deleted section, a flow
160
+ goes to a deleted experience, or a workflow starts from a deleted action. Each line names the
161
+ part, its key or name if it has one, the location of the reference in the part, and the
162
+ missing id:
163
+
164
+ ```
165
+ Export of workspace ws_id failed:
166
+ UNRESOLVED_REFERENCE: Cannot export experience 'exp_1' (key 'home'): flow node references experience 'exp_gone', which does not belong to the workspace, at flow_json.nodes.1.targetExperienceId (workspaceId)
167
+ ```
168
+
169
+ Remove or change each reference, then run the command again.
170
+
171
+ The credential needs the `organization_workspace/read` scope on the project. With `--live`,
172
+ it also needs the `organization_projects/read` scope.
173
+
174
+ #### Bundle directory
175
+
176
+ | Path | Contents |
177
+ | --- | --- |
178
+ | `bundle.json` | The workspace. `formatVersion` is `1`. `assets` lists each asset version with its `fileName`, `mimeType`, `sizeBytes`, and `sha256` hash. |
179
+ | `assets/<sha256>` | The bytes of one asset. The file name is the `sha256` hash of the bytes, in lowercase. |
180
+
181
+ The command writes the bundle into a temporary directory next to `--out`, and writes
182
+ `bundle.json` last. When the bundle is complete, the command moves it to `--out`. When the
183
+ command fails, it removes the temporary directory, and you can run the same command again.
184
+
185
+ Each request body and response body of the Picked API can be at most 4.5 MB. For a very
186
+ large workspace, `picked workspace export` and `picked workspace import` fail when its
187
+ `bundle.json` is larger than this limit. Asset files do not count, because the command
188
+ downloads and uploads them directly.
189
+
190
+ ### `picked workspace import`
191
+
192
+ Creates a new draft workspace in a project from a bundle directory, then prints the id of
193
+ the new workspace. The command does not change the other workspaces of the project. It
194
+ changes the published version only when you use `--publish`.
195
+
196
+ ```bash
197
+ picked workspace import --project proj_c3d4 --in ./bundle --name "Copy of storefront" --publish
198
+ ```
199
+
200
+ ```
201
+ Imported workspace "Copy of storefront" as ws_new into project proj_c3d4 (assets: 12 uploaded, 0 already in the project).
202
+ Published workspace ws_new.
203
+ ```
204
+
205
+ | Flag | Description |
206
+ | --- | --- |
207
+ | `--project <id>` | The project to import into. It can be in a different organization or a different API deployment. Required. |
208
+ | `--in <dir>` | The bundle directory that `picked workspace export` wrote. It must be in the current directory. Required. |
209
+ | `--name <name>` | The name of the new workspace. The default is the workspace name in the bundle. |
210
+ | `--publish` | Publish the new workspace after the command creates it. |
211
+
212
+ The command sends the `sha256` hash of each asset to the API before it uploads the asset.
213
+ When the project already has an asset with the same bytes, the new workspace uses that
214
+ asset. The command does not upload the bytes again. When you import the same bundle into
215
+ the same project two times, the second command uploads no assets. Each command creates a
216
+ new workspace.
217
+
218
+ Every part of the workspace gets a new id in the target project. The key of an experience
219
+ does not change. The nodes of a workflow keep their ids, and a workflow that starts from an
220
+ action starts from the new copy of that action.
221
+
222
+ The API calculates the scopes of each workflow from the tools that the workflow uses. For
223
+ each tool scope that a workflow does not get by default, the credential must have that
224
+ scope. If it does not, the API rejects the bundle with the error code
225
+ `WORKFLOW_SCOPES_NOT_HELD`, and the message names the workflow, the tool and the scope.
226
+
227
+ The command stops with status 1 when:
228
+
229
+ - An asset file does not exist, or its size or `sha256` hash is different from the bundle
230
+ manifest. The command makes no API request in this case.
231
+ - An asset upload fails.
232
+ - The API rejects the bundle. The message shows the error code, for example
233
+ `UNSUPPORTED_FORMAT_VERSION`, `UNRESOLVED_REFERENCE` or `WORKFLOW_SCOPES_NOT_HELD`.
234
+ - The API rejects the import request with a GraphQL error, for example because the
235
+ credential does not have the necessary scopes.
236
+ - The import request fails on the API with a different GraphQL error, for example
237
+ `INFRASTRUCTURE_ERROR`.
238
+ - The import request gets no GraphQL answer from the API, for example because of a network
239
+ failure, a timeout or an HTTP error. The import request has a longer timeout than the
240
+ other requests.
241
+ - `--publish` is used and the API does not publish the workspace. The message shows the id
242
+ of the new draft workspace.
243
+
244
+ When the API rejects the import request, the GraphQL error code is `FORBIDDEN`,
245
+ `UNAUTHENTICATED`, `BAD_USER_INPUT` or `GRAPHQL_VALIDATION_FAILED`. When an asset upload
246
+ fails or the API rejects the bundle or the import request, the API does not create a
247
+ workspace. The command deletes the assets that it uploaded, and the message names them.
248
+ Assets that were already in the project stay.
249
+
250
+ When the import request fails with a different GraphQL error or gets no GraphQL answer,
251
+ the new workspace can exist in the project. The command keeps the assets that it uploaded,
252
+ and the message names them. When the project has no new workspace, no workspace uses these
253
+ assets.
254
+
255
+ The credential needs the `organization_projects/read`, `organization_projects/update` and
256
+ `organization_workspace/update` scopes on the project. For a bundle with workflows, it also
257
+ needs the scopes of their tools, as described above.
258
+
259
+ ## Authentication
260
+
261
+ `picked login` signs in through the browser. It uses an authorization-code flow with PKCE
262
+ against the Picked OAuth server. `picked whoami` prints the identity for the current origin.
263
+ `picked logout` clears it.
264
+
265
+ The CLI holds one auth config file for each API origin, outside each repository. Every
266
+ command reads and writes only the origin that the current directory resolves to, and never
267
+ a session for another API.
268
+
269
+ | File | Contents |
270
+ | --- | --- |
271
+ | `~/.picked/auth/<origin>.json` | The OAuth session for one API origin — access token, refresh token, expiry — with the CLI's registered client id for that origin. File mode `600`. Refreshed as it nears expiry. |
272
+
273
+ An API deployment with no OAuth client registration rejects `picked login`, and has no
274
+ other flow.
275
+
276
+ A CLI session is a developer credential. It is not
277
+ [dashboard sign-in](/reference/management-api/authentication).
278
+
279
+ ### API key
280
+
281
+ When `PICKED_API_KEY` is set, each command that calls the API sends the key in the
282
+ `X-API-Key` header. The CLI does not read the stored session. An
283
+ [API key](/reference/dashboard/api-keys) lets a run that has no browser, for example a CI
284
+ job, call the API. An API key for one project can read and write only that project.
285
+
286
+ An API key does not identify a user. When `PICKED_API_KEY` is set, `picked login`,
287
+ `picked whoami`, and `picked workspace list` stop with status 1.
288
+
289
+ ## Environment variables
290
+
291
+ | Variable | Effect |
292
+ | --- | --- |
293
+ | `PICKED_API_URL` | The API origin that the CLI reads. Supersedes `picked.config` `apiUrl` and the `https://api.picked.app` default. |
294
+ | `PICKED_API_KEY` | An API key. When set, the CLI sends it as `X-API-Key` in place of the stored session. |
295
+ | `PICKED_PROJECT_ID` | Supersedes the resolved project id, above the active selection and the committed configuration. |
296
+ | `PICKED_PREVIEW_TOKEN` | Supersedes the preview token. Applies only when the resolved source is `preview`. |
297
+
298
+ ### How the selection resolves
299
+
300
+ Tooling — `picked generate types` and the
301
+ [Vite plugin](/reference/tools/vite-plugin) — resolves the configuration in this order. Each
302
+ layer supersedes the layer before it:
303
+
304
+ 1. **`picked.config.ts`** — the committed default: `projectId`, `source`, and
305
+ `previewToken`.
306
+ 2. **`.picked/settings.json`** — the per-developer active selection that
307
+ `picked workspace use` writes. It supersedes `projectId` and `source`, and Git ignores it.
308
+ 3. **Environment variables** — `PICKED_PROJECT_ID` and `PICKED_PREVIEW_TOKEN` supersede
309
+ both, for a CI or headless run.
310
+
311
+ `picked status` prints the resolved result.
312
+
313
+ ## Related
314
+
315
+ - [How to authenticate the CLI](/how-to/authenticate-the-cli) — install and sign in.
316
+ - [How to switch workspaces](/how-to/switch-workspaces) — the draft-preview workflow.
317
+ - [Type generation](/reference/sdk/type-generation) — `picked.config.ts` and the generated types.
318
+ - [Vite plugin](/reference/tools/vite-plugin) — reads the same selection in development and in a build.
319
+ - [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling) — how a preview token behaves.
@@ -0,0 +1,60 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # Delivery API client
7
+
8
+ `@picked/delivery-api-client` gives typed functions for the
9
+ [Delivery API](/reference/delivery-api). The Picked SDK uses it, and you can use it on a
10
+ server or in a script.
11
+
12
+ ```ts
13
+ import { fetchExperienceContent, fetchProject, fetchSchema } from '@picked/delivery-api-client'
14
+
15
+ const config = await fetchProject('https://api.picked.app', 'your-project-id')
16
+ const content = await fetchExperienceContent(
17
+ 'https://api.picked.app',
18
+ 'your-project-id',
19
+ 'your-experience-id',
20
+ )
21
+ const schema = await fetchSchema('https://api.picked.app', 'your-project-id')
22
+ ```
23
+
24
+ ## Functions
25
+
26
+ | Function | Endpoint | Returns |
27
+ | --- | --- | --- |
28
+ | `fetchProject(apiUrl, projectId, options?)` | [Project config](/reference/delivery-api/project-config) | `Promise<ProjectConfig \| null>` |
29
+ | `fetchExperienceContent(apiUrl, projectId, experienceId, options?)` | [Experience content](/reference/delivery-api/experience-content) | `Promise<ExperienceContentResponse \| null>` |
30
+ | `fetchSchema(apiUrl, projectId, options?)` | [Workspace schema](/reference/delivery-api/workspace-schema) | `Promise<WorkspaceSchema \| null>` |
31
+ | `runAction(apiUrl, payload, options?)` | `POST /api/v1/action/<key>/run` | `Promise<RunActionResult>` |
32
+ | `createClientHeaders(name, version)` | none | The `Picked-Client` and `Picked-Version` headers. |
33
+
34
+ `apiUrl` is the origin of the API, for example `https://api.picked.app`.
35
+
36
+ ## Options
37
+
38
+ | Option | Type | Description |
39
+ | --- | --- | --- |
40
+ | `previewToken` | `string` | Reads the draft of a workspace. See [Preview](/how-to/preview-a-workspace). |
41
+ | `headers` | `Record<string, string>` | More request headers. |
42
+ | `signal` | `AbortSignal` | Stops the request. |
43
+ | `onWarn` | `(message: string, error?: unknown) => void` | Receives each failure of a fetch function. |
44
+ | `onResponse` | `(status: number) => void` | Receives the HTTP status of `fetchProject` and `fetchExperienceContent`. |
45
+
46
+ `runAction` takes only `previewToken`, `headers` and `signal`.
47
+
48
+ ## Errors
49
+
50
+ Each request stops after 10 seconds.
51
+
52
+ | Function | On failure |
53
+ | --- | --- |
54
+ | `fetchProject`, `fetchExperienceContent`, `fetchSchema` | Returns `null` and calls `onWarn`. A failure is a network error, a status that is not `ok`, a body that is not JSON, or a body with the wrong shape. |
55
+ | `runAction` | Throws an `Error` for a status that is not `ok`. |
56
+
57
+ ## Related
58
+
59
+ - [Delivery API](/reference/delivery-api)
60
+ - [About the two APIs](/explanation/the-two-apis)
@@ -0,0 +1,104 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # Image optimisation service
7
+
8
+ The Picked service for image optimisation is a hosted endpoint at
9
+ `https://img.picked-content.com`. It reads an image from an allowed source domain and
10
+ resizes it. It then encodes the image again to a modern format, WebP or AVIF, and
11
+ caches the result.
12
+
13
+ ## Endpoint
14
+
15
+ ```
16
+ GET https://img.picked-content.com/_next/image?url={source}&w={width}&q={quality}
17
+ ```
18
+
19
+ | Parameter | Description |
20
+ |-----------|-------------|
21
+ | `url` | The URL of the source image, URL-encoded. It must point at an allowed source domain. See below. |
22
+ | `w` | The width in pixels. It must be one of the supported widths. |
23
+ | `q` | The quality: `25`, `50`, `75`, or `100`. |
24
+
25
+ The service chooses the response format. When the browser advertises `image/avif` or
26
+ `image/webp` in its `Accept` header, the response uses that format. If it does not,
27
+ the response uses the source format.
28
+
29
+ ## Allowed source domains
30
+
31
+ The service reads only from these hostnames:
32
+
33
+ - `**.picked.app`
34
+
35
+ A request with a `url` parameter for any other hostname returns `400 Bad Request`.
36
+
37
+ ## Supported widths
38
+
39
+ Device sizes, for a responsive image that spans the width of the viewport:
40
+
41
+ ```
42
+ 640, 750, 828, 1080, 1200, 1920, 2048, 3840
43
+ ```
44
+
45
+ Image sizes, for a UI element of fixed size such as an icon, an avatar, or a
46
+ thumbnail:
47
+
48
+ ```
49
+ 16, 32, 48, 64, 96, 128, 256, 384
50
+ ```
51
+
52
+ A request with any other width returns `400 Bad Request`. Choose the smallest width
53
+ that covers the size you render at the device pixel ratio of the visitor.
54
+
55
+ ## Supported qualities
56
+
57
+ ```
58
+ 25, 50, 75, 100
59
+ ```
60
+
61
+ A lower value reduces the bandwidth by a large amount. `75` is a good default for
62
+ most images. Use `25` or `50` for a thumbnail on a slow network.
63
+
64
+ ## Responsive images
65
+
66
+ Use the endpoint together with the standard `srcset` attribute. The browser then
67
+ picks the correct width for each viewport:
68
+
69
+ ```html
70
+ <img
71
+ src="https://img.picked-content.com/_next/image?url=https%3A%2F%2Fcdn.picked.app%2Fhero.png&w=1080&q=75"
72
+ srcset="
73
+ https://img.picked-content.com/_next/image?url=https%3A%2F%2Fcdn.picked.app%2Fhero.png&w=640&q=75 640w,
74
+ https://img.picked-content.com/_next/image?url=https%3A%2F%2Fcdn.picked.app%2Fhero.png&w=1080&q=75 1080w,
75
+ https://img.picked-content.com/_next/image?url=https%3A%2F%2Fcdn.picked.app%2Fhero.png&w=1920&q=75 1920w
76
+ "
77
+ sizes="(max-width: 768px) 100vw, 720px"
78
+ alt="..."
79
+ />
80
+ ```
81
+
82
+ ## Cache
83
+
84
+ The upstream CDN caches each optimised response. The smallest cache TTL is 60
85
+ seconds. The real lifetime depends on the eviction policy of the CDN. When you change
86
+ the source image at the same URL, the optimised copy stays in the cache for at least
87
+ that time.
88
+
89
+ ## Security
90
+
91
+ - The service does not optimise an SVG source. A request for an SVG returns the
92
+ original bytes when the source is allowed. The service never runs an embedded
93
+ script.
94
+ - Each optimised response carries a strict `Content-Security-Policy`
95
+ (`default-src *; script-src 'none'; sandbox;`). A compromised source therefore
96
+ cannot run a script in the browser that shows the image.
97
+ - The response uses `Content-Disposition: inline`, and never `attachment`.
98
+
99
+ ## Related
100
+
101
+ - [Asset library](/reference/dashboard/content/asset-library) — where the images come
102
+ from.
103
+ - [Content Security Policy](/reference/sdk/content-security-policy) — the `img-src`
104
+ entry this service needs.
@@ -0,0 +1,121 @@
1
+ ---
2
+ type: reference
3
+ layout: docs
4
+ ---
5
+
6
+ # MCP run tool
7
+
8
+ `picked_run` is a tool of the [MCP server](/reference/tools/mcp). It runs JavaScript that
9
+ you write against the Picked API. Each MCP tool is a function on the `tools` object. Only
10
+ the value that your code returns goes back to your agent.
11
+
12
+ Use `picked_run` when a task needs many tool calls, for example to read each experience in
13
+ a workspace. For one call, use the tool directly.
14
+
15
+ ## Arguments
16
+
17
+ | Name | Type | Default | Description |
18
+ | --- | --- | --- | --- |
19
+ | `source` | `string` | None | The body of a JavaScript function. Use `return` to send back a result. |
20
+ | `allow_writes` | `boolean` | `false` | Lets the code call the tools that change data. Without it, the code can only read. |
21
+
22
+ ## Call a tool
23
+
24
+ Call a tool with `await` and one object of arguments. The arguments have the same names as
25
+ the arguments of the MCP tool.
26
+
27
+ ```js
28
+ const { experiences } = await tools.list_experiences({ workspace_id: 'YOUR_WORKSPACE_ID' })
29
+
30
+ return experiences.map(({ id, name, status }) => ({ id, name, status }))
31
+ ```
32
+
33
+ Many how-to guides end with an `## API and MCP` section. Its Run column shows the call for
34
+ each task, for example `tools.update_step({ step_id, layout_content_entry_id })`. Each name
35
+ in the call is an argument. Give a value to each one.
36
+
37
+ ## Find a tool
38
+
39
+ - `picked_search_api` finds the tools that match the words you give, for example
40
+ `content entry update`.
41
+ - `picked_describe_api` gives the arguments and the result of each tool that you name. With
42
+ no names, it lists each tool on one line.
43
+
44
+ ## Do many calls
45
+
46
+ Use `Promise.all` to start many calls together. The run does a maximum of eight calls at
47
+ the same time. Each other call waits until a call is complete.
48
+
49
+ ```js
50
+ const { experiences } = await tools.list_experiences({ workspace_id: 'YOUR_WORKSPACE_ID' })
51
+ const results = await Promise.all(
52
+ experiences.map(({ id }) => tools.get_experience({ experience_id: id })),
53
+ )
54
+
55
+ return results.map(({ experience }) => ({
56
+ name: experience.name,
57
+ nodes: experience.flow_json.nodes.length,
58
+ }))
59
+ ```
60
+
61
+ :::warning
62
+ Do not change one entity with two calls at the same time. The two calls read the same data,
63
+ and the call that completes last removes the change of the other call. The two calls both
64
+ report success. Use `await` on each change to an entity before you start the next change to
65
+ it.
66
+ :::
67
+
68
+ ## Get each page of a list
69
+
70
+ A list tool gives a maximum of 100 rows for each call. To get the next page, give the value
71
+ of `pageInfo.endCursor` as `after`. Stop when `pageInfo.hasNextPage` is `false`.
72
+
73
+ ```js
74
+ const drafts = []
75
+ let after
76
+
77
+ do {
78
+ const page = await tools.list_experiences({ workspace_id: 'YOUR_WORKSPACE_ID', after })
79
+ for (const experience of page.experiences) {
80
+ if (experience.status === 'draft') drafts.push(experience.name)
81
+ }
82
+ after = page.pageInfo.hasNextPage ? (page.pageInfo.endCursor ?? undefined) : undefined
83
+ } while (after)
84
+
85
+ return drafts
86
+ ```
87
+
88
+ ## Errors
89
+
90
+ If a tool call fails, its promise rejects. `error.message` gives the reason, and
91
+ `error.code` gives a code that does not change. Put `try` and `catch` around a call, and
92
+ the run continues after an item that fails. If you do not have permission for a call, the run stops.
93
+
94
+ ## Result
95
+
96
+ The result of a run shows these items:
97
+
98
+ - The value that the code returns.
99
+ - The text that the code writes with `console.log`. This text is also there when the run
100
+ fails.
101
+ - Each tool that the code called, with the number of calls, the time that they took, and
102
+ the calls that failed.
103
+
104
+ Return only the data that you need. A full tool result costs more than the same result
105
+ from a direct call to the tool, because a direct call gives a short text.
106
+
107
+ ## Limits
108
+
109
+ - A run stops after 20 seconds.
110
+ - The code has no network access, no file system, and no `eval`.
111
+ - The code can use `JSON`, `Math`, `Date`, `Map`, `Set`, `Promise` and `RegExp`.
112
+ - The code cannot use `fetch`, `crypto`, `Buffer`, `URL`, `Intl`, `structuredClone` or
113
+ `setTimeout`.
114
+ - Each tool call uses your permissions. A tool that you cannot use from the MCP server is
115
+ not available in a run.
116
+
117
+ ## Related
118
+
119
+ - [MCP server](/reference/tools/mcp)
120
+ - [How to connect the MCP server](/how-to/connect-the-mcp-server)
121
+ - [Management API schema](/reference/management-api/schema)