Skip to main content

Create and configure service accounts

A service account is a non-human user identity for workloads that need to connect to MotherDuck without using a person's credentials. Use service accounts for backend services, scheduled pipelines, BI connections, embedded analytics, and customer-facing analytics workloads.

Each service account has its own credentials and Duckling configuration. This gives the workload isolated compute and makes it easier to rotate credentials without disrupting human users.

Admin access required

Creating service accounts, creating service account tokens, and configuring service account Ducklings requires an organization Admin.

REST API examples use a read/write access token generated by an Admin user. Pass the token in the Authorization header as Bearer <admin_token>.

Create a service account

Choose a stable username for the service account. The username must be unique within your organization and can contain letters, numbers, and underscores.

Service account creation form

  1. In the MotherDuck UI, go to Settings > Service Accounts.
  2. Click Create service account.
  3. Enter a username for the service account.
  4. Click Create service account.

Create an access token

Create a token for the service account after you create the account. The token value is shown only once, so store it in a secret manager before closing the modal or discarding the API response.

Service account details page

  1. In Settings > Service Accounts, open the service account details page.
  2. Click Create token.
  3. Enter a token name.
  4. Choose the token type:
    • Read/Write Token for writes, administration, and general service workloads.
    • Read Scaling Token for read-heavy workloads that should use read scaling.
  5. To set an expiration, select Automatically expire this token and choose a time-to-live.
  6. Click Create token, then copy the token and store it securely.
note

If you create a service account through the API and plan to use read scaling, connect as that service account with a read/write token before using read scaling tokens for that account.

Configure Ducklings

Configure Duckling resources for the service account based on the workload it runs. The read/write Duckling handles writes and general queries. The read scaling pool handles read-only connections that use read scaling tokens.

Service account Duckling size settings

  1. In Settings > Service Accounts, find the service account.
  2. Use the Read/Write Duckling dropdown to choose the read/write Duckling size.
  3. If you use read scaling, choose the read scaling Duckling size and pool size.

Connect as the service account

Use the service account token anywhere you would use a MotherDuck access token. For example, set motherduck_token in a DuckDB connection string or set MOTHERDUCK_TOKEN in your environment. See Connecting to MotherDuck for connection string examples.