@zeyos/client 0.1.0

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 (110) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +458 -0
  4. package/agents/README.md +66 -0
  5. package/agents/shared/business-app-benchmarks.md +111 -0
  6. package/agents/shared/zeyos-entity-map.md +142 -0
  7. package/agents/shared/zeyos-entity-reference.md +570 -0
  8. package/agents/shared/zeyos-query-patterns.md +89 -0
  9. package/agents/zeyos-account-intelligence/SKILL.md +34 -0
  10. package/agents/zeyos-account-intelligence/agents/openai.yaml +4 -0
  11. package/agents/zeyos-account-intelligence/references/workflows.md +84 -0
  12. package/agents/zeyos-billing-insights/SKILL.md +41 -0
  13. package/agents/zeyos-billing-insights/agents/openai.yaml +4 -0
  14. package/agents/zeyos-billing-insights/references/workflows.md +106 -0
  15. package/agents/zeyos-campaign-and-outreach/SKILL.md +44 -0
  16. package/agents/zeyos-campaign-and-outreach/agents/openai.yaml +4 -0
  17. package/agents/zeyos-campaign-and-outreach/references/workflows.md +100 -0
  18. package/agents/zeyos-collaboration-and-activity/SKILL.md +37 -0
  19. package/agents/zeyos-collaboration-and-activity/agents/openai.yaml +4 -0
  20. package/agents/zeyos-collaboration-and-activity/references/workflows.md +104 -0
  21. package/agents/zeyos-collections-and-dunning/SKILL.md +46 -0
  22. package/agents/zeyos-collections-and-dunning/agents/openai.yaml +4 -0
  23. package/agents/zeyos-collections-and-dunning/references/workflows.md +132 -0
  24. package/agents/zeyos-commerce-and-inventory/SKILL.md +38 -0
  25. package/agents/zeyos-commerce-and-inventory/agents/openai.yaml +4 -0
  26. package/agents/zeyos-commerce-and-inventory/references/workflows.md +101 -0
  27. package/agents/zeyos-mail-operations/SKILL.md +35 -0
  28. package/agents/zeyos-mail-operations/agents/openai.yaml +4 -0
  29. package/agents/zeyos-mail-operations/references/workflows.md +110 -0
  30. package/agents/zeyos-notes-and-sops/SKILL.md +31 -0
  31. package/agents/zeyos-notes-and-sops/agents/openai.yaml +4 -0
  32. package/agents/zeyos-notes-and-sops/references/workflows.md +85 -0
  33. package/agents/zeyos-platform-and-schema/SKILL.md +37 -0
  34. package/agents/zeyos-platform-and-schema/agents/openai.yaml +4 -0
  35. package/agents/zeyos-platform-and-schema/references/workflows.md +97 -0
  36. package/agents/zeyos-work-management/SKILL.md +45 -0
  37. package/agents/zeyos-work-management/agents/openai.yaml +4 -0
  38. package/agents/zeyos-work-management/references/workflows.md +148 -0
  39. package/docs/01-api-reference/01-data-retrieval.md +601 -0
  40. package/docs/01-api-reference/02-authentication.md +288 -0
  41. package/docs/01-api-reference/03-resources.md +270 -0
  42. package/docs/01-api-reference/04-schema.md +539 -0
  43. package/docs/01-api-reference/_category_.json +9 -0
  44. package/docs/02-javascript-client/01-getting-started.md +146 -0
  45. package/docs/02-javascript-client/02-authentication.md +287 -0
  46. package/docs/02-javascript-client/03-making-requests.md +572 -0
  47. package/docs/02-javascript-client/04-practical-guide.md +348 -0
  48. package/docs/02-javascript-client/_category_.json +9 -0
  49. package/docs/03-cli/01-getting-started.md +219 -0
  50. package/docs/03-cli/02-commands.md +407 -0
  51. package/docs/03-cli/03-configuration.md +220 -0
  52. package/docs/03-cli/_category_.json +9 -0
  53. package/docs/04-agent-workflows/00-coding-agents.md +35 -0
  54. package/docs/04-agent-workflows/01-agent-quickstart.md +147 -0
  55. package/docs/04-agent-workflows/02-agent-recipes.md +109 -0
  56. package/docs/04-agent-workflows/03-cli-coverage-and-escalation.md +65 -0
  57. package/docs/04-agent-workflows/_category_.json +9 -0
  58. package/docs/04-sample-apps/01-kanban.md +89 -0
  59. package/docs/04-sample-apps/02-crm.md +81 -0
  60. package/docs/04-sample-apps/03-dashboard.md +80 -0
  61. package/docs/04-sample-apps/_category_.json +9 -0
  62. package/docs/05-tutorials/00-application-developers.md +43 -0
  63. package/docs/05-tutorials/01-integration-architecture.md +60 -0
  64. package/docs/05-tutorials/02-build-your-own-zeyos-frontend.md +517 -0
  65. package/docs/05-tutorials/03-server-side-integrations.md +185 -0
  66. package/docs/05-tutorials/_category_.json +9 -0
  67. package/docs/intro.md +197 -0
  68. package/openapi/api.json +24308 -0
  69. package/openapi/auth.json +415 -0
  70. package/openapi/dbref.json +56223 -0
  71. package/openapi/oauth2.json +781 -0
  72. package/openapi/sdk.json +949 -0
  73. package/openapi/views.txt +642 -0
  74. package/package.json +49 -0
  75. package/samples/crm/README.md +28 -0
  76. package/samples/crm/index.html +327 -0
  77. package/samples/crm/js/api.js +208 -0
  78. package/samples/crm/js/auth.js +61 -0
  79. package/samples/crm/js/main.js +545 -0
  80. package/samples/crm/js/state.js +90 -0
  81. package/samples/crm/js/ui.js +51 -0
  82. package/samples/dashboard/README.md +28 -0
  83. package/samples/dashboard/index.html +280 -0
  84. package/samples/dashboard/js/api.js +197 -0
  85. package/samples/dashboard/js/auth.js +59 -0
  86. package/samples/dashboard/js/main.js +382 -0
  87. package/samples/dashboard/js/state.js +81 -0
  88. package/samples/dashboard/js/ui.js +48 -0
  89. package/samples/kanban/README.md +28 -0
  90. package/samples/kanban/index.html +263 -0
  91. package/samples/kanban/js/api.js +152 -0
  92. package/samples/kanban/js/auth.js +59 -0
  93. package/samples/kanban/js/constants.js +40 -0
  94. package/samples/kanban/js/kanban.js +246 -0
  95. package/samples/kanban/js/main.js +362 -0
  96. package/samples/kanban/js/modals.js +474 -0
  97. package/samples/kanban/js/settings.js +82 -0
  98. package/samples/kanban/js/state.js +118 -0
  99. package/samples/kanban/js/ui.js +49 -0
  100. package/scripts/generate-client.mjs +344 -0
  101. package/src/generated/operations.js +9772 -0
  102. package/src/generated/schema.js +8982 -0
  103. package/src/index.js +85 -0
  104. package/src/runtime/client.js +1208 -0
  105. package/src/runtime/error.js +29 -0
  106. package/src/runtime/http.js +174 -0
  107. package/src/runtime/request-shape.js +35 -0
  108. package/src/runtime/schema.js +206 -0
  109. package/src/runtime/suggest.js +74 -0
  110. package/src/runtime/token-store.js +105 -0
@@ -0,0 +1,288 @@
1
+ ---
2
+ sidebar_label: Authentication
3
+ ---
4
+
5
+ # Authentication
6
+
7
+ The ZeyOS API supports multiple authentication methods to accommodate different use cases -- from server-side integrations to browser-based applications. This guide covers OAuth2 token-based authentication, session cookie authentication, and the helpers provided by the `@zeyos/client` library.
8
+
9
+ ## Authentication Overview
10
+
11
+ ZeyOS exposes an OAuth2-compatible authorization server at:
12
+
13
+ ```
14
+ https://cloud.zeyos.com/{INSTANCE}/oauth2/v1/
15
+ ```
16
+
17
+ This endpoint supports the standard OAuth 2.0 Authorization Code flow, token refresh, token revocation, and token introspection. For browser applications where the user is already logged into ZeyOS, session cookie authentication is also available.
18
+
19
+ ## OAuth 2.0 Authorization Code Flow
20
+
21
+ The Authorization Code flow is the recommended approach for server-side applications and other trusted integrations that need to act on behalf of a user.
22
+
23
+ ### Step 1: Build the Authorization URL
24
+
25
+ Redirect the user to the ZeyOS authorization endpoint to request access. The JavaScript example below assumes a trusted environment that can safely hold OAuth client credentials:
26
+
27
+ ```js
28
+ import { createZeyosClient } from '@zeyos/client';
29
+
30
+ const client = createZeyosClient({
31
+ platform: 'https://cloud.zeyos.com/demo',
32
+ auth: {
33
+ oauth: {
34
+ clientId: 'YOUR_CLIENT_ID',
35
+ clientSecret: 'YOUR_CLIENT_SECRET',
36
+ },
37
+ },
38
+ });
39
+
40
+ const authUrl = client.oauth2.buildAuthorizationUrl({
41
+ redirectUri: 'https://yourapp.example.com/callback',
42
+ state: 'random-csrf-token',
43
+ });
44
+
45
+ // Redirect the user to authUrl
46
+ ```
47
+
48
+ The authorization URL follows this format:
49
+
50
+ ```
51
+ https://cloud.zeyos.com/{INSTANCE}/oauth2/v1/authorize
52
+ ?client_id=YOUR_CLIENT_ID
53
+ &redirect_uri=https://yourapp.example.com/callback
54
+ &response_type=code
55
+ &state=random-csrf-token
56
+ ```
57
+
58
+ ### Step 2: User Authorizes
59
+
60
+ The user logs in (if not already authenticated) and approves access to your application. ZeyOS redirects the user back to your `redirect_uri` with an authorization code:
61
+
62
+ ```
63
+ https://yourapp.example.com/callback?code=AUTHORIZATION_CODE&state=random-csrf-token
64
+ ```
65
+
66
+ ### Step 3: Exchange the Code for Tokens
67
+
68
+ Exchange the authorization code for an access token and refresh token:
69
+
70
+ **Using the JavaScript client:**
71
+
72
+ ```js
73
+ const callback = client.oauth2.parseAuthorizationCallback(callbackUrl);
74
+
75
+ if (callback.isError) {
76
+ console.error('Authorization failed:', callback.errorDescription);
77
+ } else {
78
+ const tokenSet = await client.oauth2.exchangeAuthorizationCode({
79
+ code: callback.code,
80
+ redirectUri: 'https://yourapp.example.com/callback',
81
+ });
82
+
83
+ console.log('Access token:', tokenSet.accessToken);
84
+ console.log('Refresh token:', tokenSet.refreshToken);
85
+ }
86
+ ```
87
+
88
+ **Using curl:**
89
+
90
+ ```bash
91
+ curl -X POST "https://cloud.zeyos.com/demo/oauth2/v1/token" \
92
+ -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
93
+ -H "Content-Type: application/x-www-form-urlencoded" \
94
+ -d "grant_type=authorization_code" \
95
+ -d "code=AUTHORIZATION_CODE" \
96
+ -d "redirect_uri=https://yourapp.example.com/callback"
97
+ ```
98
+
99
+ **Response:**
100
+
101
+ ```json
102
+ {
103
+ "access_token": "eyJhbGciOiJSUzI1NiIs...",
104
+ "token_type": "Bearer",
105
+ "expires_in": 3600,
106
+ "refresh_token": "dGhpcyBpcyBhIHJlZnJlc2g..."
107
+ }
108
+ ```
109
+
110
+ ### Step 4: Use the Bearer Token
111
+
112
+ Include the access token in the `Authorization` header for all API requests:
113
+
114
+ ```bash
115
+ curl -X POST "https://cloud.zeyos.com/demo/api/v1/tickets" \
116
+ -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIs..." \
117
+ -H "Content-Type: application/json" \
118
+ -d '{"limit": 10}'
119
+ ```
120
+
121
+ With the JavaScript client, tokens are managed automatically once stored:
122
+
123
+ ```js
124
+ const tickets = await client.api.listTickets({ limit: 10 });
125
+ ```
126
+
127
+ ## Token Refresh
128
+
129
+ Access tokens expire after a limited time (indicated by `expires_in` in the token response). Use the refresh token to obtain a new access token without requiring user interaction.
130
+
131
+ **Using the JavaScript client:**
132
+
133
+ ```js
134
+ const newTokenSet = await client.oauth2.refreshToken();
135
+ ```
136
+
137
+ :::tip
138
+ When you configure `autoRefresh: true` in the client's OAuth settings, expired access tokens are refreshed automatically before each request. This requires `clientId` and `clientSecret`, so treat it as a trusted-environment pattern.
139
+ :::
140
+
141
+ **Using curl:**
142
+
143
+ ```bash
144
+ curl -X POST "https://cloud.zeyos.com/demo/oauth2/v1/token" \
145
+ -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
146
+ -H "Content-Type: application/x-www-form-urlencoded" \
147
+ -d "grant_type=refresh_token" \
148
+ -d "refresh_token=dGhpcyBpcyBhIHJlZnJlc2g..."
149
+ ```
150
+
151
+ ## Token Revocation
152
+
153
+ Revoke a token when the user logs out or your application no longer needs access:
154
+
155
+ **Using the JavaScript client:**
156
+
157
+ ```js
158
+ await client.oauth2.revokeToken({
159
+ token: tokenSet.accessToken,
160
+ });
161
+ ```
162
+
163
+ **Using curl:**
164
+
165
+ ```bash
166
+ curl -X POST "https://cloud.zeyos.com/demo/oauth2/v1/revoke" \
167
+ -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
168
+ -H "Content-Type: application/x-www-form-urlencoded" \
169
+ -d "token=eyJhbGciOiJSUzI1NiIs..."
170
+ ```
171
+
172
+ ## Session Authentication
173
+
174
+ For browser-based applications where the user is already logged into ZeyOS, session cookie authentication provides a seamless experience without requiring a separate OAuth flow.
175
+
176
+ ### How It Works
177
+
178
+ When a user is logged into ZeyOS in their browser, ZeyOS sets a session cookie (`ZEYOSID`). By including `credentials: 'include'` in fetch requests, the browser automatically sends this cookie, authenticating the request.
179
+
180
+ ### Client Configuration
181
+
182
+ ```js
183
+ const client = createZeyosClient({
184
+ platform: 'https://cloud.zeyos.com/demo',
185
+ auth: {
186
+ mode: 'session',
187
+ session: {
188
+ enabled: true,
189
+ credentials: 'include',
190
+ },
191
+ },
192
+ });
193
+ ```
194
+
195
+ ### Checking Session Status
196
+
197
+ You can verify whether the user has an active session by calling the `userinfo` endpoint:
198
+
199
+ ```js
200
+ const endpoint = 'https://cloud.zeyos.com/demo/oauth2/v1/userinfo';
201
+ const response = await fetch(endpoint, {
202
+ method: 'GET',
203
+ credentials: 'include',
204
+ headers: { 'Accept': 'application/json' },
205
+ });
206
+
207
+ if (response.ok) {
208
+ const userInfo = await response.json();
209
+ console.log('Logged in as:', userInfo.sub);
210
+ }
211
+ ```
212
+
213
+ :::info
214
+ Session authentication only works in browser environments where the user is on the same domain (or an allowed origin) as the ZeyOS instance. It will not work in Node.js or server-side contexts.
215
+ :::
216
+
217
+ :::warning
218
+ Do not embed `clientSecret` in shipped browser-only code. For browser apps, prefer session-cookie authentication or perform the OAuth code exchange and refresh on a backend that stores the client credentials safely.
219
+ :::
220
+
221
+ ## Security Schemes
222
+
223
+ The ZeyOS API supports three authentication schemes. Each API operation declares which schemes it accepts:
224
+
225
+ | Scheme | Type | Transport | Use Case |
226
+ |--------|------|-----------|----------|
227
+ | **Bearer** (OAuth2) | Token | `Authorization: Bearer {token}` | Server-side apps, SPAs, CLI tools |
228
+ | **Session** (Cookie) | Cookie | `Cookie: ZEYOSID={session_id}` | Browser apps where user is logged into ZeyOS |
229
+ | **Basic** (Client Credentials) | Header | `Authorization: Basic {base64}` | OAuth2 token endpoint requests |
230
+
231
+ Most API resource operations accept both **Bearer** and **Session** authentication. The OAuth2 token endpoints (`/token`, `/revoke`, `/introspect`) use **Basic** authentication with your client credentials.
232
+
233
+ The `@zeyos/client` library handles scheme selection automatically based on your configuration:
234
+
235
+ - `mode: 'auto'` (default) -- Tries bearer first if tokens are available, falls back to session.
236
+ - `mode: 'oauth'` -- Uses bearer tokens exclusively.
237
+ - `mode: 'session'` -- Uses session cookies exclusively.
238
+ - `mode: 'none'` -- No authentication (for public endpoints).
239
+
240
+ :::warning
241
+ Never expose your `client_secret` in client-side JavaScript. For browser-based SPAs, use the session authentication mode or implement a server-side proxy for the token exchange. Keep OAuth client credentials on your backend server where they cannot be inspected by end users.
242
+ :::
243
+
244
+ ## Token Management
245
+
246
+ The client library provides built-in token storage and management:
247
+
248
+ ```js
249
+ // Read the current token set
250
+ const tokenSet = await client.auth.getTokenSet();
251
+
252
+ // Manually set tokens (e.g., after loading from a database)
253
+ await client.auth.setTokenSet({
254
+ accessToken: 'new-access-token',
255
+ refreshToken: 'new-refresh-token',
256
+ expiresAt: Math.floor(Date.now() / 1000) + 3600,
257
+ });
258
+
259
+ // Clear all stored tokens (logout)
260
+ await client.auth.clearTokenSet();
261
+ ```
262
+
263
+ For custom persistence (e.g., storing tokens in a database or encrypted file), implement the `TokenStore` interface:
264
+
265
+ ```js
266
+ const customStore = {
267
+ async get() {
268
+ // Return the stored token set or null
269
+ return loadFromDatabase();
270
+ },
271
+ async set(tokenSet) {
272
+ // Persist the token set (or null to clear)
273
+ await saveToDatabase(tokenSet);
274
+ },
275
+ };
276
+
277
+ const client = createZeyosClient({
278
+ platform: 'https://cloud.zeyos.com/demo',
279
+ auth: {
280
+ oauth: {
281
+ tokenStore: customStore,
282
+ clientId: 'YOUR_CLIENT_ID',
283
+ clientSecret: 'YOUR_CLIENT_SECRET',
284
+ autoRefresh: true,
285
+ },
286
+ },
287
+ });
288
+ ```
@@ -0,0 +1,270 @@
1
+ ---
2
+ sidebar_label: Resources
3
+ ---
4
+
5
+ # Resources
6
+
7
+ The ZeyOS REST API exposes a comprehensive set of resources covering CRM, project management, ticketing, commerce, communication, and more. Each resource maps to a RESTful endpoint under the base URL and supports a consistent set of operations.
8
+
9
+ :::info API Surface vs. CLI Surface
10
+ This page documents the **full API surface** exposed by ZeyOS. The CLI intentionally supports a curated subset of common resources. For the CLI boundary and escalation path, see [CLI Coverage and Escalation](../04-agent-workflows/03-cli-coverage-and-escalation.md).
11
+ :::
12
+
13
+ ## Available Resources
14
+
15
+ The table below lists all available API resources and their supported operations.
16
+
17
+ | Resource | Endpoint | List | Get | Create | Update | Delete |
18
+ |----------|----------|:----:|:---:|:------:|:------:|:------:|
19
+ | Accounts | `/accounts` | Yes | Yes | Yes | Yes | Yes |
20
+ | ActionSteps | `/actionsteps` | Yes | Yes | Yes | Yes | Yes |
21
+ | Addresses | `/addresses` | Yes | Yes | Yes | Yes | Yes |
22
+ | Applications | `/applications` | Yes | Yes | -- | -- | -- |
23
+ | ApplicationAssets | `/applicationassets` | Yes | Yes | -- | -- | -- |
24
+ | Appointments | `/appointments` | Yes | Yes | Yes | Yes | Yes |
25
+ | Associations | `/associations` | Yes | Yes | Yes | Yes | Yes |
26
+ | BinFiles | `/binfiles` | Yes | -- | -- | -- | -- |
27
+ | Campaigns | `/campaigns` | Yes | Yes | Yes | Yes | Yes |
28
+ | Categories | `/categories` | Yes | Yes | Yes | Yes | Yes |
29
+ | Channels | `/channels` | Yes | Yes | Yes | Yes | Yes |
30
+ | Comments | `/comments` | Yes | Yes | Yes | Yes | Yes |
31
+ | Components | `/components` | Yes | Yes | Yes | Yes | Yes |
32
+ | Contacts | `/contacts` | Yes | Yes | Yes | Yes | Yes |
33
+ | ContactsToContacts | `/contactstocontacts` | Yes | Yes | Yes | Yes | Yes |
34
+ | Contracts | `/contracts` | Yes | Yes | Yes | Yes | Yes |
35
+ | Coupons | `/coupons` | Yes | Yes | Yes | Yes | Yes |
36
+ | CouponCodes | `/couponcodes` | Yes | Yes | Yes | Yes | Yes |
37
+ | CustomFields | `/customfields` | Yes | Yes | -- | -- | -- |
38
+ | DAVServers | `/davservers` | Yes | Yes | Yes | Yes | Yes |
39
+ | Devices | `/devices` | Yes | Yes | Yes | Yes | Yes |
40
+ | Documents | `/documents` | Yes | Yes | Yes | Yes | Yes |
41
+ | DunningNotices | `/dunningnotices` | Yes | Yes | Yes | Yes | Yes |
42
+ | DunningToTransactions | `/dunningtotransactions` | Yes | Yes | Yes | Yes | Yes |
43
+ | EntitiesToChannels | `/entitiestochannels` | Yes | Yes | Yes | Yes | Yes |
44
+ | Events | `/events` | Yes | Yes | Yes | Yes | Yes |
45
+ | FeedServers | `/feedservers` | Yes | Yes | Yes | Yes | Yes |
46
+ | Files | `/files` | Yes | Yes | Yes | Yes | Yes |
47
+ | Follows | `/follows` | Yes | Yes | Yes | Yes | Yes |
48
+ | Forks | `/forks` | Yes | Yes | -- | -- | -- |
49
+ | Groups | `/groups` | Yes | Yes | -- | -- | -- |
50
+ | GroupsToUsers | `/groupstousers` | Yes | Yes | -- | -- | -- |
51
+ | Invitations | `/invitations` | Yes | Yes | Yes | Yes | Yes |
52
+ | Items | `/items` | Yes | Yes | Yes | Yes | Yes |
53
+ | Ledgers | `/ledgers` | Yes | Yes | Yes | Yes | Yes |
54
+ | Likes | `/likes` | Yes | Yes | Yes | Yes | Yes |
55
+ | Links | `/links` | Yes | Yes | Yes | Yes | Yes |
56
+ | MailingLists | `/mailinglists` | Yes | Yes | Yes | Yes | Yes |
57
+ | MailingRecipients | `/mailingrecipients` | Yes | Yes | Yes | Yes | Yes |
58
+ | MailServers | `/mailservers` | Yes | Yes | Yes | Yes | Yes |
59
+ | Messages | `/messages` | Yes | Yes | Yes | Yes | Yes |
60
+ | MessageReads | `/messagereads` | Yes | Yes | Yes | Yes | Yes |
61
+ | Notes | `/notes` | Yes | Yes | Yes | Yes | Yes |
62
+ | Objects | `/objects` | Yes | Yes | Yes | Yes | Yes |
63
+ | Opportunities | `/opportunities` | Yes | Yes | Yes | Yes | Yes |
64
+ | Participants | `/participants` | Yes | Yes | Yes | Yes | Yes |
65
+ | Payments | `/payments` | Yes | Yes | Yes | Yes | Yes |
66
+ | Permissions | `/permissions` | Yes | Yes | -- | -- | -- |
67
+ | PriceLists | `/pricelists` | Yes | Yes | Yes | Yes | Yes |
68
+ | PriceListsToAccounts | `/priceliststoaccounts` | Yes | Yes | Yes | Yes | Yes |
69
+ | Prices | `/prices` | Yes | Yes | Yes | Yes | Yes |
70
+ | Projects | `/projects` | Yes | Yes | Yes | Yes | Yes |
71
+ | Records | `/records` | Yes | Yes | Yes | Yes | Yes |
72
+ | RelatedItems | `/relateditems` | Yes | Yes | Yes | Yes | Yes |
73
+ | Resources | `/resources` | Yes | Yes | -- | -- | -- |
74
+ | Services | `/services` | Yes | Yes | -- | -- | -- |
75
+ | StockTransactions | `/stocktransactions` | Yes | Yes | Yes | Yes | Yes |
76
+ | Storages | `/storages` | Yes | Yes | Yes | Yes | Yes |
77
+ | Suppliers | `/suppliers` | Yes | Yes | Yes | Yes | Yes |
78
+ | Tasks | `/tasks` | Yes | Yes | Yes | Yes | Yes |
79
+ | Tickets | `/tickets` | Yes | Yes | Yes | Yes | Yes |
80
+ | Transactions | `/transactions` | Yes | Yes | Yes | Yes | Yes |
81
+ | Users | `/users` | Yes | Yes | -- | -- | -- |
82
+ | Weblets | `/weblets` | Yes | Yes | -- | -- | -- |
83
+
84
+ ## Common Resources
85
+
86
+ The following resources are the most frequently used when building integrations with ZeyOS.
87
+
88
+ ### Tickets
89
+
90
+ Support and service tickets with status tracking, priority levels, due dates, and assignment to users. Tickets are the central work item in ZeyOS and can be linked to accounts, projects, contacts, and tasks.
91
+
92
+ ```js
93
+ // List open tickets sorted by priority
94
+ const tickets = await client.api.listTickets({
95
+ filters: { visibility: 0, status: 4 },
96
+ sort: ['-priority', '+duedate'],
97
+ limit: 50,
98
+ });
99
+
100
+ // Get a single ticket with extended data
101
+ const ticket = await client.api.getTicket({ ID: 12345, extdata: 1, tags: 1 });
102
+
103
+ // Create a new ticket
104
+ const newTicket = await client.api.createTicket({
105
+ name: 'Server maintenance required',
106
+ priority: 3,
107
+ status: 0,
108
+ });
109
+
110
+ // Update a ticket — flat spread form or explicit body key both work
111
+ await client.api.updateTicket({ ID: 12345, status: 4, priority: 4 });
112
+ // Equivalent using explicit body key:
113
+ // await client.api.updateTicket({ ID: 12345, body: { status: 4, priority: 4 } });
114
+ ```
115
+
116
+ ### Accounts
117
+
118
+ Customer and company records that serve as the primary organizational entity in the CRM. Accounts can have linked contacts, tickets, documents, and transactions.
119
+
120
+ ```js
121
+ const accounts = await client.api.listAccounts({
122
+ fields: ['ID', 'lastname', 'firstname'],
123
+ filters: { visibility: 0 },
124
+ sort: ['+lastname'],
125
+ limit: 100,
126
+ });
127
+ ```
128
+
129
+ ### Contacts
130
+
131
+ Individual people linked to accounts. Contacts store personal details such as name, email, phone, and address information.
132
+
133
+ ```js
134
+ const contacts = await client.api.listContacts({
135
+ fields: {
136
+ Id: 'ID',
137
+ Name: 'lastname',
138
+ Email: 'email',
139
+ Company: 'account.lastname',
140
+ },
141
+ filters: { visibility: 0 },
142
+ sort: ['+lastname'],
143
+ });
144
+ ```
145
+
146
+ ### Tasks
147
+
148
+ Actionable work items that can be linked to tickets, projects, or other entities. Tasks track completion status and can be assigned to users.
149
+
150
+ ```js
151
+ const tasks = await client.api.listTasks({
152
+ filters: { ticket: 12345, visibility: 0 },
153
+ sort: ['+name'],
154
+ limit: 200,
155
+ });
156
+ ```
157
+
158
+ ### Projects
159
+
160
+ Organizational groupings for tickets, tasks, and other work items. Projects provide a way to plan and track larger initiatives.
161
+
162
+ ```js
163
+ const projects = await client.api.listProjects({
164
+ fields: ['ID', 'name'],
165
+ filters: { visibility: 0 },
166
+ sort: ['+name'],
167
+ });
168
+ ```
169
+
170
+ ### Items
171
+
172
+ Products and services with pricing information. Items are referenced in documents (invoices, quotes) and can be linked to price lists, categories, and suppliers.
173
+
174
+ ```js
175
+ const items = await client.api.listItems({
176
+ fields: ['ID', 'name', 'price', 'unit'],
177
+ sort: ['+name'],
178
+ limit: 100,
179
+ });
180
+ ```
181
+
182
+ ### Documents
183
+
184
+ Business documents such as invoices, quotes, orders, and delivery notes. Documents are linked to accounts and contain line items referencing products/services.
185
+
186
+ ```js
187
+ const invoices = await client.api.listDocuments({
188
+ filters: { doctype: 'invoice', visibility: 0 },
189
+ sort: ['-date'],
190
+ limit: 25,
191
+ });
192
+ ```
193
+
194
+ ## Resource Naming
195
+
196
+ The API follows consistent naming conventions for endpoints and operations:
197
+
198
+ ### Endpoint Paths
199
+
200
+ Resource endpoints use **plural, lowercase** paths:
201
+
202
+ ```
203
+ /accounts
204
+ /tickets
205
+ /contacts
206
+ /documents
207
+ ```
208
+
209
+ Individual records are accessed by appending `/{ID}`:
210
+
211
+ ```
212
+ /accounts/{ID}
213
+ /tickets/{ID}
214
+ ```
215
+
216
+ ### Operation IDs
217
+
218
+ The JavaScript client uses camelCase operation IDs that follow a verb-noun pattern:
219
+
220
+ | Operation | Pattern | Example |
221
+ |-----------|---------|---------|
222
+ | List | `list{Resources}` | `listTickets`, `listAccounts` |
223
+ | Get | `get{Resource}` | `getTicket`, `getAccount` |
224
+ | Create | `create{Resource}` | `createTicket`, `createAccount` |
225
+ | Update | `update{Resource}` | `updateTicket`, `updateAccount` |
226
+ | Delete | `delete{Resource}` | `deleteTicket`, `deleteAccount` |
227
+ | Exists | `exists{Resource}` | `existsTicket`, `existsAccount` |
228
+
229
+ All operations are available as methods on the `client.api` object:
230
+
231
+ ```js
232
+ // List operations accept query parameters (fields, filter, sort, etc.)
233
+ const results = await client.api.listTickets({ limit: 10 });
234
+
235
+ // Get operations require an ID path parameter
236
+ const ticket = await client.api.getTicket({ ID: 123 });
237
+
238
+ // Create operations accept a request body
239
+ const created = await client.api.createTicket({ name: 'New ticket' });
240
+
241
+ // Update operations require an ID and changed fields (flat spread or explicit body key)
242
+ await client.api.updateTicket({ ID: 123, status: 4 });
243
+
244
+ // Delete operations require an ID
245
+ await client.api.deleteTicket({ ID: 123 });
246
+
247
+ // Exists operations return a boolean-like HEAD response
248
+ await client.api.existsTicket({ ID: 123 });
249
+ ```
250
+
251
+ :::info
252
+ The client library is auto-generated from the OpenAPI specification files located in the `/openapi/` directory of this project. The spec files (`api.json`, `oauth2.json`, `auth.json`) define every available resource, operation, parameter, and response schema. Run `npm run generate` to regenerate the client after modifying the spec files.
253
+ :::
254
+
255
+ ## HTTP Methods
256
+
257
+ The API uses the following HTTP methods, which may differ from typical REST conventions:
258
+
259
+ | Operation | HTTP Method | Description |
260
+ |-----------|-------------|-------------|
261
+ | List | `POST` | Retrieve a filtered list of records (body contains query parameters) |
262
+ | Get | `GET` | Retrieve a single record by ID |
263
+ | Create | `PUT` | Create a new record |
264
+ | Update | `PATCH` | Partially update an existing record |
265
+ | Delete | `DELETE` | Delete a record by ID |
266
+ | Exists | `HEAD` | Check if a record exists (returns no body) |
267
+
268
+ :::tip
269
+ Note that **list** operations use `POST` rather than `GET`. This is because the query language (filters, field selection, sorting) can produce request payloads that exceed URL length limits. Using `POST` allows complex queries to be sent reliably in the request body.
270
+ :::