REST API Administration
Source Of Truth
- Prefer current MotherDuck REST API documentation, the public OpenAPI spec at
https://api.motherduck.com/docs/specs, or an explicit OpenAPI spec supplied by the user.
- For token scope and embed behavior, cross-check the REST API docs and the Embedded Dives docs because they include operational constraints not obvious from the raw schema.
- If the MotherDuck MCP
ask_docs_question feature is available, use it to check whether public REST API guidance has changed.
- Treat endpoint availability, preview status, token fields, and role requirements as current only when backed by the supplied spec or current docs.
Default Posture
- Treat the REST API as the control plane; SQL and data-plane queries go through a database connection, not the REST API.
- Use
https://api.motherduck.com as the base URL unless the user provides another environment.
- Authenticate with
Authorization: Bearer ${MOTHERDUCK_ADMIN_TOKEN} and keep admin read-write tokens in backend-managed secrets.
- Never use read-scaling tokens for REST API administration.
- Prefer read-before-write flows for configuration changes so the current account, service account, Duckling config, or Dive metadata is known before mutation.
- Treat
POST /v1/users as service-account creation unless current docs explicitly broaden the API.
- Assume active-account, Duckling configuration, service-account creation, service-account token creation, and Dive embed-session endpoints require an organization admin bearer token unless current docs say otherwise.
- Never expose generated access tokens in logs, browser code, client bundles, or committed files.
- Confirm destructive deletes with the user. Deleting a user permanently deletes that user and all of their data.
- Treat agent/account signup (
motherduck new or the public signup flow) as separate from the organization Admin REST API. Never create an account because an admin token is unavailable.
- For Dive embed sessions, keep
initial_state JSON-serializable and within the documented size limits; validate iframe state, navigation, and export messages in the host application.
Workflow
- Identify whether the task is service-account provisioning, token management, Duckling sizing, active-account inspection, or Dive embedding.
- Resolve the admin token from the existing environment and identify the target
username or dive_id; ask only when a required value cannot be discovered, and never invent production identifiers.
- Check token scope before calling token endpoints: users can create tokens for themselves, and admins can create tokens for service accounts, but admins cannot create tokens for other non-service-account members through the API.
- For Duckling config changes, read the current config first, then update both
read_write and read_scaling because the PUT payload requires both.
- Preserve response fields that are only returned once, especially newly created token strings and embed session strings.
- Surface API errors by status and response body; do not hide
400, 401, 403, 404, or 500 responses behind success-shaped fallbacks.
- When the MotherDuck MCP server is connected, prefer its admin tools over raw HTTP. Call
get_user_admin_guide first, or read the MCP column in references/REST_API_GUIDE.md.
For answer, review, or planning requests, inspect and report without mutating the control plane. For create or update requests, perform the requested in-scope operation and verify the response; retain confirmation for destructive deletes or broader administrative changes.
References
Read only the reference sections needed for the current task.
- Read
references/REST_API_GUIDE.md for endpoint summaries, MCP tool mapping, curl examples, validation limits, and operational gotchas.
Related Skills
Load related skills only for missing capabilities; reuse established context.
motherduck-query for SQL and data-plane query work
motherduck-connect for connection tokens and application connection posture
motherduck-security-governance for admin-token handling, service-account posture, and access-boundary questions
motherduck-create-dive for designing Dives before minting embed sessions
1---2name: motherduck-rest-api3description: Administer MotherDuck service accounts, tokens, Ducklings, and Dive embed sessions through the control-plane REST API.4license: MIT5---6
7# REST API Administration
8
9## Source Of Truth
10
11- Prefer current MotherDuck REST API documentation, the public OpenAPI spec at `https://api.motherduck.com/docs/specs`, or an explicit OpenAPI spec supplied by the user.
12- For token scope and embed behavior, cross-check the REST API docs and the Embedded Dives docs because they include operational constraints not obvious from the raw schema.
13- If the MotherDuck MCP `ask_docs_question` feature is available, use it to check whether public REST API guidance has changed.
14- Treat endpoint availability, preview status, token fields, and role requirements as current only when backed by the supplied spec or current docs.
15
16## Default Posture
17
18- Treat the REST API as the control plane; SQL and data-plane queries go through a database connection, not the REST API.
19- Use `https://api.motherduck.com` as the base URL unless the user provides another environment.
20- Authenticate with `Authorization: Bearer ${MOTHERDUCK_ADMIN_TOKEN}` and keep admin read-write tokens in backend-managed secrets.
21- Never use read-scaling tokens for REST API administration.
22- Prefer read-before-write flows for configuration changes so the current account, service account, Duckling config, or Dive metadata is known before mutation.
23- Treat `POST /v1/users` as service-account creation unless current docs explicitly broaden the API.
24- Assume active-account, Duckling configuration, service-account creation, service-account token creation, and Dive embed-session endpoints require an organization admin bearer token unless current docs say otherwise.
25- Never expose generated access tokens in logs, browser code, client bundles, or committed files.
26- Confirm destructive deletes with the user. Deleting a user permanently deletes that user and all of their data.
27- Treat agent/account signup (`motherduck new` or the public signup flow) as separate from the organization Admin REST API. Never create an account because an admin token is unavailable.
28- For Dive embed sessions, keep `initial_state` JSON-serializable and within the documented size limits; validate iframe state, navigation, and export messages in the host application.
29
30## Workflow
31
321. Identify whether the task is service-account provisioning, token management, Duckling sizing, active-account inspection, or Dive embedding.
332. Resolve the admin token from the existing environment and identify the target `username` or `dive_id`; ask only when a required value cannot be discovered, and never invent production identifiers.
343. Check token scope before calling token endpoints: users can create tokens for themselves, and admins can create tokens for service accounts, but admins cannot create tokens for other non-service-account members through the API.
354. For Duckling config changes, read the current config first, then update both `read_write` and `read_scaling` because the `PUT` payload requires both.
365. Preserve response fields that are only returned once, especially newly created token strings and embed session strings.
376. Surface API errors by status and response body; do not hide `400`, `401`, `403`, `404`, or `500` responses behind success-shaped fallbacks.
387. When the MotherDuck MCP server is connected, prefer its admin tools over raw HTTP. Call `get_user_admin_guide` first, or read the MCP column in `references/REST_API_GUIDE.md`.
39
40For answer, review, or planning requests, inspect and report without mutating the control plane. For create or update requests, perform the requested in-scope operation and verify the response; retain confirmation for destructive deletes or broader administrative changes.
41
42## References
43
44Read only the reference sections needed for the current task.
45
46- Read `references/REST_API_GUIDE.md` for endpoint summaries, MCP tool mapping, curl examples, validation limits, and operational gotchas.
47
48## Related Skills
49
50Load related skills only for missing capabilities; reuse established context.
51
52- `motherduck-query` for SQL and data-plane query work
53- `motherduck-connect` for connection tokens and application connection posture
54- `motherduck-security-governance` for admin-token handling, service-account posture, and access-boundary questions
55- `motherduck-create-dive` for designing Dives before minting embed sessions