@proveanything/smartlinks 2.1.44 → 2.1.46

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.
@@ -55,6 +55,7 @@ export { loyalty } from "./loyalty.js";
55
55
  export { translations } from "./translations.js";
56
56
  export { integrations } from "./integrations.js";
57
57
  export { secrets } from "./secrets.js";
58
+ export { serviceAccounts } from "./serviceAccounts.js";
58
59
  export { research } from "./research.js";
59
60
  export { config } from "./config.js";
60
61
  export { http } from "./http.js";
package/dist/api/index.js CHANGED
@@ -58,6 +58,7 @@ export { loyalty } from "./loyalty.js";
58
58
  export { translations } from "./translations.js";
59
59
  export { integrations } from "./integrations.js";
60
60
  export { secrets } from "./secrets.js";
61
+ export { serviceAccounts } from "./serviceAccounts.js";
61
62
  export { research } from "./research.js";
62
63
  export { config } from "./config.js";
63
64
  export { http } from "./http.js";
@@ -0,0 +1,35 @@
1
+ import type { ServiceAccount, ServiceAccountList, CreateServiceAccountInput, CreateServiceAccountResult, UpdateServiceAccountInput, ServiceAccountKeyResult, AddServiceAccountToCollectionInput } from "../types/serviceAccounts.js";
2
+ export declare namespace serviceAccounts {
3
+ /**
4
+ * The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other
5
+ * collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be
6
+ * given. GET /service-accounts
7
+ */
8
+ function list(collectionId: string): Promise<ServiceAccountList>;
9
+ /**
10
+ * Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't
11
+ * give it more access than you have. POST /service-accounts
12
+ */
13
+ function create(collectionId: string, input: CreateServiceAccountInput): Promise<CreateServiceAccountResult>;
14
+ /** Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id */
15
+ function update(collectionId: string, id: string, input: UpdateServiceAccountInput): Promise<ServiceAccount>;
16
+ /** Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key */
17
+ function newKey(collectionId: string, id: string): Promise<ServiceAccountKeyResult>;
18
+ /**
19
+ * Let it work on another collection too, or change its access there. Call on its home collection; you must
20
+ * be an admin of `input.collectionId` as well, and can't give more access than you have there.
21
+ * POST /service-accounts/:id/collections
22
+ */
23
+ function addTo(collectionId: string, id: string, input: AddServiceAccountToCollectionInput): Promise<ServiceAccount>;
24
+ /** Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId */
25
+ function removeFrom(collectionId: string, id: string, otherCollectionId: string): Promise<{
26
+ ok: true;
27
+ }>;
28
+ /**
29
+ * On its home collection: delete it — its key stops working and its access is removed everywhere. On another
30
+ * collection it works on: remove it from that collection only. DELETE /service-accounts/:id
31
+ */
32
+ function remove(collectionId: string, id: string): Promise<{
33
+ ok: true;
34
+ }>;
35
+ }
@@ -0,0 +1,76 @@
1
+ // src/api/serviceAccounts.ts
2
+ //
3
+ // A collection's service accounts: identities for the systems that work with it (an ERP, a warehouse
4
+ // system, an agency's integration), each with its own key and access level. A service account is a member of
5
+ // its HOME collection, like a person on the team, and optionally of other collections too ("also works on"),
6
+ // each with its own access. It belongs to its home collection — not to whoever made it — so it keeps working
7
+ // when people leave. (A personal API key is different: it IS its person, with everything they can do.) Use its key as the bearer (`initializeApi({ bearerToken: key })` or an
8
+ // `Authorization: Bearer <key>` header); it can do what a person with the same access can on that collection
9
+ // it works on only. It can't invite people, change anyone's access, make keys or other service accounts, make
10
+ // collections or hand a collection over.
11
+ //
12
+ // Only the home collection renames it, gives it a new key, deletes it (everywhere) or adds it to another
13
+ // collection — and adding needs you to be an admin of that collection too. A collection it also works on can
14
+ // change its access there or remove it from there.
15
+ //
16
+ // Managed by the collection's admins (Studio → Team → Service accounts). The key is shown ONCE, when the
17
+ // account is made or given a new key; only its hash is kept.
18
+ //
19
+ // Endpoints: /admin/collection/:collectionId/service-accounts
20
+ import { request, post, put, del } from "../http.js";
21
+ function enc(v) { return encodeURIComponent(v); }
22
+ export var serviceAccounts;
23
+ (function (serviceAccounts) {
24
+ const base = (collectionId) => `/admin/collection/${enc(collectionId)}/service-accounts`;
25
+ /**
26
+ * The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other
27
+ * collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be
28
+ * given. GET /service-accounts
29
+ */
30
+ async function list(collectionId) {
31
+ return request(base(collectionId));
32
+ }
33
+ serviceAccounts.list = list;
34
+ /**
35
+ * Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't
36
+ * give it more access than you have. POST /service-accounts
37
+ */
38
+ async function create(collectionId, input) {
39
+ return post(base(collectionId), input);
40
+ }
41
+ serviceAccounts.create = create;
42
+ /** Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id */
43
+ async function update(collectionId, id, input) {
44
+ const out = await put(`${base(collectionId)}/${enc(id)}`, input);
45
+ return out.serviceAccount;
46
+ }
47
+ serviceAccounts.update = update;
48
+ /** Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key */
49
+ async function newKey(collectionId, id) {
50
+ return post(`${base(collectionId)}/${enc(id)}/key`, {});
51
+ }
52
+ serviceAccounts.newKey = newKey;
53
+ /**
54
+ * Let it work on another collection too, or change its access there. Call on its home collection; you must
55
+ * be an admin of `input.collectionId` as well, and can't give more access than you have there.
56
+ * POST /service-accounts/:id/collections
57
+ */
58
+ async function addTo(collectionId, id, input) {
59
+ const out = await post(`${base(collectionId)}/${enc(id)}/collections`, input);
60
+ return out.serviceAccount;
61
+ }
62
+ serviceAccounts.addTo = addTo;
63
+ /** Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId */
64
+ async function removeFrom(collectionId, id, otherCollectionId) {
65
+ return del(`${base(collectionId)}/${enc(id)}/collections/${enc(otherCollectionId)}`);
66
+ }
67
+ serviceAccounts.removeFrom = removeFrom;
68
+ /**
69
+ * On its home collection: delete it — its key stops working and its access is removed everywhere. On another
70
+ * collection it works on: remove it from that collection only. DELETE /service-accounts/:id
71
+ */
72
+ async function remove(collectionId, id) {
73
+ return del(`${base(collectionId)}/${enc(id)}`);
74
+ }
75
+ serviceAccounts.remove = remove;
76
+ })(serviceAccounts || (serviceAccounts = {}));
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.44 | Generated: 2026-11-23T13:04:11.379Z
3
+ Version: 2.1.46 | Generated: 2026-11-23T13:55:15.125Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -168,6 +168,7 @@ The Smartlinks SDK is organized into the following namespaces:
168
168
  - **realtime** - Functions for realtime operations
169
169
  - **research** - Functions for research operations
170
170
  - **secrets** - Functions for secrets operations
171
+ - **serviceAccounts** - Functions for serviceAccounts operations
171
172
  - **shop** - Functions for shop operations
172
173
  - **subscriptions** - Functions for subscriptions operations
173
174
  - **tagCodes** - Functions for tagCodes operations
@@ -11949,6 +11950,84 @@ interface SegmentRecipientsResponse {
11949
11950
 
11950
11951
  **SegmentFilterRule** = ``
11951
11952
 
11953
+ ### serviceAccounts
11954
+
11955
+ **ServiceAccount** (interface)
11956
+ ```typescript
11957
+ interface ServiceAccount {
11958
+ id: string
11959
+ name: string
11960
+ access: ServiceAccountAccess | null
11961
+ active: boolean
11962
+ home: boolean
11963
+ alsoOn?: ServiceAccountCollection[]
11964
+ homeCollection?: { collectionId: string; title: string }
11965
+ createdAt: string
11966
+ createdBy: string | null
11967
+ lastUsedAt: string | null
11968
+ keyCreatedAt: string
11969
+ keyHint: string
11970
+ }
11971
+ ```
11972
+
11973
+ **ServiceAccountCollection** (interface)
11974
+ ```typescript
11975
+ interface ServiceAccountCollection {
11976
+ collectionId: string
11977
+ title: string
11978
+ access: ServiceAccountAccess | null
11979
+ }
11980
+ ```
11981
+
11982
+ **AddServiceAccountToCollectionInput** (interface)
11983
+ ```typescript
11984
+ interface AddServiceAccountToCollectionInput {
11985
+ collectionId: string
11986
+ access: ServiceAccountAccess
11987
+ }
11988
+ ```
11989
+
11990
+ **ServiceAccountList** (interface)
11991
+ ```typescript
11992
+ interface ServiceAccountList {
11993
+ serviceAccounts: ServiceAccount[]
11994
+ access: ServiceAccountAccess[]
11995
+ }
11996
+ ```
11997
+
11998
+ **CreateServiceAccountInput** (interface)
11999
+ ```typescript
12000
+ interface CreateServiceAccountInput {
12001
+ name: string
12002
+ access: ServiceAccountAccess
12003
+ }
12004
+ ```
12005
+
12006
+ **UpdateServiceAccountInput** (interface)
12007
+ ```typescript
12008
+ interface UpdateServiceAccountInput {
12009
+ name?: string
12010
+ access?: ServiceAccountAccess
12011
+ }
12012
+ ```
12013
+
12014
+ **CreateServiceAccountResult** (interface)
12015
+ ```typescript
12016
+ interface CreateServiceAccountResult {
12017
+ serviceAccount: ServiceAccount
12018
+ key: string
12019
+ }
12020
+ ```
12021
+
12022
+ **ServiceAccountKeyResult** (interface)
12023
+ ```typescript
12024
+ interface ServiceAccountKeyResult {
12025
+ key: string
12026
+ }
12027
+ ```
12028
+
12029
+ **ServiceAccountAccess** = `"User" | "Reporter" | "Assigner" | "Admin"`
12030
+
11952
12031
  ### shop
11953
12032
 
11954
12033
  **ShopPrice** (interface)
@@ -16211,6 +16290,29 @@ Soft-delete a secret. DELETE /secrets/:ref
16211
16290
  id: string,
16212
16291
  query: { limit?: number; offset?: number } = {}) → `Promise<SegmentRecipientsResponse>`
16213
16292
 
16293
+ ### serviceAccounts
16294
+
16295
+ **list**(collectionId: string) → `Promise<ServiceAccountList>`
16296
+ The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be given. GET /service-accounts
16297
+
16298
+ **create**(collectionId: string, input: CreateServiceAccountInput) → `Promise<CreateServiceAccountResult>`
16299
+ Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't give it more access than you have. POST /service-accounts
16300
+
16301
+ **update**(collectionId: string, id: string, input: UpdateServiceAccountInput) → `Promise<ServiceAccount>`
16302
+ Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id
16303
+
16304
+ **newKey**(collectionId: string, id: string) → `Promise<ServiceAccountKeyResult>`
16305
+ Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key
16306
+
16307
+ **addTo**(collectionId: string, id: string, input: AddServiceAccountToCollectionInput) → `Promise<ServiceAccount>`
16308
+ Let it work on another collection too, or change its access there. Call on its home collection; you must be an admin of `input.collectionId` as well, and can't give more access than you have there. POST /service-accounts/:id/collections
16309
+
16310
+ **removeFrom**(collectionId: string, id: string, otherCollectionId: string) → `Promise<`
16311
+ Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId
16312
+
16313
+ **remove**(collectionId: string, id: string) → `Promise<`
16314
+ On its home collection: delete it — its key stops working and its access is removed everywhere. On another collection it works on: remove it from that collection only. DELETE /service-accounts/:id
16315
+
16214
16316
  ### sessions
16215
16317
 
16216
16318
  **stats**(collectionId: string) → `Promise<SessionStatistics>`
@@ -78,6 +78,7 @@ The SmartLinks SDK (`@proveanything/smartlinks`) includes comprehensive document
78
78
  | **AI Guide Template** | `docs/ai-guide-template.md` | Template for creating `public/ai-guide.md` — customise per app |
79
79
  | **Forms** | `docs/forms.md` | Form definitions, schema-driven rendering, submission patterns |
80
80
  | **Auth Kit** | `docs/auth-kit.md` | End-user sign-in: email/password, magic links, phone OTP, Google OAuth |
81
+ | **Service accounts** | `docs/service-accounts.md` | Identities for other systems (an ERP, a warehouse system) to work with one collection: own key, own access level, made and removed by the collection's admins |
81
82
  | **Members** | `docs/members.md` | Signed-in members with a level (clubs, leagues, members' areas): the level field, members-only functions, joining rules |
82
83
  | **Portal Request Login** | `docs/portal-request-login.md` | How sub-apps ask the portal to authenticate the user; hook and iframe postMessage contracts |
83
84
  | **Portal Auth Broadcast** | `docs/portal-auth-broadcast.md` | Publishing custom auth flows to the portal; syncing sessions across containers and iframes |
@@ -0,0 +1,64 @@
1
+ # Service accounts
2
+
3
+ A **service account** is how another system works with a collection: an ERP sending stock levels, a
4
+ warehouse system recording shipments, an agency's integration. It's an identity of its own, with its own key
5
+ and access level. It is **not** a person's API key.
6
+
7
+ - It's a member of its **home** collection with an access level (`User`, `Reporter`, `Assigner` or `Admin`),
8
+ just like a person on the team, and can **also work on** other collections, each with its own access.
9
+ Everything a person with that access can do on those collections, it can do. It can reach nothing else.
10
+ - It belongs to its home collection, not to whoever made it, so it keeps working when people leave the team.
11
+ - Its key (`slsvc_<id>.<secret>`) is shown **once**, when it's made or given a new key. Only a hash is kept.
12
+ - It **can't** invite people or change anyone's access. It can't make API keys or other service accounts,
13
+ make collections, or hand the collection over. A leaked key can't leave a way back in once it's deleted.
14
+
15
+ Collection admins manage them in **Studio → Team → Service accounts**, or with `serviceAccounts.*`:
16
+
17
+ ```ts
18
+ import { serviceAccounts } from "@proveanything/smartlinks"
19
+
20
+ // Make one: show the key once, then it's gone.
21
+ const { serviceAccount, key } = await serviceAccounts.create(collectionId, { name: "Warehouse system", access: "Assigner" })
22
+
23
+ await serviceAccounts.list(collectionId) // { serviceAccounts: [...], access: ["User", "Reporter", "Assigner", "Admin"] }
24
+ await serviceAccounts.update(collectionId, serviceAccount.id, { access: "Reporter" })
25
+ const { key: replacement } = await serviceAccounts.newKey(collectionId, serviceAccount.id) // the old key stops within a minute
26
+ await serviceAccounts.remove(collectionId, serviceAccount.id) // key stops, access removed
27
+ ```
28
+
29
+ You can't give a service account more access than you have yourself, and never `Owner`.
30
+
31
+ ## More than one collection
32
+
33
+ One system working across several collections (say, a brand's three ranges) uses one service account:
34
+
35
+ ```ts
36
+ // On its home collection; you must be an admin of the other collection too.
37
+ await serviceAccounts.addTo(collectionId, serviceAccount.id, { collectionId: otherCollectionId, access: "Reporter" })
38
+ await serviceAccounts.removeFrom(collectionId, serviceAccount.id, otherCollectionId)
39
+ ```
40
+
41
+ Same key everywhere; each request names the collection it's for. Only the home collection renames it, gives
42
+ it a new key or deletes it (deleting removes it everywhere). The other collection lists it with
43
+ `home: false` and `homeCollection`, and its admins can change its access there (`update`) or take it off
44
+ (`remove`, which there removes it from that collection only).
45
+
46
+ ## Personal API keys are different
47
+
48
+ A personal API key **is** you: everything you can do, on every collection you can, and it gains or loses
49
+ access as you do. Use one for your own scripts. Use a service account for another system, so it doesn't
50
+ depend on any one person.
51
+
52
+ ## Using the key
53
+
54
+ The other system sends the key as its bearer token:
55
+
56
+ ```ts
57
+ import { initializeApi } from "@proveanything/smartlinks"
58
+ initializeApi({ baseURL: "https://smartlinks.app/api/v1", bearerToken: process.env.SMARTLINKS_KEY })
59
+ ```
60
+
61
+ or, without the SDK, `Authorization: Bearer slsvc_…` on each request. Keep it in a secret store. To retire
62
+ a key, give the account a new one; delete the account when the system no longer needs it.
63
+
64
+ A list shows `lastUsedAt` (to within a few minutes) so you can see which accounts are still in use.
package/dist/openapi.yaml CHANGED
@@ -36981,6 +36981,121 @@ components:
36981
36981
  SegmentFilterRule:
36982
36982
  type: object
36983
36983
  additionalProperties: true
36984
+ ServiceAccount:
36985
+ type: object
36986
+ properties:
36987
+ id:
36988
+ type: string
36989
+ name:
36990
+ type: string
36991
+ access:
36992
+ $ref: "#/components/schemas/ServiceAccountAccess"
36993
+ active:
36994
+ type: boolean
36995
+ home:
36996
+ type: boolean
36997
+ alsoOn:
36998
+ type: array
36999
+ items:
37000
+ $ref: "#/components/schemas/ServiceAccountCollection"
37001
+ homeCollection:
37002
+ type: object
37003
+ additionalProperties: true
37004
+ createdAt:
37005
+ type: string
37006
+ createdBy:
37007
+ type: string
37008
+ lastUsedAt:
37009
+ type: string
37010
+ keyCreatedAt:
37011
+ type: string
37012
+ keyHint:
37013
+ type: string
37014
+ required:
37015
+ - id
37016
+ - name
37017
+ - access
37018
+ - active
37019
+ - home
37020
+ - createdAt
37021
+ - createdBy
37022
+ - lastUsedAt
37023
+ - keyCreatedAt
37024
+ - keyHint
37025
+ ServiceAccountCollection:
37026
+ type: object
37027
+ properties:
37028
+ collectionId:
37029
+ type: string
37030
+ title:
37031
+ type: string
37032
+ access:
37033
+ $ref: "#/components/schemas/ServiceAccountAccess"
37034
+ required:
37035
+ - collectionId
37036
+ - title
37037
+ - access
37038
+ AddServiceAccountToCollectionInput:
37039
+ type: object
37040
+ properties:
37041
+ collectionId:
37042
+ type: string
37043
+ access:
37044
+ $ref: "#/components/schemas/ServiceAccountAccess"
37045
+ required:
37046
+ - collectionId
37047
+ - access
37048
+ ServiceAccountList:
37049
+ type: object
37050
+ properties:
37051
+ serviceAccounts:
37052
+ type: array
37053
+ items:
37054
+ $ref: "#/components/schemas/ServiceAccount"
37055
+ access:
37056
+ type: array
37057
+ items:
37058
+ $ref: "#/components/schemas/ServiceAccountAccess"
37059
+ required:
37060
+ - serviceAccounts
37061
+ - access
37062
+ CreateServiceAccountInput:
37063
+ type: object
37064
+ properties:
37065
+ name:
37066
+ type: string
37067
+ access:
37068
+ $ref: "#/components/schemas/ServiceAccountAccess"
37069
+ required:
37070
+ - name
37071
+ - access
37072
+ UpdateServiceAccountInput:
37073
+ type: object
37074
+ properties:
37075
+ name:
37076
+ type: string
37077
+ access:
37078
+ $ref: "#/components/schemas/ServiceAccountAccess"
37079
+ CreateServiceAccountResult:
37080
+ type: object
37081
+ properties:
37082
+ serviceAccount:
37083
+ $ref: "#/components/schemas/ServiceAccount"
37084
+ key:
37085
+ type: string
37086
+ required:
37087
+ - serviceAccount
37088
+ - key
37089
+ ServiceAccountKeyResult:
37090
+ type: object
37091
+ properties:
37092
+ key:
37093
+ type: string
37094
+ required:
37095
+ - key
37096
+ ServiceAccountAccess:
37097
+ type: object
37098
+ additionalProperties: true
36984
37099
  ShopPrice:
36985
37100
  type: object
36986
37101
  properties:
@@ -16,6 +16,7 @@ export * from "./contact.js";
16
16
  export * from "./broadcasts.js";
17
17
  export * from "./segments.js";
18
18
  export * from "./userGroups.js";
19
+ export * from "./serviceAccounts.js";
19
20
  export * from "./operations.js";
20
21
  export * from "./common.js";
21
22
  export * from "./query.js";
@@ -18,6 +18,7 @@ export * from "./contact.js";
18
18
  export * from "./broadcasts.js";
19
19
  export * from "./segments.js";
20
20
  export * from "./userGroups.js";
21
+ export * from "./serviceAccounts.js";
21
22
  export * from "./operations.js";
22
23
  export * from "./common.js";
23
24
  export * from "./query.js";
@@ -0,0 +1,67 @@
1
+ /** The access a service account can have on its collection (never Owner). */
2
+ export type ServiceAccountAccess = "User" | "Reporter" | "Assigner" | "Admin";
3
+ /** One of a collection's service accounts. The key itself is never listed (only shown when made or replaced). */
4
+ export interface ServiceAccount {
5
+ /** e.g. "sa-3f9c0a1b2d4e"; its user id on the collection is "svc:" + id. */
6
+ id: string;
7
+ /** What uses it, e.g. "Warehouse system". */
8
+ name: string;
9
+ /** Its access on the collection you asked about (null if it was removed from the members another way). */
10
+ access: ServiceAccountAccess | null;
11
+ /** false once its key has been switched off. */
12
+ active: boolean;
13
+ /**
14
+ * true when it belongs to the collection you asked about (its home): only there can it be renamed, given a
15
+ * new key, deleted, or added to other collections.
16
+ */
17
+ home: boolean;
18
+ /** Home only: the other collections it also works on, each with its access there. */
19
+ alsoOn?: ServiceAccountCollection[];
20
+ /** Not home: the collection it belongs to. */
21
+ homeCollection?: {
22
+ collectionId: string;
23
+ title: string;
24
+ };
25
+ createdAt: string;
26
+ /** The user id of the person who made it. */
27
+ createdBy: string | null;
28
+ /** When its key was last used (to within a few minutes), or null if never. */
29
+ lastUsedAt: string | null;
30
+ /** When its current key was made. */
31
+ keyCreatedAt: string;
32
+ /** How its key starts ("slsvc_sa-….…"), to recognise it — never the secret. */
33
+ keyHint: string;
34
+ }
35
+ /** Another collection a service account works on. */
36
+ export interface ServiceAccountCollection {
37
+ collectionId: string;
38
+ title: string;
39
+ access: ServiceAccountAccess | null;
40
+ }
41
+ /** Let a service account work on another collection too (or change its access there). */
42
+ export interface AddServiceAccountToCollectionInput {
43
+ collectionId: string;
44
+ access: ServiceAccountAccess;
45
+ }
46
+ export interface ServiceAccountList {
47
+ serviceAccounts: ServiceAccount[];
48
+ /** The access levels that can be given. */
49
+ access: ServiceAccountAccess[];
50
+ }
51
+ export interface CreateServiceAccountInput {
52
+ name: string;
53
+ access: ServiceAccountAccess;
54
+ }
55
+ export interface UpdateServiceAccountInput {
56
+ name?: string;
57
+ access?: ServiceAccountAccess;
58
+ }
59
+ /** A new service account and its key. Show the key once: it can't be read again (make a new one instead). */
60
+ export interface CreateServiceAccountResult {
61
+ serviceAccount: ServiceAccount;
62
+ key: string;
63
+ }
64
+ /** A replacement key; the old one stops working (within a minute everywhere). */
65
+ export interface ServiceAccountKeyResult {
66
+ key: string;
67
+ }
@@ -0,0 +1,2 @@
1
+ // src/types/serviceAccounts.ts — a collection's service accounts (serviceAccounts.*)
2
+ export {};
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.44 | Generated: 2026-11-23T13:04:11.379Z
3
+ Version: 2.1.46 | Generated: 2026-11-23T13:55:15.125Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -168,6 +168,7 @@ The Smartlinks SDK is organized into the following namespaces:
168
168
  - **realtime** - Functions for realtime operations
169
169
  - **research** - Functions for research operations
170
170
  - **secrets** - Functions for secrets operations
171
+ - **serviceAccounts** - Functions for serviceAccounts operations
171
172
  - **shop** - Functions for shop operations
172
173
  - **subscriptions** - Functions for subscriptions operations
173
174
  - **tagCodes** - Functions for tagCodes operations
@@ -11949,6 +11950,84 @@ interface SegmentRecipientsResponse {
11949
11950
 
11950
11951
  **SegmentFilterRule** = ``
11951
11952
 
11953
+ ### serviceAccounts
11954
+
11955
+ **ServiceAccount** (interface)
11956
+ ```typescript
11957
+ interface ServiceAccount {
11958
+ id: string
11959
+ name: string
11960
+ access: ServiceAccountAccess | null
11961
+ active: boolean
11962
+ home: boolean
11963
+ alsoOn?: ServiceAccountCollection[]
11964
+ homeCollection?: { collectionId: string; title: string }
11965
+ createdAt: string
11966
+ createdBy: string | null
11967
+ lastUsedAt: string | null
11968
+ keyCreatedAt: string
11969
+ keyHint: string
11970
+ }
11971
+ ```
11972
+
11973
+ **ServiceAccountCollection** (interface)
11974
+ ```typescript
11975
+ interface ServiceAccountCollection {
11976
+ collectionId: string
11977
+ title: string
11978
+ access: ServiceAccountAccess | null
11979
+ }
11980
+ ```
11981
+
11982
+ **AddServiceAccountToCollectionInput** (interface)
11983
+ ```typescript
11984
+ interface AddServiceAccountToCollectionInput {
11985
+ collectionId: string
11986
+ access: ServiceAccountAccess
11987
+ }
11988
+ ```
11989
+
11990
+ **ServiceAccountList** (interface)
11991
+ ```typescript
11992
+ interface ServiceAccountList {
11993
+ serviceAccounts: ServiceAccount[]
11994
+ access: ServiceAccountAccess[]
11995
+ }
11996
+ ```
11997
+
11998
+ **CreateServiceAccountInput** (interface)
11999
+ ```typescript
12000
+ interface CreateServiceAccountInput {
12001
+ name: string
12002
+ access: ServiceAccountAccess
12003
+ }
12004
+ ```
12005
+
12006
+ **UpdateServiceAccountInput** (interface)
12007
+ ```typescript
12008
+ interface UpdateServiceAccountInput {
12009
+ name?: string
12010
+ access?: ServiceAccountAccess
12011
+ }
12012
+ ```
12013
+
12014
+ **CreateServiceAccountResult** (interface)
12015
+ ```typescript
12016
+ interface CreateServiceAccountResult {
12017
+ serviceAccount: ServiceAccount
12018
+ key: string
12019
+ }
12020
+ ```
12021
+
12022
+ **ServiceAccountKeyResult** (interface)
12023
+ ```typescript
12024
+ interface ServiceAccountKeyResult {
12025
+ key: string
12026
+ }
12027
+ ```
12028
+
12029
+ **ServiceAccountAccess** = `"User" | "Reporter" | "Assigner" | "Admin"`
12030
+
11952
12031
  ### shop
11953
12032
 
11954
12033
  **ShopPrice** (interface)
@@ -16211,6 +16290,29 @@ Soft-delete a secret. DELETE /secrets/:ref
16211
16290
  id: string,
16212
16291
  query: { limit?: number; offset?: number } = {}) → `Promise<SegmentRecipientsResponse>`
16213
16292
 
16293
+ ### serviceAccounts
16294
+
16295
+ **list**(collectionId: string) → `Promise<ServiceAccountList>`
16296
+ The service accounts that work on this collection — its own (`home: true`, with `alsoOn`) and other collections' (`home: false`, with `homeCollection`) — never their keys, and the access levels that can be given. GET /service-accounts
16297
+
16298
+ **create**(collectionId: string, input: CreateServiceAccountInput) → `Promise<CreateServiceAccountResult>`
16299
+ Make a service account → `{ serviceAccount, key }`. Show the key once — it can't be read again. You can't give it more access than you have. POST /service-accounts
16300
+
16301
+ **update**(collectionId: string, id: string, input: UpdateServiceAccountInput) → `Promise<ServiceAccount>`
16302
+ Rename it (home collection only) and/or change its access on this collection. PUT /service-accounts/:id
16303
+
16304
+ **newKey**(collectionId: string, id: string) → `Promise<ServiceAccountKeyResult>`
16305
+ Give it a new key → `{ key }` (shown once; home collection only); the old key stops working within a minute. POST /service-accounts/:id/key
16306
+
16307
+ **addTo**(collectionId: string, id: string, input: AddServiceAccountToCollectionInput) → `Promise<ServiceAccount>`
16308
+ Let it work on another collection too, or change its access there. Call on its home collection; you must be an admin of `input.collectionId` as well, and can't give more access than you have there. POST /service-accounts/:id/collections
16309
+
16310
+ **removeFrom**(collectionId: string, id: string, otherCollectionId: string) → `Promise<`
16311
+ Stop it working on `otherCollectionId` (call on its home collection). DELETE /service-accounts/:id/collections/:otherId
16312
+
16313
+ **remove**(collectionId: string, id: string) → `Promise<`
16314
+ On its home collection: delete it — its key stops working and its access is removed everywhere. On another collection it works on: remove it from that collection only. DELETE /service-accounts/:id
16315
+
16214
16316
  ### sessions
16215
16317
 
16216
16318
  **stats**(collectionId: string) → `Promise<SessionStatistics>`
package/docs/overview.md CHANGED
@@ -78,6 +78,7 @@ The SmartLinks SDK (`@proveanything/smartlinks`) includes comprehensive document
78
78
  | **AI Guide Template** | `docs/ai-guide-template.md` | Template for creating `public/ai-guide.md` — customise per app |
79
79
  | **Forms** | `docs/forms.md` | Form definitions, schema-driven rendering, submission patterns |
80
80
  | **Auth Kit** | `docs/auth-kit.md` | End-user sign-in: email/password, magic links, phone OTP, Google OAuth |
81
+ | **Service accounts** | `docs/service-accounts.md` | Identities for other systems (an ERP, a warehouse system) to work with one collection: own key, own access level, made and removed by the collection's admins |
81
82
  | **Members** | `docs/members.md` | Signed-in members with a level (clubs, leagues, members' areas): the level field, members-only functions, joining rules |
82
83
  | **Portal Request Login** | `docs/portal-request-login.md` | How sub-apps ask the portal to authenticate the user; hook and iframe postMessage contracts |
83
84
  | **Portal Auth Broadcast** | `docs/portal-auth-broadcast.md` | Publishing custom auth flows to the portal; syncing sessions across containers and iframes |
@@ -0,0 +1,64 @@
1
+ # Service accounts
2
+
3
+ A **service account** is how another system works with a collection: an ERP sending stock levels, a
4
+ warehouse system recording shipments, an agency's integration. It's an identity of its own, with its own key
5
+ and access level. It is **not** a person's API key.
6
+
7
+ - It's a member of its **home** collection with an access level (`User`, `Reporter`, `Assigner` or `Admin`),
8
+ just like a person on the team, and can **also work on** other collections, each with its own access.
9
+ Everything a person with that access can do on those collections, it can do. It can reach nothing else.
10
+ - It belongs to its home collection, not to whoever made it, so it keeps working when people leave the team.
11
+ - Its key (`slsvc_<id>.<secret>`) is shown **once**, when it's made or given a new key. Only a hash is kept.
12
+ - It **can't** invite people or change anyone's access. It can't make API keys or other service accounts,
13
+ make collections, or hand the collection over. A leaked key can't leave a way back in once it's deleted.
14
+
15
+ Collection admins manage them in **Studio → Team → Service accounts**, or with `serviceAccounts.*`:
16
+
17
+ ```ts
18
+ import { serviceAccounts } from "@proveanything/smartlinks"
19
+
20
+ // Make one: show the key once, then it's gone.
21
+ const { serviceAccount, key } = await serviceAccounts.create(collectionId, { name: "Warehouse system", access: "Assigner" })
22
+
23
+ await serviceAccounts.list(collectionId) // { serviceAccounts: [...], access: ["User", "Reporter", "Assigner", "Admin"] }
24
+ await serviceAccounts.update(collectionId, serviceAccount.id, { access: "Reporter" })
25
+ const { key: replacement } = await serviceAccounts.newKey(collectionId, serviceAccount.id) // the old key stops within a minute
26
+ await serviceAccounts.remove(collectionId, serviceAccount.id) // key stops, access removed
27
+ ```
28
+
29
+ You can't give a service account more access than you have yourself, and never `Owner`.
30
+
31
+ ## More than one collection
32
+
33
+ One system working across several collections (say, a brand's three ranges) uses one service account:
34
+
35
+ ```ts
36
+ // On its home collection; you must be an admin of the other collection too.
37
+ await serviceAccounts.addTo(collectionId, serviceAccount.id, { collectionId: otherCollectionId, access: "Reporter" })
38
+ await serviceAccounts.removeFrom(collectionId, serviceAccount.id, otherCollectionId)
39
+ ```
40
+
41
+ Same key everywhere; each request names the collection it's for. Only the home collection renames it, gives
42
+ it a new key or deletes it (deleting removes it everywhere). The other collection lists it with
43
+ `home: false` and `homeCollection`, and its admins can change its access there (`update`) or take it off
44
+ (`remove`, which there removes it from that collection only).
45
+
46
+ ## Personal API keys are different
47
+
48
+ A personal API key **is** you: everything you can do, on every collection you can, and it gains or loses
49
+ access as you do. Use one for your own scripts. Use a service account for another system, so it doesn't
50
+ depend on any one person.
51
+
52
+ ## Using the key
53
+
54
+ The other system sends the key as its bearer token:
55
+
56
+ ```ts
57
+ import { initializeApi } from "@proveanything/smartlinks"
58
+ initializeApi({ baseURL: "https://smartlinks.app/api/v1", bearerToken: process.env.SMARTLINKS_KEY })
59
+ ```
60
+
61
+ or, without the SDK, `Authorization: Bearer slsvc_…` on each request. Keep it in a secret store. To retire
62
+ a key, give the account a new one; delete the account when the system no longer needs it.
63
+
64
+ A list shows `lastUsedAt` (to within a few minutes) so you can see which accounts are still in use.
package/openapi.yaml CHANGED
@@ -36981,6 +36981,121 @@ components:
36981
36981
  SegmentFilterRule:
36982
36982
  type: object
36983
36983
  additionalProperties: true
36984
+ ServiceAccount:
36985
+ type: object
36986
+ properties:
36987
+ id:
36988
+ type: string
36989
+ name:
36990
+ type: string
36991
+ access:
36992
+ $ref: "#/components/schemas/ServiceAccountAccess"
36993
+ active:
36994
+ type: boolean
36995
+ home:
36996
+ type: boolean
36997
+ alsoOn:
36998
+ type: array
36999
+ items:
37000
+ $ref: "#/components/schemas/ServiceAccountCollection"
37001
+ homeCollection:
37002
+ type: object
37003
+ additionalProperties: true
37004
+ createdAt:
37005
+ type: string
37006
+ createdBy:
37007
+ type: string
37008
+ lastUsedAt:
37009
+ type: string
37010
+ keyCreatedAt:
37011
+ type: string
37012
+ keyHint:
37013
+ type: string
37014
+ required:
37015
+ - id
37016
+ - name
37017
+ - access
37018
+ - active
37019
+ - home
37020
+ - createdAt
37021
+ - createdBy
37022
+ - lastUsedAt
37023
+ - keyCreatedAt
37024
+ - keyHint
37025
+ ServiceAccountCollection:
37026
+ type: object
37027
+ properties:
37028
+ collectionId:
37029
+ type: string
37030
+ title:
37031
+ type: string
37032
+ access:
37033
+ $ref: "#/components/schemas/ServiceAccountAccess"
37034
+ required:
37035
+ - collectionId
37036
+ - title
37037
+ - access
37038
+ AddServiceAccountToCollectionInput:
37039
+ type: object
37040
+ properties:
37041
+ collectionId:
37042
+ type: string
37043
+ access:
37044
+ $ref: "#/components/schemas/ServiceAccountAccess"
37045
+ required:
37046
+ - collectionId
37047
+ - access
37048
+ ServiceAccountList:
37049
+ type: object
37050
+ properties:
37051
+ serviceAccounts:
37052
+ type: array
37053
+ items:
37054
+ $ref: "#/components/schemas/ServiceAccount"
37055
+ access:
37056
+ type: array
37057
+ items:
37058
+ $ref: "#/components/schemas/ServiceAccountAccess"
37059
+ required:
37060
+ - serviceAccounts
37061
+ - access
37062
+ CreateServiceAccountInput:
37063
+ type: object
37064
+ properties:
37065
+ name:
37066
+ type: string
37067
+ access:
37068
+ $ref: "#/components/schemas/ServiceAccountAccess"
37069
+ required:
37070
+ - name
37071
+ - access
37072
+ UpdateServiceAccountInput:
37073
+ type: object
37074
+ properties:
37075
+ name:
37076
+ type: string
37077
+ access:
37078
+ $ref: "#/components/schemas/ServiceAccountAccess"
37079
+ CreateServiceAccountResult:
37080
+ type: object
37081
+ properties:
37082
+ serviceAccount:
37083
+ $ref: "#/components/schemas/ServiceAccount"
37084
+ key:
37085
+ type: string
37086
+ required:
37087
+ - serviceAccount
37088
+ - key
37089
+ ServiceAccountKeyResult:
37090
+ type: object
37091
+ properties:
37092
+ key:
37093
+ type: string
37094
+ required:
37095
+ - key
37096
+ ServiceAccountAccess:
37097
+ type: object
37098
+ additionalProperties: true
36984
37099
  ShopPrice:
36985
37100
  type: object
36986
37101
  properties:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "2.1.44",
3
+ "version": "2.1.46",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",