@picked/client 0.0.1-dev.1785305085063 → 0.0.1-dev.1785908062293

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 (291) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/api-03c5jvVk.js +38 -0
  3. package/dist/api-CQxCVIrm.cjs +1 -0
  4. package/dist/cjs/form/index.js +1 -1
  5. package/dist/cjs/index.js +2 -2
  6. package/dist/cjs/plugins/dom-observer/index.js +1 -1
  7. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  8. package/dist/cjs/server/index.js +1 -1
  9. package/dist/docs/explanation/conditions-and-the-logic-engine.md +94 -0
  10. package/dist/docs/explanation/feature-flag-allocation.md +176 -0
  11. package/dist/docs/explanation/how-picked-works.md +124 -0
  12. package/dist/docs/explanation/how-pickedql-works.md +76 -0
  13. package/dist/docs/explanation/pages-and-flows.md +64 -0
  14. package/dist/docs/explanation/the-content-model.md +77 -0
  15. package/dist/docs/explanation/the-two-apis.md +68 -0
  16. package/dist/docs/explanation/why-server-side-rendering.md +76 -0
  17. package/dist/docs/explanation/workspaces-and-versions.md +71 -0
  18. package/dist/docs/how-to/add-a-step-field-or-action.md +43 -0
  19. package/dist/docs/{pickedql/examples.md → how-to/analytics/index.md} +53 -28
  20. package/dist/docs/how-to/archive-or-delete-a-workspace.md +46 -0
  21. package/dist/docs/how-to/authenticate-with-a-magic-link.md +40 -0
  22. package/dist/docs/how-to/authenticate-with-a-password.md +51 -0
  23. package/dist/docs/how-to/authenticate-with-an-api-key.md +51 -0
  24. package/dist/docs/how-to/authenticate-with-oauth.md +40 -0
  25. package/dist/docs/how-to/build-a-flow.md +83 -0
  26. package/dist/docs/how-to/connect-the-mcp-server.md +38 -0
  27. package/dist/docs/how-to/create-a-project.md +29 -0
  28. package/dist/docs/how-to/create-an-experience.md +42 -0
  29. package/dist/docs/how-to/create-and-revoke-an-api-key.md +37 -0
  30. package/dist/docs/how-to/debug-with-the-chrome-extension.md +57 -0
  31. package/dist/docs/how-to/define-a-page-layout.md +39 -0
  32. package/dist/docs/how-to/fill-and-publish-a-page.md +50 -0
  33. package/dist/docs/how-to/install-the-gtm-template.md +84 -0
  34. package/dist/docs/how-to/install-the-sdk.md +68 -0
  35. package/dist/docs/how-to/install-the-vite-plugin.md +56 -0
  36. package/dist/docs/how-to/invite-and-remove-members.md +34 -0
  37. package/dist/docs/how-to/preview-a-workspace.md +28 -0
  38. package/dist/docs/how-to/publish-a-workspace.md +30 -0
  39. package/dist/docs/how-to/read-a-feature-flag.md +101 -0
  40. package/dist/docs/how-to/register-a-component.md +55 -0
  41. package/dist/docs/how-to/register-an-action-handler.md +67 -0
  42. package/dist/docs/how-to/render-a-step-form.md +132 -0
  43. package/dist/docs/how-to/render-an-unpublished-preview.md +41 -0
  44. package/dist/docs/how-to/reuse-a-section.md +37 -0
  45. package/dist/docs/how-to/reuse-a-step-field-or-action.md +28 -0
  46. package/dist/docs/how-to/roll-back-a-published-version.md +26 -0
  47. package/dist/docs/how-to/run-an-ab-test.md +49 -0
  48. package/dist/docs/how-to/run-code-on-a-form-submission.md +125 -0
  49. package/dist/docs/how-to/server-render-a-page.md +81 -0
  50. package/dist/docs/how-to/set-a-content-security-policy.md +32 -0
  51. package/dist/docs/how-to/set-up-mfa.md +69 -0
  52. package/dist/docs/how-to/upload-and-use-an-asset.mdx +73 -0
  53. package/dist/docs/how-to/validate-a-field.md +52 -0
  54. package/dist/docs/how-to/write-a-condition.md +45 -0
  55. package/dist/docs/how-to/write-a-predicate.md +60 -0
  56. package/dist/docs/index.md +41 -59
  57. package/dist/docs/reference/dashboard/actions.mdx +53 -0
  58. package/dist/docs/reference/dashboard/api-keys.mdx +37 -0
  59. package/dist/docs/reference/dashboard/conditions.mdx +42 -0
  60. package/dist/docs/reference/dashboard/content/asset-library.mdx +63 -0
  61. package/dist/docs/reference/dashboard/content/content-entries.mdx +44 -0
  62. package/dist/docs/reference/dashboard/content/layouts.mdx +62 -0
  63. package/dist/docs/reference/dashboard/content/pages.mdx +35 -0
  64. package/dist/docs/reference/dashboard/content/sections.mdx +28 -0
  65. package/dist/docs/reference/dashboard/experiences.mdx +51 -0
  66. package/dist/docs/reference/dashboard/features.mdx +114 -0
  67. package/dist/docs/reference/dashboard/fields.mdx +100 -0
  68. package/dist/docs/reference/dashboard/flow-builder/canvas.mdx +58 -0
  69. package/dist/docs/reference/dashboard/flow-builder/condition-builder.md +57 -0
  70. package/dist/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +72 -0
  71. package/dist/docs/reference/dashboard/flow-builder/nodes.md +63 -0
  72. package/dist/docs/reference/dashboard/projects.mdx +44 -0
  73. package/dist/docs/reference/dashboard/reports.mdx +43 -0
  74. package/dist/docs/reference/dashboard/steps.mdx +37 -0
  75. package/dist/docs/reference/dashboard/team-management.md +29 -0
  76. package/dist/docs/reference/dashboard/workspace-versioning.mdx +30 -0
  77. package/dist/docs/reference/dashboard/workspaces.mdx +76 -0
  78. package/dist/docs/{delivery-api → reference/delivery-api}/experience-content.md +17 -5
  79. package/dist/docs/reference/delivery-api/index.md +45 -0
  80. package/dist/docs/reference/delivery-api/preview-caching-crawling.md +79 -0
  81. package/dist/docs/{delivery-api → reference/delivery-api}/project-config.md +15 -6
  82. package/dist/docs/reference/glossary.md +173 -0
  83. package/dist/docs/reference/management-api/authentication.md +74 -0
  84. package/dist/docs/{api → reference/management-api}/authorization-and-scopes.md +70 -47
  85. package/dist/docs/reference/management-api/error-handling.md +233 -0
  86. package/dist/docs/{api → reference/management-api}/pagination.md +36 -20
  87. package/dist/docs/reference/pickedql/data-sources.md +174 -0
  88. package/dist/docs/reference/pickedql/dimensions.md +87 -0
  89. package/dist/docs/{pickedql → reference/pickedql}/filtering.md +17 -6
  90. package/dist/docs/reference/pickedql/index.md +18 -0
  91. package/dist/docs/reference/pickedql/schema.md +172 -0
  92. package/dist/docs/reference/pickedql/virtual-functions.md +237 -0
  93. package/dist/docs/reference/sdk/actions.md +30 -0
  94. package/dist/docs/{sdk → reference/sdk}/conditions.md +15 -5
  95. package/dist/docs/reference/sdk/content-security-policy.md +21 -0
  96. package/dist/docs/reference/sdk/experiences.md +51 -0
  97. package/dist/docs/reference/sdk/features.md +233 -0
  98. package/dist/docs/reference/sdk/fields.md +209 -0
  99. package/dist/docs/reference/sdk/index.md +68 -0
  100. package/dist/docs/{sdk → reference/sdk}/plugins/create-experience.md +25 -34
  101. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +74 -0
  102. package/dist/docs/reference/sdk/plugins/index.md +29 -0
  103. package/dist/docs/{sdk → reference/sdk}/plugins/window-object.md +6 -0
  104. package/dist/docs/reference/sdk/predicates.md +43 -0
  105. package/dist/docs/reference/sdk/ssr/index.md +33 -0
  106. package/dist/docs/reference/sdk/ssr/rendering-and-hydration.md +103 -0
  107. package/dist/docs/reference/sdk/ssr/serialize.md +77 -0
  108. package/dist/docs/reference/sdk/ssr/slots-and-placements.md +59 -0
  109. package/dist/docs/reference/sdk/steps.md +87 -0
  110. package/dist/docs/reference/tools/chrome-extension.md +16 -0
  111. package/dist/docs/reference/tools/image-optimisation-service.md +104 -0
  112. package/dist/docs/reference/tools/mcp.md +88 -0
  113. package/dist/docs/reference/tools/vite-plugin.md +88 -0
  114. package/dist/docs/tutorials/first-api-call.md +228 -0
  115. package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +143 -0
  116. package/dist/docs/tutorials/first-experience.mdx +255 -0
  117. package/dist/docs/tutorials/first-server-rendered-page.mdx +186 -0
  118. package/dist/{dom-BwmTHeT7.js → dom-BqcToNL0.js} +1 -3
  119. package/dist/{dom-CDrHc_j9.cjs → dom-DlLH3FxV.cjs} +1 -1
  120. package/dist/esm/form/index.js +2 -4
  121. package/dist/esm/index.js +225 -186
  122. package/dist/esm/plugins/dom-observer/index.js +1 -1
  123. package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
  124. package/dist/esm/preview/index.js +1 -1
  125. package/dist/esm/server/index.js +33 -31
  126. package/dist/{experience-instance-DOJShRk5.js → experience-instance-DGk11d8a.js} +3 -3
  127. package/dist/experience-instance-Dej3P1sE.cjs +1 -0
  128. package/dist/plugin-CHOVsx7Z.js +287 -0
  129. package/dist/plugin-DsaGXQHx.cjs +1 -0
  130. package/dist/{preview-channel-DW9J8t4B.js → preview-channel-CSr96XAo.js} +1 -1
  131. package/dist/{protocol-DSqOlW2r.js → protocol-C5KkkiZc.js} +1 -1
  132. package/dist/types/client.d.ts +7 -6
  133. package/dist/types/data-source/api.d.ts +60 -0
  134. package/dist/types/data-source/api.d.ts.map +1 -0
  135. package/dist/types/data-source/provider.d.ts +97 -0
  136. package/dist/types/data-source/provider.d.ts.map +1 -0
  137. package/dist/types/entities/action/action.d.ts +5 -4
  138. package/dist/types/entities/action/action.d.ts.map +1 -1
  139. package/dist/types/entities/component/component.d.ts +6 -5
  140. package/dist/types/entities/component/component.d.ts.map +1 -1
  141. package/dist/types/entities/condition/condition.d.ts +5 -5
  142. package/dist/types/entities/content/content.d.ts +4 -3
  143. package/dist/types/entities/experience/experience.d.ts +11 -10
  144. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  145. package/dist/types/entities/experience-instance/experience-instance.d.ts +10 -9
  146. package/dist/types/entities/feature/feature.d.ts +19 -2
  147. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  148. package/dist/types/entities/field/field.d.ts +7 -6
  149. package/dist/types/entities/framework/framework.d.ts +7 -6
  150. package/dist/types/entities/framework/framework.d.ts.map +1 -1
  151. package/dist/types/entities/history/history.d.ts +6 -6
  152. package/dist/types/entities/plugin/plugin.d.ts +3 -2
  153. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  154. package/dist/types/entities/predicate/predicate.d.ts +4 -3
  155. package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
  156. package/dist/types/entities/response/response-validation.d.ts +3 -2
  157. package/dist/types/entities/response/response.d.ts +12 -11
  158. package/dist/types/entities/session/session.d.ts +2 -1
  159. package/dist/types/entities/step/step.d.ts +6 -5
  160. package/dist/types/exports.d.ts +2 -1
  161. package/dist/types/exports.d.ts.map +1 -1
  162. package/dist/types/form/build-responses.d.ts +2 -1
  163. package/dist/types/form/create-field-evaluator.d.ts +4 -3
  164. package/dist/types/form/create-field-validation.d.ts +5 -4
  165. package/dist/types/form/create-form.d.ts +7 -6
  166. package/dist/types/form/create-submit-pipeline.d.ts +7 -6
  167. package/dist/types/form/get-step-fields.d.ts +3 -2
  168. package/dist/types/lifecycle/condition-selection.d.ts +14 -4
  169. package/dist/types/lifecycle/lifecycle.d.ts +4 -3
  170. package/dist/types/lifecycle/rules-logic.d.ts +4 -3
  171. package/dist/types/lifecycle/state-snapshot.d.ts +4 -3
  172. package/dist/types/picked.d.ts +79 -62
  173. package/dist/types/picked.d.ts.map +1 -1
  174. package/dist/types/ping.d.ts +1 -1
  175. package/dist/types/ping.d.ts.map +1 -1
  176. package/dist/types/plugins/create-experience/create-experience.d.ts +9 -8
  177. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  178. package/dist/types/plugins/create-experience/plugin.d.ts +3 -2
  179. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  180. package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
  181. package/dist/types/plugins/dom-observer/plugin.d.ts +1 -1
  182. package/dist/types/plugins/dynamic-experiences/hash.d.ts +40 -5
  183. package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -1
  184. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -0
  185. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  186. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +4 -36
  187. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  188. package/dist/types/plugins/dynamic-experiences/types.d.ts +42 -11
  189. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  190. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -1
  191. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  192. package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -1
  193. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  194. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -1
  195. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  196. package/dist/types/plugins/responses-indexeddb/plugin.d.ts +1 -1
  197. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  198. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  199. package/dist/types/plugins/web-components/plugin.d.ts +2 -1
  200. package/dist/types/plugins/window-object/plugin.d.ts +2 -2
  201. package/dist/types/preview-channel.d.ts +5 -1
  202. package/dist/types/preview-receiver/index.d.ts +18 -1
  203. package/dist/types/preview-receiver/protocol.d.ts +10 -1
  204. package/dist/types/server/index.d.ts +3 -3
  205. package/dist/types/server/serialize.d.ts +8 -2
  206. package/dist/types/server/serialize.d.ts.map +1 -1
  207. package/dist/types/utils/dom.d.ts +2 -1
  208. package/dist/types/utils/events.d.ts +6 -6
  209. package/dist/types/utils/events.d.ts.map +1 -1
  210. package/dist/types/utils/global-obj.d.ts +1 -1
  211. package/dist/types/utils/global-obj.d.ts.map +1 -1
  212. package/dist/types/utils/id.d.ts.map +1 -1
  213. package/dist/types/utils/logger.d.ts +2 -1
  214. package/dist/types/utils/logger.d.ts.map +1 -1
  215. package/dist/types/utils/node-tree/get-next-node-from-action.d.ts +2 -1
  216. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +2 -1
  217. package/dist/types/utils/node-tree/get-next-node.d.ts +1 -1
  218. package/dist/types/utils/node-tree/get-next-node.d.ts.map +1 -1
  219. package/dist/types/utils/node-tree/get-origin-node.d.ts +1 -1
  220. package/dist/types/utils/node-tree/get-origin-node.d.ts.map +1 -1
  221. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts +1 -1
  222. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  223. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts +1 -1
  224. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  225. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +1 -1
  226. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  227. package/dist/types/utils/nodes.d.ts +1 -1
  228. package/dist/types/utils/picked-config.d.ts +2 -1
  229. package/dist/types/utils/rehydrate-scripts.d.ts +6 -0
  230. package/dist/types/utils/rehydrate-scripts.d.ts.map +1 -1
  231. package/dist/types/utils/rules-logic.d.ts +6 -2
  232. package/dist/types/utils/storage.d.ts +1 -1
  233. package/dist/types/utils/storage.d.ts.map +1 -1
  234. package/package.json +22 -23
  235. package/dist/api-CPL40b7A.js +0 -40
  236. package/dist/api-Dz5rgRgQ.cjs +0 -1
  237. package/dist/docs/actions.mdx +0 -78
  238. package/dist/docs/api/authentication.md +0 -376
  239. package/dist/docs/api/error-handling.md +0 -211
  240. package/dist/docs/api/index.md +0 -197
  241. package/dist/docs/api-keys.mdx +0 -40
  242. package/dist/docs/chrome-extension.md +0 -51
  243. package/dist/docs/conditions.mdx +0 -59
  244. package/dist/docs/content/asset-library.mdx +0 -93
  245. package/dist/docs/content/content-entries.mdx +0 -30
  246. package/dist/docs/content/layouts.mdx +0 -70
  247. package/dist/docs/content/pages.mdx +0 -67
  248. package/dist/docs/content/sections.mdx +0 -33
  249. package/dist/docs/delivery-api/index.md +0 -46
  250. package/dist/docs/delivery-api/preview-caching-crawling.md +0 -59
  251. package/dist/docs/experiences.mdx +0 -42
  252. package/dist/docs/features.mdx +0 -58
  253. package/dist/docs/fields.mdx +0 -79
  254. package/dist/docs/flow-builder/building-flows.md +0 -61
  255. package/dist/docs/flow-builder/condition-builder.md +0 -54
  256. package/dist/docs/flow-builder/keyboard-shortcuts.md +0 -66
  257. package/dist/docs/flow-builder/nodes.md +0 -43
  258. package/dist/docs/flow-builder/overview.mdx +0 -50
  259. package/dist/docs/gtm-template.md +0 -69
  260. package/dist/docs/guides/build-a-personalized-page.mdx +0 -143
  261. package/dist/docs/image-optimisation-service.md +0 -80
  262. package/dist/docs/mcp.md +0 -120
  263. package/dist/docs/pickedql/data-sources.md +0 -145
  264. package/dist/docs/pickedql/dimensions.md +0 -65
  265. package/dist/docs/pickedql/index.md +0 -36
  266. package/dist/docs/pickedql/schema.md +0 -156
  267. package/dist/docs/pickedql/virtual-functions.md +0 -204
  268. package/dist/docs/projects.mdx +0 -37
  269. package/dist/docs/reports.mdx +0 -18
  270. package/dist/docs/sdk/actions.md +0 -66
  271. package/dist/docs/sdk/content-security-policy.md +0 -32
  272. package/dist/docs/sdk/experiences.md +0 -46
  273. package/dist/docs/sdk/features.md +0 -212
  274. package/dist/docs/sdk/fields.md +0 -263
  275. package/dist/docs/sdk/index.md +0 -83
  276. package/dist/docs/sdk/plugins/dynamic-experiences.md +0 -58
  277. package/dist/docs/sdk/plugins/index.md +0 -9
  278. package/dist/docs/sdk/predicates.md +0 -112
  279. package/dist/docs/sdk/ssr/index.md +0 -62
  280. package/dist/docs/sdk/ssr/rendering-and-hydration.md +0 -141
  281. package/dist/docs/sdk/ssr/serialize.md +0 -86
  282. package/dist/docs/sdk/ssr/slots-and-placements.md +0 -35
  283. package/dist/docs/sdk/steps.md +0 -434
  284. package/dist/docs/steps.mdx +0 -44
  285. package/dist/docs/team-management.md +0 -40
  286. package/dist/docs/vite-plugin.md +0 -82
  287. package/dist/docs/workspace-versioning.mdx +0 -28
  288. package/dist/docs/workspaces.mdx +0 -102
  289. package/dist/experience-instance-DurC3pE-.cjs +0 -1
  290. package/dist/plugin-CFXwbXeM.js +0 -247
  291. package/dist/plugin-m4qekgtA.cjs +0 -1
@@ -0,0 +1,228 @@
1
+ ---
2
+ type: tutorial
3
+ layout: docs
4
+ ---
5
+
6
+ # Your first API call
7
+
8
+ In this tutorial we make your first calls to the Picked management API. We start with a
9
+ ping, then authenticate, then read your user and make an organization.
10
+
11
+ At the end you have an access token and two answers from the API.
12
+
13
+ ## Before you start
14
+
15
+ - A Picked account, with an email address and a password.
16
+ - `curl`, or any HTTP client.
17
+
18
+ :::note
19
+ This tutorial covers the GraphQL management API, which needs authentication. To serve
20
+ published configuration and page content to your application, use the read-only
21
+ [Delivery API](/reference/delivery-api) instead.
22
+ :::
23
+
24
+ ## Playground
25
+
26
+ Read the API and run a query in the
27
+ [GraphQL Playground](https://api.picked.app/api/graphql).
28
+
29
+ ## API endpoint
30
+
31
+ All requests go to a single endpoint:
32
+
33
+ ```
34
+ POST https://api.picked.app/api/graphql
35
+ ```
36
+
37
+ Every request must use the `POST` method. The JSON body must hold a `query` field,
38
+ and it can also hold a `variables` field:
39
+
40
+ ```json
41
+ {
42
+ "query": "query { ... }",
43
+ "variables": { }
44
+ }
45
+ ```
46
+
47
+ Set the `Content-Type` header to `application/json` on every request.
48
+
49
+ ```bash
50
+ curl -X POST https://api.picked.app/api/graphql \
51
+ -H "Content-Type: application/json" \
52
+ -d '{"query": "{ ping }"}'
53
+ ```
54
+
55
+ ## Ping the API
56
+
57
+ Check that the API is reachable with the `ping` query. This query needs no
58
+ authentication.
59
+
60
+ ```graphql
61
+ query {
62
+ ping
63
+ }
64
+ ```
65
+
66
+ Response:
67
+
68
+ ```json
69
+ {
70
+ "data": {
71
+ "ping": "pong"
72
+ }
73
+ }
74
+ ```
75
+
76
+ This response means that the API is ready.
77
+
78
+ ## Authenticate
79
+
80
+ Most operations need an access token. To get one, create a session with your email
81
+ address and your password.
82
+
83
+ ```graphql
84
+ mutation {
85
+ sessionCreate(input: {
86
+ email: "you@example.com"
87
+ password: "your-password"
88
+ }) {
89
+ session {
90
+ accessToken
91
+ refreshToken
92
+ expiresAt
93
+ }
94
+ requiresMfa
95
+ }
96
+ }
97
+ ```
98
+
99
+ A successful response returns a `Session` with an `accessToken` and a
100
+ `refreshToken`:
101
+
102
+ ```json
103
+ {
104
+ "data": {
105
+ "sessionCreate": {
106
+ "session": {
107
+ "accessToken": "eyJhbGciOiJIUzI1NiIs...",
108
+ "refreshToken": "v1.refresh-token...",
109
+ "expiresAt": "2025-01-15T12:00:00Z"
110
+ },
111
+ "requiresMfa": false
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ When `requiresMfa` is `true`, you must complete the MFA challenge before you receive
118
+ a session. See the [Authentication](/reference/management-api/authentication) guide.
119
+
120
+ For a server-to-server integration, use
121
+ [API key authentication](/reference/management-api/authentication#api-key-authentication) and not a
122
+ session token.
123
+
124
+ ## Make an authenticated query
125
+
126
+ Pass the access token in the `Authorization` header as a Bearer token:
127
+
128
+ ```
129
+ Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
130
+ ```
131
+
132
+ You can now query a resource that needs authentication. This example reads your user
133
+ profile:
134
+
135
+ ```graphql
136
+ query {
137
+ user {
138
+ id
139
+ email
140
+ createdAt
141
+ organizations(first: 5) {
142
+ edges {
143
+ node {
144
+ id
145
+ name
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ ## Make a mutation
154
+
155
+ A mutation follows the same pattern. Send a `POST` request with the `Authorization`
156
+ header. This example creates an organization:
157
+
158
+ ```graphql
159
+ mutation {
160
+ organizationCreate(input: {
161
+ name: "My Company"
162
+ slug: "my-company"
163
+ }) {
164
+ organization {
165
+ id
166
+ name
167
+ slug
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ Response:
174
+
175
+ ```json
176
+ {
177
+ "data": {
178
+ "organizationCreate": {
179
+ "organization": {
180
+ "id": "org_abc123",
181
+ "name": "My Company",
182
+ "slug": "my-company"
183
+ }
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ Every mutation takes an `input` argument and returns a payload object. On success the
190
+ payload holds the resource that the mutation created or updated. On failure the
191
+ `errors` array at the top level holds the errors.
192
+
193
+ ## Errors
194
+
195
+ When something goes wrong, the API returns the errors in the standard GraphQL
196
+ `errors` array:
197
+
198
+ ```json
199
+ {
200
+ "data": null,
201
+ "errors": [
202
+ {
203
+ "message": "Invalid credentials",
204
+ "extensions": {
205
+ "code": "INVALID_CREDENTIALS"
206
+ }
207
+ }
208
+ ]
209
+ }
210
+ ```
211
+
212
+ Read the `extensions.code` field. It holds an error code that your code can act on.
213
+ See the [Errors](/reference/management-api/error-handling) guide for the full list of codes.
214
+
215
+ ## What you built
216
+
217
+ You authenticated against the management API, read your own user, and created an
218
+ organization. Every other operation follows the same shape: a `POST` to one endpoint,
219
+ with your token in the `Authorization` header.
220
+
221
+ ## Where to go next
222
+
223
+ - [Authentication](/reference/management-api/authentication) — an email address and a password, OAuth,
224
+ magic links, MFA, API keys, and how to control a session.
225
+ - [Authorization and Scopes](/reference/management-api/authorization-and-scopes) — what each role can
226
+ reach, and how a scope controls a permission.
227
+ - [Pagination](/reference/management-api/pagination) — how to move through a large result with a cursor.
228
+ - [Errors](/reference/management-api/error-handling) — every error code that the API can return.
@@ -0,0 +1,143 @@
1
+ ---
2
+ type: tutorial
3
+ layout: docs
4
+ ---
5
+
6
+ import { Screenshot } from '../../../components/Screenshot'
7
+
8
+ # Build your first experience
9
+
10
+ In this tutorial we build a survey and show it to your visitors. We do all of it in the
11
+ Picked dashboard.
12
+
13
+ At the end you have one experience, one step, one field, and a preview of the survey on
14
+ your own site.
15
+
16
+ ## You will need
17
+
18
+ **A Picked account, in an organization.** An organization holds your projects and the
19
+ people who work on them. If you have an invitation, accept it and sign in. If nobody made
20
+ an organization yet, make one from the dashboard home page.
21
+
22
+ **A project.** A project is one site or one application. See
23
+ [How to create a project](/how-to/create-a-project). Keep the project home page open,
24
+ because it shows the SDK snippet that the next item needs.
25
+
26
+ **The URL of your site**, such as `https://www.example.com`. Step 5 opens it to show you
27
+ the survey. It can be a test site.
28
+
29
+ ## What a developer must do first
30
+
31
+ The SDK must be on your site before step 1. This happens one time, and after it you need
32
+ no developer again. Send them these four tasks:
33
+
34
+ 1. Add the SDK to the site. The snippet and the project ID are on the project home page.
35
+ See [How to install the SDK](/how-to/install-the-sdk).
36
+ 2. Make a component that renders a step form.
37
+ 3. [Register that component](/how-to/register-a-component) under the name `ColorSurvey`.
38
+ Step 3 enters the same name in the dashboard, and the two names must match.
39
+ 4. Tell you which site the SDK runs on, so you can open a preview against it.
40
+
41
+ [Add Picked to your application](/tutorials/first-experience) walks a developer through
42
+ all of it.
43
+
44
+ ## 1. Make a field
45
+
46
+ A field collects one answer from your visitor.
47
+
48
+ 1. Open your project.
49
+ 2. Click **Fields** in the sidebar.
50
+ 3. Click **New field**.
51
+ 4. Enter the name `Color`. The dashboard fills in the label and the key for you.
52
+ 5. Change the label to `Which color do you like most?`. Your visitors read the label, and
53
+ they never see the name or the key.
54
+ 6. Leave the key as `color`. You cannot change it later.
55
+ 7. Choose the type **Text**.
56
+ 8. Click **Create field**.
57
+
58
+ <Screenshot
59
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields/new"
60
+ alt="The new field form, with a name, a label, and a key entered"
61
+ fill={{ 'input[name="name"]': 'Color', 'input[name="label"]': 'Which color do you like most?' }}
62
+ />
63
+
64
+ <Screenshot
65
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields"
66
+ alt="The fields list for a workspace on the Picked dashboard"
67
+ />
68
+
69
+ Your field appears in the fields list.
70
+
71
+ ## 2. Make the experience
72
+
73
+ 1. Click **Flows** in the sidebar. The experiences list opens.
74
+ 2. Click **New experience**.
75
+ 3. Enter the name `Color survey`.
76
+ 4. Leave **Type** on the **Flow** option. A flow is the interactive kind, and it is what
77
+ this tutorial builds. See [About pages and flows](/explanation/pages-and-flows) for the
78
+ other kind.
79
+ 5. Open **Advanced**.
80
+ 6. Enter the component name `ColorSurvey`. This is the name your developer registered.
81
+ 7. Click **Create flow**.
82
+
83
+ The flow builder opens with an empty canvas. One gray circle sits on the left. That
84
+ circle is the origin, and every flow starts there.
85
+
86
+ ## 3. Make a step
87
+
88
+ A step is one screen that your visitor sees. It holds your field. You make one from the
89
+ library, on the left of the flow builder.
90
+
91
+ 1. Find the **Steps** section in the library.
92
+ 2. Click the **+** next to it.
93
+ 3. Enter the name `Question`. The key fills in as `question`.
94
+ 4. Click **Create step**.
95
+
96
+ The flow builder opens again, and your step is in the library.
97
+
98
+ ## 4. Build the flow
99
+
100
+ 1. Find your `Question` step under **Steps** in the library.
101
+ 2. Drag it onto the canvas.
102
+ 3. Drag from the output handle of the origin to the input handle of your step. An arrow
103
+ joins them.
104
+ 4. Drag your `Color` field from the library onto the step node.
105
+ 5. Click **Save** in the toolbar.
106
+
107
+ <Screenshot
108
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/experiences/{experienceId}"
109
+ alt="The flow builder with the library, canvas, and inspector panels"
110
+ />
111
+
112
+ The subtitle of the step node now reads one field. Your flow is one step long, and it
113
+ starts at the origin.
114
+
115
+ ## 5. Preview it
116
+
117
+ A preview opens your own site with this workspace applied. Your visitors see no change.
118
+
119
+ 1. Click **Preview** in the workspace toolbar.
120
+ 2. Enter the URL of your site.
121
+ 3. Click **Open preview**.
122
+
123
+ Your site opens in a new tab, and your survey is on it. Enter a color and continue.
124
+
125
+ ## 6. Publish it
126
+
127
+ 1. Click **Publish** in the workspace toolbar.
128
+ 2. Read the change preview. It lists what your visitors get.
129
+ 3. Click **Publish** to confirm.
130
+
131
+ Your survey is live.
132
+
133
+ ## What you built
134
+
135
+ You have an experience that your visitors see. The dashboard holds the flow, the step, and
136
+ the field, so you change any of them and publish again without a deployment.
137
+
138
+ ## Where to go next
139
+
140
+ - [How to build a flow](/how-to/build-a-flow) — branches, actions, and conditions.
141
+ - [How to run an A/B test](/how-to/run-an-ab-test) — show a change to some visitors.
142
+ - [About how Picked works](/explanation/how-picked-works) — what happens when you
143
+ publish.
@@ -0,0 +1,255 @@
1
+ ---
2
+ type: tutorial
3
+ layout: docs
4
+ ---
5
+
6
+ import { Screenshot } from '../../../components/Screenshot'
7
+
8
+ # Add Picked to your application
9
+
10
+ In this tutorial we make a color survey and put it on a page. We build the flow in the
11
+ Picked dashboard, connect the SDK to it, and see the survey in a browser.
12
+
13
+ At the end you have one experience, one step, one field, and a page that shows them.
14
+
15
+ ## Before you start
16
+
17
+ - A Picked account, and an organization in it.
18
+ - Node 20 or later.
19
+ - A web application that runs React or Svelte. A new Vite application is enough.
20
+
21
+ ## 1. Make a project
22
+
23
+ A project is one site or one application.
24
+
25
+ 1. Sign in to the dashboard.
26
+ 2. Open your organization.
27
+ 3. Click **New Project**.
28
+ 4. Enter the name `Tutorial`.
29
+ 5. Click **Create**.
30
+
31
+ The project home page opens. It shows a project ID near the top. Copy that ID. Every step
32
+ after this one needs it.
33
+
34
+ ## 2. Make a field
35
+
36
+ A field collects one answer from your visitor.
37
+
38
+ 1. Click **Fields** in the sidebar.
39
+ 2. Click **New field**.
40
+ 3. Enter the name `Color`. The dashboard fills in the label and the key for you.
41
+ 4. Change the label to `Which color do you like most?`.
42
+ 5. Leave the key as `color`.
43
+ 6. Choose the type **Text**.
44
+ 7. Click **Create field**.
45
+
46
+ <Screenshot
47
+ route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields"
48
+ alt="The fields list for a workspace on the Picked dashboard"
49
+ />
50
+
51
+ The field now appears in the fields list.
52
+
53
+ ## 3. Make the experience
54
+
55
+ 1. Click **Flows** in the sidebar. The experiences list opens.
56
+ 2. Click **New experience**.
57
+ 3. Enter the name `Color survey`.
58
+ 4. Leave **Type** on the **Flow** option.
59
+ 5. Open **Advanced**.
60
+ 6. Enter the component name `ColorSurvey`.
61
+ 7. Click **Create flow**.
62
+
63
+ The flow builder opens with an empty canvas. One gray circle is on the left. That circle
64
+ is the origin, and every flow starts there.
65
+
66
+ ## 4. Make a step
67
+
68
+ A step is one screen that your visitor sees. It holds your field. You make one from the
69
+ library, on the left of the flow builder.
70
+
71
+ 1. Find the **Steps** section in the library.
72
+ 2. Click the **+** next to it.
73
+ 3. Enter the name `Question`. The key fills in as `question`.
74
+ 4. Click **Create step**.
75
+
76
+ The flow builder opens again, and your step is in the library.
77
+
78
+ ## 5. Build the flow
79
+
80
+ 1. Find your `Question` step in the library on the left.
81
+ 2. Drag it onto the canvas.
82
+ 3. Drag from the output handle of the origin to the input handle of your step. An arrow
83
+ joins them.
84
+ 4. Drag your `Color` field from the library onto the step node.
85
+ 5. Click **Save** in the toolbar.
86
+
87
+ The subtitle of the step node now reads one field. Your flow is one step long, and it
88
+ starts at the origin.
89
+
90
+ ## 6. Publish the workspace
91
+
92
+ Your visitors see nothing until you publish.
93
+
94
+ 1. Click **Publish** in the workspace toolbar.
95
+ 2. Read the change preview.
96
+ 3. Click **Publish** to confirm.
97
+
98
+ ## 7. Connect the SDK
99
+
100
+ Install the client and the adapter for your framework.
101
+
102
+ :::code-group
103
+
104
+ ```bash [React]
105
+ npm install @picked/client @picked/react effector effector-react
106
+ ```
107
+
108
+ ```bash [Svelte]
109
+ npm install @picked/client @picked/svelte effector
110
+ ```
111
+
112
+ :::
113
+
114
+ Now write the component that renders the step. Put it in `ColorSurvey.tsx`, or in
115
+ `ColorSurvey.svelte`. It reads the fields of the active step and
116
+ puts each one in a form.
117
+
118
+ :::code-group
119
+
120
+ ```tsx [React]
121
+ import { useStep } from '@picked/react/hooks'
122
+ import { useUnit } from 'effector-react'
123
+
124
+ export function ColorSurvey() {
125
+ const { fields, form } = useStep()
126
+ const currentFields = useUnit(fields)
127
+
128
+ return (
129
+ <form {...form.props}>
130
+ {currentFields.map((field) => (
131
+ <div key={field.id}>
132
+ <label htmlFor={field.id}>{field.label}</label>
133
+ <input
134
+ id={field.id}
135
+ name={field.id}
136
+ value={field.value ?? ''}
137
+ onChange={field.onChange}
138
+ onBlur={field.onBlur}
139
+ />
140
+ </div>
141
+ ))}
142
+ <button type="submit">Continue</button>
143
+ </form>
144
+ )
145
+ }
146
+ ```
147
+
148
+ ```svelte [Svelte]
149
+ <script lang="ts">
150
+ import { getStep } from '@picked/svelte/hooks'
151
+
152
+ const { fields, form } = getStep()
153
+ </script>
154
+
155
+ <form {...form.props}>
156
+ {#each $fields as field}
157
+ <div>
158
+ <label for={field.id}>{field.label}</label>
159
+ <input
160
+ id={field.id}
161
+ name={field.id}
162
+ value={field.value ?? ''}
163
+ onchange={field.onChange}
164
+ onblur={field.onBlur}
165
+ />
166
+ </div>
167
+ {/each}
168
+ <button type="submit">Continue</button>
169
+ </form>
170
+ ```
171
+
172
+ :::
173
+
174
+ Then start the client from `picked.ts`. Put your project ID in `projectId`. The key in `components` must
175
+ match the component name that you entered in step 4.
176
+
177
+ :::code-group
178
+
179
+ ```tsx [React]
180
+ import { createClient } from '@picked/client'
181
+ import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
182
+ import { adaptReactComponent } from '@picked/react'
183
+ import { reactFrameworkPlugin } from '@picked/react/plugins/framework'
184
+ import { ColorSurvey } from './ColorSurvey'
185
+
186
+ export const picked = createClient({
187
+ projectId: 'your-project-id',
188
+ components: {
189
+ ColorSurvey: adaptReactComponent(ColorSurvey),
190
+ },
191
+ plugins: [reactFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
192
+ })
193
+
194
+ picked.start()
195
+ ```
196
+
197
+ ```ts [Svelte]
198
+ import { createClient } from '@picked/client'
199
+ import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
200
+ import { adaptSvelteComponent } from '@picked/svelte'
201
+ import { svelteFrameworkPlugin } from '@picked/svelte/plugins/framework'
202
+ import ColorSurvey from './ColorSurvey.svelte'
203
+
204
+ export const picked = createClient({
205
+ projectId: 'your-project-id',
206
+ components: {
207
+ ColorSurvey: adaptSvelteComponent(ColorSurvey),
208
+ },
209
+ plugins: [svelteFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
210
+ })
211
+
212
+ picked.start()
213
+ ```
214
+
215
+ :::
216
+
217
+ `dynamicExperiencesPlugin` reads the published configuration of your project. It registers your
218
+ experience, your step, and your field. You declare none of them in code.
219
+
220
+ ## 8. See it
221
+
222
+ Start your application and open it in a browser.
223
+
224
+ Your survey appears. It shows the label `Which color do you like most?` and one text
225
+ input. Both come from the dashboard, and neither is in your code.
226
+
227
+ ## 9. Change it without a deployment
228
+
229
+ This step shows you what the dashboard controls.
230
+
231
+ 1. Go back to the dashboard.
232
+ 2. Open your `Color` field.
233
+ 3. Change the label to `Which color do you like least?`.
234
+ 4. Click **Save**.
235
+ 5. Publish the workspace again.
236
+ 6. Open the page in your browser again.
237
+
238
+ The question changes. You edited no code and you deployed nothing.
239
+
240
+ ## What you built
241
+
242
+ You have an experience that you control from the dashboard and render in your own
243
+ application. The dashboard holds the flow, the step, and the field. Your code holds only
244
+ the component and the client.
245
+
246
+ To change the label, the field type, or the order of the steps, edit the workspace and
247
+ publish again. You deploy no code.
248
+
249
+ ## Where to go next
250
+
251
+ - [Your first server-rendered page](/tutorials/first-server-rendered-page) — a page that
252
+ a search engine can read.
253
+ - [How to build a flow](/how-to/build-a-flow) — branches, actions, and conditions.
254
+ - [About how Picked works](/explanation/how-picked-works) — what happens between publish
255
+ and render.