MotherDuck REST API
The REST API methods are in 'Preview' and may change in the future
To better support scenarios that require some flexibility or dynamic configuration around managing a MotherDuck organization we are exposing an OpenAPI endpoint with some new functionality. At the moment it enables limited management of users and tokens through HTTP without requiring a DuckDB + MotherDuck client to be running.
All of the methods are authenticated using a Read/Write token of a user with the Admin role within your MotherDuck Organization
and passing it through the Authorization header with a value of Bearer {TOKEN}.
You can use this REST API to programmatically manage service accounts, including their creation, token generation, and Duckling configuration. For a detailed walkthrough, see Create and configure service accounts.
If you would like to generate your own OpenAPI client the spec file is located at https://api.motherduck.com/docs/specs
Error responses
All endpoints return errors as JSON, with the matching HTTP status code. Validation failures (400) also include an issues array:
{
"message": "Username must start with an alphabetic character",
"code": "BAD_REQUEST",
"issues": [
{ "code": "invalid_string", "message": "Username must start with an alphabetic character", "path": ["username"] }
]
}
message— human-readable description of the error.code— stable error code:BAD_REQUEST,UNAUTHORIZED,FORBIDDEN,NOT_FOUND, orINTERNAL_SERVER_ERROR.issues— included only on400validation errors; one entry per field that failed validation, with acode,message, andpath.
Create a Dive embed session for a service account
Creates an embed session for the specified Dive using a service account. The username must be a service account username, not a user account.
Get active accounts
Get the active accounts in an organization, along with each account's running Ducklings (those in active or cooldown status). Requires 'Admin' role.
Get user Duckling configuration
Gets Duckling (instance) configuration for a service account or user account. Requires 'Admin' role.
Set user Duckling configuration
Sets Duckling (instance) configuration for a service account or user account. Requires 'Admin' role.
Create service account
Creates a service account with a 'Member' role. This endpoint does not create user accounts.
Create an access token for a user
Creates an access token for a service account or for your own user account. Requires an Admin token when creating service account tokens.
Invalidate a user access token
Invalidates an access token for a service account or user account. Use the token ID, not the token secret.
Delete a user
Permanently delete a user and all of their data. THIS CANNOT BE UNDONE
List a user's access tokens
Lists access token metadata for a service account or user account. Token secrets are not returned.