@xano/developer-mcp 2.3.0-beta.1 → 2.3.0-beta.11

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 (51) hide show
  1. package/README.md +4 -14
  2. package/dist/cli_docs/index.js +0 -4
  3. package/dist/cli_docs/topics/function.js +0 -2
  4. package/dist/cli_docs/topics/knowledge.js +1 -2
  5. package/dist/cli_docs/topics/workspace.js +23 -12
  6. package/dist/meta_api_docs/format.js +15 -2
  7. package/dist/meta_api_docs/index.js +0 -2
  8. package/dist/meta_api_docs/topics/agent.js +36 -24
  9. package/dist/meta_api_docs/topics/api.js +50 -43
  10. package/dist/meta_api_docs/topics/apigroup.js +2 -2
  11. package/dist/meta_api_docs/topics/authentication.js +1 -1
  12. package/dist/meta_api_docs/topics/function.js +26 -25
  13. package/dist/meta_api_docs/topics/history.js +42 -11
  14. package/dist/meta_api_docs/topics/mcp_server.js +23 -28
  15. package/dist/meta_api_docs/topics/middleware.js +36 -32
  16. package/dist/meta_api_docs/topics/table.js +43 -22
  17. package/dist/meta_api_docs/topics/task.js +40 -40
  18. package/dist/meta_api_docs/topics/tool.js +39 -26
  19. package/dist/meta_api_docs/topics/workflows.js +84 -28
  20. package/dist/meta_api_docs/topics/workspace.js +1 -1
  21. package/dist/tools/validate_xanoscript.js +6 -9
  22. package/dist/xanoscript.js +0 -1
  23. package/dist/xanoscript_docs/README.md +25 -8
  24. package/dist/xanoscript_docs/agents.md +14 -5
  25. package/dist/xanoscript_docs/ai.md +820 -0
  26. package/dist/xanoscript_docs/branch.md +109 -29
  27. package/dist/xanoscript_docs/database.md +7 -5
  28. package/dist/xanoscript_docs/docs_index.json +36 -22
  29. package/dist/xanoscript_docs/essentials.md +53 -19
  30. package/dist/xanoscript_docs/file-uploads.md +4 -4
  31. package/dist/xanoscript_docs/mcp-servers.md +2 -2
  32. package/dist/xanoscript_docs/prompts.md +4 -2
  33. package/dist/xanoscript_docs/realtime-v2.md +4 -2
  34. package/dist/xanoscript_docs/resources.md +3 -1
  35. package/dist/xanoscript_docs/survival.md +1 -5
  36. package/dist/xanoscript_docs/tables.md +58 -0
  37. package/dist/xanoscript_docs/tools.md +1 -1
  38. package/dist/xanoscript_docs/triggers.md +133 -3
  39. package/dist/xanoscript_docs/types.md +14 -1
  40. package/dist/xanoscript_docs/unit-testing.md +29 -2
  41. package/dist/xanoscript_docs/version.json +2 -2
  42. package/dist/xanoscript_docs/workflow-tests.md +18 -0
  43. package/dist/xanoscript_docs/working.md +39 -15
  44. package/package.json +2 -3
  45. package/dist/cli_docs/topics/policy.d.ts +0 -2
  46. package/dist/cli_docs/topics/policy.js +0 -91
  47. package/dist/cli_docs/topics/skills.d.ts +0 -2
  48. package/dist/cli_docs/topics/skills.js +0 -57
  49. package/dist/meta_api_docs/topics/policy.d.ts +0 -3
  50. package/dist/meta_api_docs/topics/policy.js +0 -135
  51. package/dist/xanoscript_docs/policies.md +0 -308
@@ -63,35 +63,24 @@ Functions can cache results based on:
63
63
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
64
64
  ],
65
65
  request_body: {
66
- type: "application/json",
67
- properties: {
68
- name: { type: "string", description: "Function name", required: true },
69
- description: { type: "string", description: "Function description" },
70
- xanoscript: { type: "string", description: "XanoScript function definition", required: true }
71
- }
66
+ type: "text/x-xanoscript",
67
+ description: "The function as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`. Its name, description, inputs and response come from the script. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request creates the function without its code."
72
68
  },
73
69
  example: {
74
70
  method: "POST",
75
71
  path: "/workspace/1/function",
76
- body: {
77
- name: "calculate_total",
78
- description: "Calculate order total with tax",
79
- xanoscript: `function calculate_total {
72
+ headers: { "Content-Type": "text/x-xanoscript" },
73
+ body: `function "calculate_total" {
74
+ description = "Order total for a quantity at a unit price"
80
75
  input {
81
- decimal subtotal
82
- decimal tax_rate = 0.08
76
+ int quantity filters=min:0
77
+ decimal price filters=min:0
83
78
  }
84
79
  stack {
85
- var $tax {
86
- value = $input.subtotal * $input.tax_rate
87
- }
88
- var $total {
89
- value = $input.subtotal + $tax
90
- }
80
+ var $total { value = $input.quantity * $input.price }
91
81
  }
92
82
  response = $total
93
83
  }`
94
- }
95
84
  }
96
85
  },
97
86
  {
@@ -105,12 +94,24 @@ Functions can cache results based on:
105
94
  { name: "publish", type: "boolean", default: true, description: "Publish changes immediately (false saves as draft)" }
106
95
  ],
107
96
  request_body: {
108
- type: "application/json",
109
- properties: {
110
- name: { type: "string", description: "Function name" },
111
- description: { type: "string", description: "Function description" },
112
- xanoscript: { type: "string", description: "XanoScript function definition" }
113
- }
97
+ type: "text/x-xanoscript",
98
+ description: "The whole function as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`; it replaces the current definition. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request never changes the function's code."
99
+ },
100
+ example: {
101
+ method: "PUT",
102
+ path: "/workspace/1/function/12",
103
+ headers: { "Content-Type": "text/x-xanoscript" },
104
+ body: `function "calculate_total" {
105
+ description = "Order total for a quantity at a unit price"
106
+ input {
107
+ int quantity filters=min:0
108
+ decimal price filters=min:0
109
+ }
110
+ stack {
111
+ var $total { value = $input.quantity * $input.price }
112
+ }
113
+ response = $total
114
+ }`
114
115
  }
115
116
  },
116
117
  {
@@ -9,6 +9,8 @@ export const historyDoc = {
9
9
  - **Task History**: Scheduled task execution logs
10
10
  - **Middleware History**: Middleware execution logs
11
11
  - **Tool History**: Agent tool execution logs
12
+ - **Prompt History**: MCP prompt request logs
13
+ - **Resource History**: MCP resource request logs
12
14
  - **Trigger History**: Event trigger execution logs
13
15
 
14
16
  ## Common Use Cases
@@ -20,13 +22,13 @@ export const historyDoc = {
20
22
  ai_hints: `- Use request history to debug API issues
21
23
  - Filter by status to find errors (4xx, 5xx)
22
24
  - Use branch filter to separate dev/prod logs
23
- - Include payload for full request/response data
25
+ - Pass include_output=true for each request's output; the input is always returned
24
26
  - History is limited to recent requests (not permanent storage)`,
25
27
  endpoints: [
26
28
  {
27
29
  method: "GET",
28
30
  path: "/workspace/{workspace_id}/request_history",
29
- tool_name: "getRequestHistory",
31
+ tool_name: "getApiRequestHistory",
30
32
  description: "Get API request history with pagination.",
31
33
  parameters: [
32
34
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -34,13 +36,13 @@ export const historyDoc = {
34
36
  { name: "per_page", type: "integer", default: 50, description: "Items per page (max 500)" },
35
37
  { name: "branch", type: "string", description: "Filter by branch name" },
36
38
  { name: "api_id", type: "integer", description: "Filter by API endpoint ID" },
37
- { name: "include_payload", type: "boolean", default: false, description: "Include request/response payloads" }
39
+ { name: "include_output", type: "boolean", default: false, description: "Include each request's output (response); the input is always returned" }
38
40
  ]
39
41
  },
40
42
  {
41
43
  method: "POST",
42
44
  path: "/workspace/{workspace_id}/request_history/search",
43
- tool_name: "searchRequestHistory",
45
+ tool_name: "searchApiRequestHistory",
44
46
  description: "Search request history with advanced filters.",
45
47
  parameters: [
46
48
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
@@ -53,14 +55,15 @@ export const historyDoc = {
53
55
  status: { type: "array", description: "Filter by status codes (e.g., [200, 201])" },
54
56
  verb: { type: "array", description: "Filter by HTTP methods (e.g., ['GET', 'POST'])" },
55
57
  from_date: { type: "string", description: "Start date (ISO format)" },
56
- to_date: { type: "string", description: "End date (ISO format)" }
58
+ to_date: { type: "string", description: "End date (ISO format)" },
59
+ include_output: { type: "boolean", description: "Include each request's output (response); the input is always returned" }
57
60
  }
58
61
  }
59
62
  },
60
63
  {
61
64
  method: "GET",
62
65
  path: "/workspace/{workspace_id}/function_history",
63
- tool_name: "getFunctionHistory",
66
+ tool_name: "getFunctionRequestHistory",
64
67
  description: "Get function execution history.",
65
68
  parameters: [
66
69
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -72,7 +75,7 @@ export const historyDoc = {
72
75
  {
73
76
  method: "GET",
74
77
  path: "/workspace/{workspace_id}/task_history",
75
- tool_name: "getTaskHistory",
78
+ tool_name: "getTaskRequestHistory",
76
79
  description: "Get scheduled task execution history.",
77
80
  parameters: [
78
81
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -84,7 +87,7 @@ export const historyDoc = {
84
87
  {
85
88
  method: "GET",
86
89
  path: "/workspace/{workspace_id}/middleware_history",
87
- tool_name: "getMiddlewareHistory",
90
+ tool_name: "getMiddlewareRequestHistory",
88
91
  description: "Get middleware execution history.",
89
92
  parameters: [
90
93
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -96,7 +99,7 @@ export const historyDoc = {
96
99
  {
97
100
  method: "GET",
98
101
  path: "/workspace/{workspace_id}/tool_history",
99
- tool_name: "getToolHistory",
102
+ tool_name: "getToolRequestHistory",
100
103
  description: "Get agent tool execution history.",
101
104
  parameters: [
102
105
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -105,10 +108,38 @@ export const historyDoc = {
105
108
  { name: "per_page", type: "integer", default: 50, description: "Items per page" }
106
109
  ]
107
110
  },
111
+ {
112
+ method: "GET",
113
+ path: "/workspace/{workspace_id}/prompt_history",
114
+ tool_name: "getPromptRequestHistory",
115
+ description: "Get MCP prompt request history, newest first.",
116
+ parameters: [
117
+ { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
118
+ { name: "prompt_id", type: "integer", description: "Filter by MCP prompt ID" },
119
+ { name: "branch", type: "string", description: "Filter by branch name" },
120
+ { name: "page", type: "integer", default: 1, description: "Page number" },
121
+ { name: "per_page", type: "integer", default: 50, description: "Items per page (max 500)" },
122
+ { name: "include_output", type: "boolean", default: false, description: "Include each request's output" }
123
+ ]
124
+ },
125
+ {
126
+ method: "GET",
127
+ path: "/workspace/{workspace_id}/resource_history",
128
+ tool_name: "getResourceRequestHistory",
129
+ description: "Get MCP resource request history, newest first.",
130
+ parameters: [
131
+ { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
132
+ { name: "resource_id", type: "integer", description: "Filter by MCP resource ID" },
133
+ { name: "branch", type: "string", description: "Filter by branch name" },
134
+ { name: "page", type: "integer", default: 1, description: "Page number" },
135
+ { name: "per_page", type: "integer", default: 50, description: "Items per page (max 500)" },
136
+ { name: "include_output", type: "boolean", default: false, description: "Include each request's output" }
137
+ ]
138
+ },
108
139
  {
109
140
  method: "GET",
110
141
  path: "/workspace/{workspace_id}/trigger_history",
111
- tool_name: "getTriggerHistory",
142
+ tool_name: "getTriggerRequestHistory",
112
143
  description: "Get trigger execution history.",
113
144
  parameters: [
114
145
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -145,5 +176,5 @@ export const historyDoc = {
145
176
  }
146
177
  }
147
178
  },
148
- related_topics: ["api", "function", "task"]
179
+ related_topics: ["api", "function", "task", "prompt", "resource"]
149
180
  };
@@ -28,7 +28,7 @@ export const mcpServerDoc = {
28
28
  {
29
29
  method: "GET",
30
30
  path: "/workspace/{workspace_id}/mcp_server",
31
- tool_name: "listMcpServers",
31
+ tool_name: "listMCPServers",
32
32
  description: "List all MCP servers in a workspace.",
33
33
  parameters: [
34
34
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -41,7 +41,7 @@ export const mcpServerDoc = {
41
41
  {
42
42
  method: "GET",
43
43
  path: "/workspace/{workspace_id}/mcp_server/{mcp_server_id}",
44
- tool_name: "getMcpServer",
44
+ tool_name: "getMCPServer",
45
45
  description: "Get details of a specific MCP server.",
46
46
  parameters: [
47
47
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -52,57 +52,52 @@ export const mcpServerDoc = {
52
52
  {
53
53
  method: "POST",
54
54
  path: "/workspace/{workspace_id}/mcp_server",
55
- tool_name: "createMcpServer",
55
+ tool_name: "createMCPServer",
56
56
  description: "Create a new MCP server to expose tools.",
57
57
  parameters: [
58
58
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
59
59
  ],
60
60
  request_body: {
61
- type: "application/json",
62
- properties: {
63
- name: { type: "string", description: "MCP server name", required: true },
64
- description: { type: "string", description: "MCP server description" },
65
- xanoscript: { type: "string", description: "XanoScript MCP server definition", required: true }
66
- }
61
+ type: "text/x-xanoscript",
62
+ description: "The MCP server as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`. Its name and the tools, prompts and resources it exposes come from the script. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request creates the MCP server without its code."
67
63
  },
68
64
  example: {
69
65
  method: "POST",
70
66
  path: "/workspace/1/mcp_server",
71
- body: {
72
- name: "my_tools",
73
- description: "MCP server exposing customer support tools",
74
- xanoscript: `mcp_server my_tools {
75
- tools = [lookup_order, update_ticket, send_notification]
76
- authentication {
77
- type = "bearer"
78
- token = env.MCP_TOKEN
79
- }
67
+ headers: { "Content-Type": "text/x-xanoscript" },
68
+ body: `mcp_server "Orders" {
69
+ canonical = "orders-mcp"
70
+ tools = [{ name: "get_order_status" }]
80
71
  }`
81
- }
82
72
  }
83
73
  },
84
74
  {
85
75
  method: "PUT",
86
76
  path: "/workspace/{workspace_id}/mcp_server/{mcp_server_id}",
87
- tool_name: "updateMcpServer",
77
+ tool_name: "updateMCPServer",
88
78
  description: "Update an existing MCP server.",
89
79
  parameters: [
90
80
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
91
81
  { name: "mcp_server_id", type: "integer", required: true, in: "path", description: "MCP Server ID" }
92
82
  ],
93
83
  request_body: {
94
- type: "application/json",
95
- properties: {
96
- name: { type: "string", description: "MCP server name" },
97
- description: { type: "string", description: "MCP server description" },
98
- xanoscript: { type: "string", description: "XanoScript MCP server definition" }
99
- }
84
+ type: "text/x-xanoscript",
85
+ description: "The whole MCP server as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`; it replaces the current definition. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request never changes the MCP server's code."
86
+ },
87
+ example: {
88
+ method: "PUT",
89
+ path: "/workspace/1/mcp_server/1",
90
+ headers: { "Content-Type": "text/x-xanoscript" },
91
+ body: `mcp_server "Orders" {
92
+ canonical = "orders-mcp"
93
+ tools = [{ name: "get_order_status" }]
94
+ }`
100
95
  }
101
96
  },
102
97
  {
103
98
  method: "DELETE",
104
99
  path: "/workspace/{workspace_id}/mcp_server/{mcp_server_id}",
105
- tool_name: "deleteMcpServer",
100
+ tool_name: "deleteMCPServer",
106
101
  description: "Delete an MCP server.",
107
102
  parameters: [
108
103
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -112,7 +107,7 @@ export const mcpServerDoc = {
112
107
  {
113
108
  method: "GET",
114
109
  path: "/mcp_server/documentation",
115
- tool_name: "getMcpDocumentation",
110
+ tool_name: "documentation",
116
111
  description: "Get MCP documentation for setup and syntax reference.",
117
112
  parameters: [
118
113
  { name: "type", type: "string", enum: ["start", "api", "function", "task", "mcp", "agent", "tool", "fs-syntax", "table", "database"], description: "Documentation type to retrieve" }
@@ -26,7 +26,7 @@ export const middlewareDoc = {
26
26
  {
27
27
  method: "GET",
28
28
  path: "/workspace/{workspace_id}/middleware",
29
- tool_name: "listMiddlewares",
29
+ tool_name: "listmiddlewares",
30
30
  description: "List all middleware in a workspace.",
31
31
  parameters: [
32
32
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -58,38 +58,27 @@ export const middlewareDoc = {
58
58
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
59
59
  ],
60
60
  request_body: {
61
- type: "application/json",
62
- properties: {
63
- name: { type: "string", description: "Middleware name", required: true },
64
- description: { type: "string", description: "Middleware description" },
65
- type: { type: "string", description: "pre or post", required: true },
66
- xanoscript: { type: "string", description: "XanoScript middleware definition", required: true }
67
- }
61
+ type: "text/x-xanoscript",
62
+ description: "The middleware as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`. Its name, policies, inputs and response come from the script. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request creates the middleware without its code."
68
63
  },
69
64
  example: {
70
65
  method: "POST",
71
66
  path: "/workspace/1/middleware",
72
- body: {
73
- name: "rate_limiter",
74
- description: "Limit requests to 100 per minute per IP",
75
- type: "pre",
76
- xanoscript: `middleware rate_limiter {
77
- stack {
78
- var $key {
79
- value = "ratelimit:" + $request.ip
80
- }
81
- var $count {
82
- value = redis.incr($key)
83
- }
84
- if ($count == 1) {
85
- redis.expire($key, 60)
86
- }
87
- if ($count > 100) {
88
- throw(429, "Rate limit exceeded")
67
+ headers: { "Content-Type": "text/x-xanoscript" },
68
+ body: `middleware "wrap_response" {
69
+ exception_policy = "rethrow"
70
+ response_strategy = "replace"
71
+ input {
72
+ json vars
73
+ enum type {
74
+ values = ["pre", "post"]
89
75
  }
90
76
  }
77
+ stack {
78
+ var $payload { value = $input.vars.result }
79
+ }
80
+ response = {success: true, payload: $payload}
91
81
  }`
92
- }
93
82
  }
94
83
  },
95
84
  {
@@ -103,12 +92,27 @@ export const middlewareDoc = {
103
92
  { name: "publish", type: "boolean", default: true, description: "Publish changes immediately" }
104
93
  ],
105
94
  request_body: {
106
- type: "application/json",
107
- properties: {
108
- name: { type: "string", description: "Middleware name" },
109
- description: { type: "string", description: "Middleware description" },
110
- xanoscript: { type: "string", description: "XanoScript middleware definition" }
111
- }
95
+ type: "text/x-xanoscript",
96
+ description: "The whole middleware as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`; it replaces the current definition. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request never changes the middleware's code."
97
+ },
98
+ example: {
99
+ method: "PUT",
100
+ path: "/workspace/1/middleware/3",
101
+ headers: { "Content-Type": "text/x-xanoscript" },
102
+ body: `middleware "wrap_response" {
103
+ exception_policy = "rethrow"
104
+ response_strategy = "replace"
105
+ input {
106
+ json vars
107
+ enum type {
108
+ values = ["pre", "post"]
109
+ }
110
+ }
111
+ stack {
112
+ var $payload { value = $input.vars.result }
113
+ }
114
+ response = {success: true, payload: $payload}
115
+ }`
112
116
  }
113
117
  },
114
118
  {
@@ -26,7 +26,7 @@ export const tableDoc = {
26
26
  {
27
27
  method: "GET",
28
28
  path: "/workspace/{workspace_id}/table",
29
- tool_name: "listTables",
29
+ tool_name: "getTables",
30
30
  description: "List all database tables in a workspace.",
31
31
  parameters: [
32
32
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
@@ -53,31 +53,35 @@ export const tableDoc = {
53
53
  {
54
54
  method: "POST",
55
55
  path: "/workspace/{workspace_id}/table",
56
- tool_name: "createTable",
56
+ tool_name: "addTable",
57
57
  description: "Create a new database table with optional schema.",
58
58
  parameters: [
59
59
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
60
60
  ],
61
61
  request_body: {
62
- type: "application/json",
63
- properties: {
64
- name: { type: "string", description: "Table name", required: true },
65
- description: { type: "string", description: "Table description" },
66
- xanoscript: { type: "string", description: "XanoScript table definition with schema" }
67
- }
62
+ type: "text/x-xanoscript",
63
+ description: "The table as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`. Its name, schema and indexes come from the script. To start from an empty table instead, send JSON `{\"name\": \"...\"}` and add fields with the schema endpoints below. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request creates the table without the schema in it."
68
64
  },
69
65
  example: {
70
66
  method: "POST",
71
67
  path: "/workspace/1/table",
72
- body: {
73
- name: "users",
74
- xanoscript: `table users {
75
- id int [pk, auto]
76
- email text [unique]
77
- name text
78
- created_at timestamp [default:now]
68
+ headers: { "Content-Type": "text/x-xanoscript" },
69
+ body: `table "user" {
70
+ auth = true
71
+ schema {
72
+ int id
73
+ timestamp created_at?=now
74
+ text name filters=trim
75
+ email email filters=trim|lower {
76
+ sensitive = true
77
+ }
78
+ password password
79
+ }
80
+ index = [
81
+ {type: "primary", field: [{name: "id"}]}
82
+ {type: "btree|unique", field: [{name: "email"}]}
83
+ ]
79
84
  }`
80
- }
81
85
  }
82
86
  },
83
87
  {
@@ -90,12 +94,29 @@ export const tableDoc = {
90
94
  { name: "table_id", type: "integer", required: true, in: "path", description: "Table ID" }
91
95
  ],
92
96
  request_body: {
93
- type: "application/json",
94
- properties: {
95
- name: { type: "string", description: "Table name" },
96
- description: { type: "string", description: "Table description" },
97
- xanoscript: { type: "string", description: "Updated XanoScript definition" }
98
- }
97
+ type: "text/x-xanoscript",
98
+ description: "The whole table as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`; it replaces the current definition. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request never changes the table's schema."
99
+ },
100
+ example: {
101
+ method: "PUT",
102
+ path: "/workspace/1/table/3",
103
+ headers: { "Content-Type": "text/x-xanoscript" },
104
+ body: `table "user" {
105
+ auth = true
106
+ schema {
107
+ int id
108
+ timestamp created_at?=now
109
+ text name filters=trim
110
+ email email filters=trim|lower {
111
+ sensitive = true
112
+ }
113
+ password password
114
+ }
115
+ index = [
116
+ {type: "primary", field: [{name: "id"}]}
117
+ {type: "btree|unique", field: [{name: "email"}]}
118
+ ]
119
+ }`
99
120
  }
100
121
  },
101
122
  {
@@ -1,10 +1,10 @@
1
1
  export const taskDoc = {
2
2
  topic: "task",
3
3
  title: "Scheduled Task Management",
4
- description: `Tasks are scheduled jobs that run automatically based on a cron schedule. They're used for background processing, periodic data sync, automated maintenance, and more.
4
+ description: `Tasks are scheduled jobs that run automatically on a schedule: a start time and a repeat frequency in seconds, written in the task's XanoScript. They're used for background processing, periodic data sync, automated maintenance, and more.
5
5
 
6
6
  ## Key Concepts
7
- - Tasks run on a schedule (cron syntax)
7
+ - Tasks run on the schedule in their XanoScript: \`schedule = [{starts_on: 2026-01-01 03:00:00+0000, freq: 86400}]\` (freq in seconds; add \`ends_on\` to stop; several entries for several times)
8
8
  - No HTTP trigger - runs automatically
9
9
  - Can access databases, call functions, make external requests
10
10
  - Support draft/publish workflow
@@ -17,7 +17,9 @@ export const taskDoc = {
17
17
  - Notification sending
18
18
  - Cache warming`,
19
19
  ai_hints: `- Tasks require paid account (will fail on free tier)
20
- - Use cron syntax for scheduling (e.g., "0 * * * *" for hourly)
20
+ - Create and update a task by sending its XanoScript as the raw body with \`Content-Type: text/x-xanoscript\`. The schedule, the \`active\` flag and the stack all live in the script; there is no cron field
21
+ - A JSON body with a \`xanoscript\` field creates a task with no stack and no schedule (the field is dropped silently), so it never runs
22
+ - Schedule frequency is in seconds: 3600 hourly, 86400 daily, 604800 weekly
21
23
  - Tasks have no HTTP inputs - all data comes from database or environment
22
24
  - Draft changes won't affect running schedule until published
23
25
  - Check task history to debug execution issues`,
@@ -60,34 +62,23 @@ export const taskDoc = {
60
62
  { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
61
63
  ],
62
64
  request_body: {
63
- type: "application/json",
64
- properties: {
65
- name: { type: "string", description: "Task name", required: true },
66
- description: { type: "string", description: "Task description" },
67
- schedule: { type: "string", description: "Cron expression (e.g., '0 * * * *' for hourly)", required: true },
68
- active: { type: "boolean", description: "Whether task is active", required: true },
69
- xanoscript: { type: "string", description: "XanoScript task definition", required: true }
70
- }
65
+ type: "text/x-xanoscript",
66
+ description: "The task as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`. Its name, description, `active` flag and schedule (`schedule = [{starts_on, freq}]`, freq in seconds) come from the script. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request creates the task without its code."
71
67
  },
72
68
  example: {
73
69
  method: "POST",
74
70
  path: "/workspace/1/task",
75
- body: {
76
- name: "cleanup_old_sessions",
77
- description: "Delete sessions older than 30 days",
78
- schedule: "0 3 * * *",
79
- active: true,
80
- xanoscript: `task cleanup_old_sessions {
71
+ headers: { "Content-Type": "text/x-xanoscript" },
72
+ body: `task "cleanup_old_sessions" {
73
+ description = "Delete sessions older than 30 days, daily at 03:00 UTC"
81
74
  stack {
82
- var $cutoff {
83
- value = now|transform_timestamp:"-30 days"
84
- }
85
- db.bulk.delete "sessions" {
86
- where = $db.sessions.created_at < $cutoff
87
- } as $deleted_count
75
+ var $cutoff { value = now|transform_timestamp:"-30 days" }
76
+ db.bulk.delete "session" {
77
+ where = $db.session.created_at < $cutoff
78
+ } as $deleted
88
79
  }
80
+ schedule = [{starts_on: 2026-01-01 03:00:00+0000, freq: 86400}]
89
81
  }`
90
- }
91
82
  }
92
83
  },
93
84
  {
@@ -101,14 +92,24 @@ export const taskDoc = {
101
92
  { name: "publish", type: "boolean", default: true, description: "Publish changes immediately" }
102
93
  ],
103
94
  request_body: {
104
- type: "application/json",
105
- properties: {
106
- name: { type: "string", description: "Task name" },
107
- description: { type: "string", description: "Task description" },
108
- schedule: { type: "string", description: "Cron expression" },
109
- active: { type: "boolean", description: "Whether task is active" },
110
- xanoscript: { type: "string", description: "XanoScript task definition" }
111
- }
95
+ type: "text/x-xanoscript",
96
+ description: "The whole task as XanoScript, sent as the raw request body with `Content-Type: text/x-xanoscript`; it replaces the current definition. A JSON body's `xanoscript` field is not read: the route drops fields it does not declare, so a JSON request never changes the task's code."
97
+ },
98
+ example: {
99
+ method: "PUT",
100
+ path: "/workspace/1/task/4",
101
+ headers: { "Content-Type": "text/x-xanoscript" },
102
+ body: `task "cleanup_old_sessions" {
103
+ description = "Delete sessions older than 30 days, every 6 hours, paused"
104
+ active = false
105
+ stack {
106
+ var $cutoff { value = now|transform_timestamp:"-30 days" }
107
+ db.bulk.delete "session" {
108
+ where = $db.session.created_at < $cutoff
109
+ } as $deleted
110
+ }
111
+ schedule = [{starts_on: 2026-01-01 00:00:00+0000, freq: 21600}]
112
+ }`
112
113
  }
113
114
  },
114
115
  {
@@ -145,20 +146,19 @@ export const taskDoc = {
145
146
  id: { type: "integer" },
146
147
  name: { type: "string" },
147
148
  description: { type: "string" },
148
- schedule: { type: "string", description: "Cron expression" },
149
+ datasource: { type: "string" },
149
150
  active: { type: "boolean" },
150
151
  xanoscript: { type: "string" },
151
152
  created_at: { type: "string", format: "date-time" },
152
153
  updated_at: { type: "string", format: "date-time" }
153
154
  }
154
155
  },
155
- CronExamples: {
156
- "every_minute": "* * * * *",
157
- "every_hour": "0 * * * *",
158
- "every_day_midnight": "0 0 * * *",
159
- "every_day_3am": "0 3 * * *",
160
- "every_monday": "0 0 * * 1",
161
- "first_of_month": "0 0 1 * *"
156
+ ScheduleExamples: {
157
+ "hourly": "schedule = [{starts_on: 2026-01-01 00:00:00+0000, freq: 3600}]",
158
+ "daily_3am_utc": "schedule = [{starts_on: 2026-01-01 03:00:00+0000, freq: 86400}]",
159
+ "weekly_monday": "schedule = [{starts_on: 2026-01-05 00:00:00+0000, freq: 604800}]",
160
+ "twice_daily": "schedule = [{starts_on: 2026-01-01 09:00:00+0000, freq: 86400}, {starts_on: 2026-01-01 21:00:00+0000, freq: 86400}]",
161
+ "until_year_end": "schedule = [{starts_on: 2026-01-01 08:00:00+0000, freq: 3600, ends_on: 2026-12-31 23:59:59+0000}]"
162
162
  }
163
163
  },
164
164
  related_topics: ["function", "history"]