Tables REST automation
Use the OAuth automation bridge to read and edit LeadMagic tables without an MCP client, with explicit operation batches, run quotes, idempotency, and workspace checks.
Use the typed LeadMagic Tables MCP tools when your client supports MCP. An agent or application without MCP can call the OAuth automation bridge instead. It dispatches allowlisted app routes as the authenticated user and retains workspace, role, plan, and feature checks.
The bridge is separate from the public enrichment API at api.leadmagic.io. Public API keys and X-API-Key do not authenticate it.
Request envelope
Every call is an HTTP POST to https://app.leadmagic.io/api/automation. The envelope's method selects the underlying operation:
Replace the example workspace and table IDs with your own. Keep the token in your application's credential storage, not in source code or a chat transcript.
| Field | Contract |
|---|---|
organizationId | Workspace ID. The authenticated user must currently be an admin or member of that workspace. |
method | GET, POST, PUT, PATCH, or DELETE, matching an allowlisted route. |
path | Relative /api/… path and optional query string, at most 2,000 characters. Absolute URLs and unsupported routes are refused. |
body | Optional object for the underlying route. Use an empty object or omit it for reads. |
The envelope is limited to 1 MB. Session cookies and caller-supplied identity headers are not a substitute for bearer authentication. Each request verifies the user's membership; the route then checks access to the target table.
Successful app routes normally return {"success": true, "data": ...}. Validation and dispatch errors can instead return an error string. Inspect the HTTP status and response body together rather than assuming every response uses one envelope.
Common table routes
The allowlist is broader than the typed MCP tools. The following routes cover common table tasks; availability and permissions still depend on the workspace. This table is not a promise that every app endpoint can be dispatched.
| Task | Underlying method and path |
|---|---|
| List or create tables | GET /api/sheets, POST /api/sheets |
| Read one table and columns | GET /api/sheets/:sheetId |
| Read, append, or delete rows | GET, POST, DELETE /api/sheets/:sheetId/rows |
| Batch edits and structural operations | POST /api/sheets/:sheetId/ops |
| Add, update, reorder, or delete columns | POST, PATCH, PUT, DELETE /api/sheets/:sheetId/columns |
| Configure a column action | POST /api/sheets/:sheetId/columns/:columnKey/action |
| Quote or start a run | POST /api/sheets/:sheetId/run-preview, POST /api/sheets/:sheetId/runs |
| List runs or read a run | GET /api/sheets/:sheetId/runs, GET …/runs/:runId |
| Inspect run rows | GET /api/sheets/:sheetId/runs/:runId/rows |
| Pause, resume, or cancel | POST …/runs/:runId/pause, POST …/runs/:runId/resume, POST …/runs/:runId/cancel |
| Table-wide statistics | GET /api/sheets/:sheetId/stats |
| Export table data | POST /api/sheets/:sheetId/export |
| Inspect or create push jobs | GET, POST /api/sheets/:sheetId/pushes |
| Describe a table recipe | POST /api/sheets/:sheetId/recipe |
| Import a recipe | POST /api/sheets/recipes/import |
For row reads, limit is at most 500. Unsorted pagination uses cursor; sorted reads can use offset. Search (q), a JSON filter tree (tree), and JSON sort rules select from the whole table before paging. Query values containing JSON must be URL-encoded. Filters use the group-root structure described in the MCP reference.
Attribute writes
On routes that require it, pass a clientId identifying your agent, such as agent:acme-research. The allowed namespaces are mcp:, cli:, and agent:, followed by 1–58 letters, digits, ., _, :, or -, with at most 64 characters overall. Do not use an app tab's identifier.
The hosted MCP supplies its identity automatically. Direct REST callers supply this field in the underlying write body. It lets the grid attribute changes and handle the write's live update correctly.
Edit cells and append rows
Send a body like this to POST /api/sheets/:sheetId/ops inside the automation envelope:
The row UUID is illustrative; generate a new UUID for each new row. Column keys must already exist on your table. REST operations use camel-case fields such as rowId and columnKey; typed MCP cell edits use row_id and column_key.
- A batch has up to 50 operations and up to 500 cell edits in total.
- A
rows.addoperation has up to 100 new rows. Row-ID operations have up to 10,000 IDs per operation. - Values are strings of at most 4,000 characters, with no NUL character. An empty string clears a cell; a row can carry at most 200 values.
- Every operation has an
opIdof 8–64 characters. Reuse the same ID and unchanged operation on retry so it is not applied twice. - Operations run in order, so later operations can address a row added earlier in the batch.
- Inspect each result's applied, skipped, or rejected outcome. A missing row or column can cause an edit to be skipped.
Other supported operations include column.add, column.patch, column.delete, column.restore, column.reorder, rows.delete, and rows.restore. Creating a column through raw operations uses a client-generated col_ key followed by eight hexadecimal characters. Use the higher-level column route if you want the server to create its key.
Quote and submit a run
Quote the selection
Quote the exact selection first through POST /api/sheets/:sheetId/run-preview:
The response includes eligible rows, maximum credits, a configuration hash, and skipped reasons. Show the scope and cost to the user before a run that needs approval. If pricing is unavailable, wait for a valid quote rather than substituting your own cost.
Submit with the quoted values
Dispatch POST /api/sheets/:sheetId/runs with the same selection and the actual quoted values:
The numbers are illustrative; copy the returned quote's numbers and hash. The hash must be 64 hexadecimal characters. A configuration or selection change needs a fresh preview and approval. idempotencyKey is required, 8–128 characters, and must be reused for retries of the same submission.
For selected rows, use scope: "selection" and rowIds. For a filter/search selection, use scope: "view" with scopeSpec: {"tree": ..., "q": ...}. Optional rowState narrows work to failed, insufficientCredits, noResult, or notRun; force: true deliberately repeats existing work. Keep those arguments identical between preview and submission.
REST submits a column run; it does not orchestrate the typed MCP tool's multi-column dependency pipeline. Wait for upstream values before submitting downstream columns. Use GET …/runs/:runId or the active run list to follow completion, no more frequently than every 15 seconds. Verify row outcomes and cell states after a run settles.
Permissions and external services
Run submission retains paid-plan, role, feature, and table-access checks. HTTP execution can contact a third-party provider and incur vendor costs even when LeadMagic credits are zero. Saved keys stay in the app's credential store; do not pass secrets through a chat transcript. Review destination hosts and row data, obtain the required user approval, and configure custom HTTP requests in the LeadMagic app. The hosted public MCP does not provide arbitrary HTTP request authoring or test tools.
The hosted public MCP and its Tables REST bridge reject recipes containing arbitrary HTTP requests or webhook sources. Configure integrations and manage webhook URLs in the LeadMagic app.
Limits and recovery
Rate limits apply per user across clients. Route-specific limits can be tighter than the bridge's default:
| Operation | Limit |
|---|---|
| Table reads | 600/minute, 10,000/hour |
| General changes | 60/minute |
| Cell-edit batches | 120/minute, 2,000/hour |
| Table creation | 10/minute, 40/hour, in addition to bridge checks |
| Run submissions | 10/minute, 60/hour, 300/day, in addition to bridge checks |
| HTTP status | Recovery |
|---|---|
400 | Fix the envelope, path, operation, or agent identifier. Read the error before retrying. |
401 | Supply a valid OAuth bearer token or sign in again. |
403 | Check membership and role for the target workspace, plus plan or feature access. |
404 | Check the route allowlist and target IDs; do not probe another workspace's tables. |
413 | Split the request below 1 MB and stay within operation limits. |
429 | Respect Retry-After when present, back off, and reuse operation/run IDs. |
503 | Retry with backoff; a pricing failure must be resolved before starting paid work. |
After a timeout, inspect existing run or operation results before creating another submission. Retain the original idempotency identifiers; generating new ones can duplicate work. Report completion only after the run and intended row results have been read back.
Was this page helpful?
We value your feedback.