You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: references/service-accounts.mdx
+61-24Lines changed: 61 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,46 +3,83 @@ title: "Service accounts"
3
3
description: "Service accounts provide a userless alternative to Personal Access Tokens (PATs) when working with the Lightdash CLI or the API. They are created and managed at the organization level, can be assigned granular scopes, and remain valid even if the administrator who created them leaves the organization."
4
4
---
5
5
6
+
<Info>
7
+
Service accounts require an **Enterprise License Key**.
8
+
</Info>
9
+
10
+
## Overview
11
+
12
+
Service accounts provide machine-to-machine authentication for automated access to the Lightdash API. Unlike personal access tokens which are tied to individual users, service accounts are organization-level entities designed for applications, CI/CD pipelines, and automated workflows.
13
+
14
+
Service accounts allow you to:
15
+
16
+
- Authenticate API requests without using personal user credentials
17
+
- Grant specific permission scopes (read, edit, or admin)
18
+
- Set expiration dates for tokens
19
+
20
+
## Enabling service accounts (self-hosted only)
21
+
22
+
If you're self-hosting Lightdash, you will need to add the following environment variable to your configuration:
23
+
24
+
```bash
25
+
SERVICE_ACCOUNT_ENABLED=true
26
+
```
27
+
28
+
After enabling, restart your Lightdash instance for the change to take effect.
29
+
6
30
## Creating a Service Account
7
31
8
32
1. Navigate to **General Settings** → **Service Accounts**
9
33
2. Click **Add Service Account**
10
34
11
-

12
-
3. Enter a **Description** optional **Expiry**
35
+

36
+
3. Enter a **Description**and optional **Expiry**
13
37
4. Select one or more **Scopes** to grant
14
38
5. Click **Create service account**
15
-
6.**Copy** the generated token. This is the only time it will be shown. All service accounts tokens will be prefixed with `ldsvc_`
16
-
7. Use it to login on the CLI using _``lightdash login https://your-lightdash-cloud --token your-token``_
17
-
8. Or in the API like
18
-
19
-
```
20
-
GET https://your-lightdash-cloud/api/v1/org/projects
6.**Copy** the generated token. This is the only time it will be shown. All service account tokens will be prefixed with `ldsvc_`
23
40
24
41
## Scopes
25
42
26
-
> Scopes are hierarchical: granting a higher-level scope (e.g. `org:admin`) automatically includes all lower-level permissions (e.g. `org:edit`, `org:view`).
43
+
Scopes are hierarchical - granting a higher-level scope (e.g. `org:admin`) automatically includes all lower-level permissions (e.g. `org:edit`, `org:view`).
Service account tokens use the `Authorization` header:
64
+
65
+
```bash
66
+
curl -H "Authorization: ldsvc_abc123xyz..." \
67
+
"$LIGHTDASH_URL/api/v1/..."
68
+
```
69
+
70
+
For full API documentation, see the [API Reference](/api-reference/v1/introduction).
71
+
72
+
## Example Use cases
73
+
74
+
### CI/CD automation
75
+
76
+
Use service accounts to automatically deploy dbt changes to Lightdash in your CI/CD pipeline. See [deploying with GitHub Actions](https://docs.lightdash.com/references/dbt-projects#1-automatically%3A-deploy-your-changes-to-lightdash-using-a-github-action) for implementation details.
33
77
34
-
##Use cases
78
+
### Instance initialization
35
79
36
-
### I want to create a service account to refresh my dbt changes on Lightdash on CI
80
+
When setting up a new self-hosted instance, configure `LD_SETUP_SERVICE_ACCOUNT_TOKEN`to initialize with a service account. See the [environment variables guide](https://docs.lightdash.com/self-host/customize-deployment/environment-variables#initialize-instance) for details.
37
81
38
-
1. Create a service account (see above)
39
-
2. Create a CI pipeline using [github actions](https://docs.lightdash.com/references/dbt-projects#1-automatically%3A-deploy-your-changes-to-lightdash-using-a-github-action)
40
-
3. Make sure you change the `yaml` on github to use your service account token _``lightdash login https://your-lightdash-cloud --token your-token``_
82
+
### Automated reporting
41
83
42
-
### I want to create a new instance using service accounts
84
+
Use service accounts to programmatically export dashboard data, schedule reports, or integrate Lightdash data into other systems via the API.
43
85
44
-
1. Follow [this guide to initialize an instance using environment variables](https://docs.lightdash.com/self-host/customize-deployment/environment-variables#initialize-instance)
45
-
2. Make sure you configure the `LD_SETUP_SERVICE_ACCOUNT_TOKEN` (must start with the prefix `ldsvc_`)
46
-
3. Initialize instance
47
-
4. Login on the CLI using this token _``lightdash login https://your-lightdash-cloud --token your-token``_
48
-
5. Update content from templates using `lighdash upload`
0 commit comments