|
| 1 | +--- |
| 2 | +title: Convex |
| 3 | +description: Use Convex database |
| 4 | +--- |
| 5 | + |
| 6 | +import { BlockInfoCard } from "@/components/ui/block-info-card" |
| 7 | + |
| 8 | +<BlockInfoCard |
| 9 | + type="convex" |
| 10 | + color="#FFFFFF" |
| 11 | +/> |
| 12 | + |
| 13 | +{/* MANUAL-CONTENT-START:intro */} |
| 14 | +[Convex](https://www.convex.dev/) is an open-source reactive backend platform that combines a document database, serverless functions, and real-time sync in one developer-friendly package. Instead of writing SQL, you define queries, mutations, and actions in TypeScript that run right next to your data, and every client subscribed to a query updates automatically when the underlying data changes. |
| 15 | + |
| 16 | +**Why Convex?** |
| 17 | + |
| 18 | +- **Functions as the API:** Queries (reads), mutations (transactional writes), and actions (side effects like calling external APIs) are the building blocks of your backend — typed, versioned, and deployed together. |
| 19 | +- **Reactive by default:** Query results update live as data changes, with no cache invalidation or polling logic to maintain. |
| 20 | +- **Transactional writes:** Mutations run as ACID transactions with serializable isolation, so your data stays consistent without manual locking. |
| 21 | +- **Built-in schema awareness:** Convex tracks the shape of every table, so tooling can introspect your data model without a separate migration system. |
| 22 | + |
| 23 | +**Using Convex in Sim** |
| 24 | + |
| 25 | +Sim's Convex integration connects your workflows to any Convex deployment with two fields: the deployment URL and a deploy key from the dashboard Settings page. From there you can: |
| 26 | + |
| 27 | +- **Run functions:** Call query, mutation, and action functions with named JSON arguments — or use Run Function when you don't want to specify the function type. |
| 28 | +- **Inspect your data model:** List Tables returns every table in the deployment with the JSON schema of its documents. |
| 29 | +- **Export and sync data:** List Documents pages through a consistent snapshot of a table, and Document Deltas returns only the documents that changed since a snapshot — including deletions — making incremental syncs to warehouses, search indexes, or other tools straightforward. |
| 30 | + |
| 31 | +Typical patterns include agents that read and write application data through your existing Convex functions, scheduled exports to analytics destinations, and change-driven automations that react to new or updated documents. |
| 32 | +{/* MANUAL-CONTENT-END */} |
| 33 | + |
| 34 | + |
| 35 | +## Usage Instructions |
| 36 | + |
| 37 | +Integrate Convex into the workflow. Run query, mutation, and action functions on your deployment, list tables with their schemas, and export documents with snapshot pagination and change deltas. |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +## Actions |
| 42 | + |
| 43 | +### `convex_query` |
| 44 | + |
| 45 | +Run a Convex query function and return its result |
| 46 | + |
| 47 | +#### Input |
| 48 | + |
| 49 | +| Parameter | Type | Required | Description | |
| 50 | +| --------- | ---- | -------- | ----------- | |
| 51 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 52 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 53 | +| `functionPath` | string | Yes | Path to the query function \(e.g., messages:list or folder/file:myQuery\) | |
| 54 | +| `args` | json | No | Named arguments to pass to the function as a JSON object | |
| 55 | + |
| 56 | +#### Output |
| 57 | + |
| 58 | +| Parameter | Type | Description | |
| 59 | +| --------- | ---- | ----------- | |
| 60 | +| `value` | json | Result returned by the query function | |
| 61 | +| `logLines` | array | Log lines printed during the function execution | |
| 62 | + |
| 63 | +### `convex_mutation` |
| 64 | + |
| 65 | +Run a Convex mutation function to write data and return its result |
| 66 | + |
| 67 | +#### Input |
| 68 | + |
| 69 | +| Parameter | Type | Required | Description | |
| 70 | +| --------- | ---- | -------- | ----------- | |
| 71 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 72 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 73 | +| `functionPath` | string | Yes | Path to the mutation function \(e.g., messages:send or folder/file:myMutation\) | |
| 74 | +| `args` | json | No | Named arguments to pass to the function as a JSON object | |
| 75 | + |
| 76 | +#### Output |
| 77 | + |
| 78 | +| Parameter | Type | Description | |
| 79 | +| --------- | ---- | ----------- | |
| 80 | +| `value` | json | Result returned by the mutation function | |
| 81 | +| `logLines` | array | Log lines printed during the function execution | |
| 82 | + |
| 83 | +### `convex_action` |
| 84 | + |
| 85 | +Run a Convex action function and return its result |
| 86 | + |
| 87 | +#### Input |
| 88 | + |
| 89 | +| Parameter | Type | Required | Description | |
| 90 | +| --------- | ---- | -------- | ----------- | |
| 91 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 92 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 93 | +| `functionPath` | string | Yes | Path to the action function \(e.g., emails:send or folder/file:myAction\) | |
| 94 | +| `args` | json | No | Named arguments to pass to the function as a JSON object | |
| 95 | + |
| 96 | +#### Output |
| 97 | + |
| 98 | +| Parameter | Type | Description | |
| 99 | +| --------- | ---- | ----------- | |
| 100 | +| `value` | json | Result returned by the action function | |
| 101 | +| `logLines` | array | Log lines printed during the function execution | |
| 102 | + |
| 103 | +### `convex_run_function` |
| 104 | + |
| 105 | +Run any Convex function (query, mutation, or action) by path without specifying its type |
| 106 | + |
| 107 | +#### Input |
| 108 | + |
| 109 | +| Parameter | Type | Required | Description | |
| 110 | +| --------- | ---- | -------- | ----------- | |
| 111 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 112 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 113 | +| `functionPath` | string | Yes | Path to the function \(e.g., messages:list or folder/file:myFunction\) | |
| 114 | +| `args` | json | No | Named arguments to pass to the function as a JSON object | |
| 115 | + |
| 116 | +#### Output |
| 117 | + |
| 118 | +| Parameter | Type | Description | |
| 119 | +| --------- | ---- | ----------- | |
| 120 | +| `value` | json | Result returned by the function | |
| 121 | +| `logLines` | array | Log lines printed during the function execution | |
| 122 | + |
| 123 | +### `convex_list_tables` |
| 124 | + |
| 125 | +List all tables in a Convex deployment along with their JSON schemas |
| 126 | + |
| 127 | +#### Input |
| 128 | + |
| 129 | +| Parameter | Type | Required | Description | |
| 130 | +| --------- | ---- | -------- | ----------- | |
| 131 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 132 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 133 | + |
| 134 | +#### Output |
| 135 | + |
| 136 | +| Parameter | Type | Description | |
| 137 | +| --------- | ---- | ----------- | |
| 138 | +| `tables` | array | Names of the tables in the deployment | |
| 139 | +| `schemas` | json | Map of table name to the JSON schema of its documents | |
| 140 | + |
| 141 | +### `convex_list_documents` |
| 142 | + |
| 143 | +List documents from a Convex table via a paginated snapshot. Pass the returned snapshot and cursor back in to fetch the next page. |
| 144 | + |
| 145 | +#### Input |
| 146 | + |
| 147 | +| Parameter | Type | Required | Description | |
| 148 | +| --------- | ---- | -------- | ----------- | |
| 149 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 150 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 151 | +| `tableName` | string | No | Table to list documents from. Omit to list documents from all tables. | |
| 152 | +| `snapshot` | string | No | Snapshot timestamp from a previous page. Omit on the first request to start a new snapshot. | |
| 153 | +| `cursor` | string | No | Pagination cursor from a previous page. Omit on the first request. | |
| 154 | + |
| 155 | +#### Output |
| 156 | + |
| 157 | +| Parameter | Type | Description | |
| 158 | +| --------- | ---- | ----------- | |
| 159 | +| `documents` | array | Documents in this page of the snapshot | |
| 160 | +| `hasMore` | boolean | Whether more pages remain in the snapshot | |
| 161 | +| `snapshot` | string | Snapshot timestamp to pass back in when fetching the next page | |
| 162 | +| `cursor` | string | Pagination cursor to pass back in when fetching the next page | |
| 163 | + |
| 164 | +### `convex_document_deltas` |
| 165 | + |
| 166 | +List documents that changed after a snapshot or previous delta cursor. Deleted documents are returned with a _deleted flag. |
| 167 | + |
| 168 | +#### Input |
| 169 | + |
| 170 | +| Parameter | Type | Required | Description | |
| 171 | +| --------- | ---- | -------- | ----------- | |
| 172 | +| `deploymentUrl` | string | Yes | Convex deployment URL \(e.g., https://your-deployment.convex.cloud\) | |
| 173 | +| `deployKey` | string | Yes | Convex deploy key from the dashboard Settings page | |
| 174 | +| `cursor` | string | Yes | Timestamp cursor to read deltas after. Use the snapshot value from List Documents or the cursor from a previous Document Deltas page. | |
| 175 | +| `tableName` | string | No | Table to read deltas from. Omit to read deltas from all tables. | |
| 176 | + |
| 177 | +#### Output |
| 178 | + |
| 179 | +| Parameter | Type | Description | |
| 180 | +| --------- | ---- | ----------- | |
| 181 | +| `documents` | array | Changed documents, each including _table and _ts fields | |
| 182 | +| `hasMore` | boolean | Whether more delta pages remain | |
| 183 | +| `cursor` | string | Cursor to pass back in when fetching the next page of deltas | |
| 184 | + |
| 185 | + |
0 commit comments