docs: introduce versioned docs and migrate to fuma (#11166)

## Todos for release

- [x] Configure Env in docs project on vercel
- [x] Configure Root Path in the docs project on vercel
- [ ] Remove old CSP https://github.com/zitadel/website/pull/1592

## What we did

This pull request migrates the project documentation from the old
`docs/` directory to the new `apps/docs/` directory, introduces a new
documentation system built with Next.js and Fumadocs, and updates all
relevant references, configuration files, and documentation to reflect
this change. It also adds new configuration and ignore files for the new
documentation app, updates CI and linting to exclude the new docs from
certain checks, and revises the contributing guidelines accordingly.

**Documentation System Migration and New Docs App**

* Migrated all documentation from `docs/` to `apps/docs/`, and updated
all references in `README.md`, `CONTRIBUTING.md`, and other files to
point to the new location.
[[1]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L585-L640)
[[2]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L660-R607)
[[3]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L740-R687)
[[4]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L2-R3)
[[5]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L30-R30)
* Added a new Next.js/Fumadocs-based documentation app under
`apps/docs/`, including core app files, layouts, routing, search API,
and a comprehensive `README.md` with development and contribution
instructions.
[[1]](diffhunk://#diff-5a1b07344a2c1b4d3f37b23ff1388b62cd9f57dea3c1cd23d8a0412b7602b132R1-R74)
[[2]](diffhunk://#diff-462b9ad1eabbb7d1c29bb9c36e4931eb180fd7190900e6d2babf8f4d66ad1c28R1-R39)
[[3]](diffhunk://#diff-e16ae25660ded787b10ac35dea96d5ecaacf895dae0afc8a9bd4382dc79a8c87R1-R7)
[apps/docs/app/[[...slug]]/layout.tsxR1-R81](diffhunk://#diff-59e08acde4e805b7aeccef1dcf98f1d71dfc550777e6b9402085cee0e9fa4e0aR1-R81),
[apps/docs/app/[[...slug]]/page.tsxR1-R79](diffhunk://#diff-e5df3f80d0fa01e12d63d81f29c57a9d14e846c78fd3beabb2ef768e38fd9580R1-R79),
[[4]](diffhunk://#diff-389b34918e040cacaa87cd7201ffa462cc2b0b716736f537e3d3c660ac69353bR1-R7)
[[5]](diffhunk://#diff-d3b03416d1c457b19f1c27b26f2db741412df841b875c26ccadc36e4522247f4R1-R29)
[[6]](diffhunk://#diff-c8fb8339570a5305809be7c618e14705fd86390dc278e6ce8ba224a7bc8b0c3cR1-R25)

**Configuration and Tooling Updates**

* Updated `.github/workflows/codeql.yml`, `.golangci.yaml`, and
`.github/dependabot.yml` to properly handle the new docs app: excluded
`apps/docs` from certain checks, added npm dependency updates for the
docs app, and excluded generated content.
[[1]](diffhunk://#diff-12783128521e452af0cfac94b99b8d250413c516ec71fe6d97dbea666ff7ba27L8-R14)
[[2]](diffhunk://#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5R5-R6)
[[3]](diffhunk://#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5R126-R129)
[[4]](diffhunk://#diff-dd4fbda47e51f1e35defb9275a9cd9c212ecde0b870cba89ddaaae65c5f3cd28R89-R106)
* Updated `.devcontainer/devcontainer.json` to use the latest Go 1.25.3
version for consistency.

**Licensing and Miscellaneous**

* Added `apps/docs/` to the list of licensed directories in
`LICENSING.md`.

These changes ensure the documentation is now maintained in a modern,
scalable system and all project tooling is updated to support the new
structure.

---------

Co-authored-by: Federico Coppede <[email protected]>
This commit is contained in:
Florian Forster
2026-01-29 08:38:36 -08:00
committed by GitHub
co-authored by Federico Coppede
parent 7b6395c348
commit d8ea041c56
2826 changed files with 78739 additions and 23571 deletions
@@ -0,0 +1,73 @@
## Accessing ZITADEL APIs
In this step, we will authenticate a service user and receive an access_token to use against the ZITADEL API.
You will need to craft a POST request to ZITADEL's token endpoint:
```bash
curl --request POST \
--url https://${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic ${BASIC_AUTH}' \
--data grant_type=client_credentials \
--data scope='openid urn:zitadel:iam:org:project:id:zitadel:aud'
```
If you want to access the ZITADEL API with this access token, you have to add `urn:zitadel:iam:org:project:id:zitadel:aud` to the list of scopes.
* `grant_type` should be set to `urn:ietf:params:oauth:grant-type:jwt-bearer`
* `scope` should contain any [Scopes](/apis/openidoauth/scopes) you want to include, but must include `openid` and `urn:zitadel:iam:org:project:id:zitadel:aud`
* `assertion` is the encoded value of the JWT that was signed with your private key from the prior step
You should receive a successful response with `access_token`, `token_type` and time to expiry in seconds as `expires_in`.
```bash
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "MtjHodGy4zxKylDOhg6kW90WeEQs2q...",
"token_type": "Bearer",
"expires_in": 43199
}
```
In this step we will authenticate a service user and receive an access_token to use against the ZITADEL API.
You will need to craft a POST request to ZITADEL's token endpoint:
```bash
curl --request POST \
--url https://${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic ${BASIC_AUTH}' \
--data grant_type=client_credentials \
--data scope='openid profile email urn:zitadel:iam:org:project:id:zitadel:aud'
```
* `grant_type` should be set to `client_credentials`
* `scope` should contain any [Scopes](/apis/openidoauth/scopes) you want to include, but must include `openid`. For this example, please include `profile`, `email`
and `urn:zitadel:iam:org:project:id:zitadel:aud`. The latter provides access to the ZITADEL API.
You should receive a successful response with `access_token`, `token_type` and time to expiry in seconds as `expires_in`.
```bash
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "MtjHodGy4zxKylDOhg6kW90WeEQs2q...",
"token_type": "Bearer",
"expires_in": 43199
}
```
### Access ZITADEL's API with the token
```bash
curl --request GET \
--url ${CUSTOM_DOMAIN}/management/v1/orgs/me \
--header "Authorization: Bearer $TOKEN"
```
Where `$TOKEN` corresponds to the access token from the earlier response.
@@ -0,0 +1,235 @@
---
title: Access ZITADEL APIs
---
This guide explains what ZITADEL APIs are and how to access ZITADEL APIs using a service user to manage all types of resources and settings.
## What are the ZITADEL APIs
ZITADEL exposes a variety of APIs that allow you to interact with its functionalities programmatically.
These APIs are offered through different protocols including gRPC and REST.
Additionally, ZITADEL provides [SDKs for popular languages](/sdk-examples/introduction) and frameworks to simplify integration.
Here's a breakdown of some key points about ZITADEL APIs:
* **Auth API:** Used by authenticated users for tasks related to their accounts.
* **Management API:** Used by organization managers for administrative tasks.
* **Admin API:** Used for administrative functions on the ZITADEL instance itself (may require separate user setup).
* **System API:** For ZITADEL self-hosted deployments only, providing superordinate control (requires specific configuration).
<Callout title="Resource-based APIs">
ZITADEL is transitioning from a use-case based API structure to a resource-based one, aiming to simplify API usage.
</Callout>
For further details and in-depth exploration, you can refer to the [ZITADEL API documentation](/apis/introduction).
## How to access ZITADEL APIs
Accessing ZITADEL APIs, except for the Auth API and the System API, requires these basic steps:
1. **Create a service user**: A service user is a special type of account used to grant programmatic access to ZITADEL's functionalities. Unlike regular users who log in with a username and password, [service users rely on a more secure mechanism involving digital keys and tokens](../service-users/authenticate-service-users).
2. **Give permission to access ZITADEL APIs**: Assign a Administrator role to the service user, giving it permission to make changes to certain resources in ZITADEL.
3. **Authenticate the service user**: Like human users, service users must authenticate and request an OAuth token with the scope `urn:zitadel:iam:org:project:id:zitadel:aud` to access ZITADEL APIs. [Service users can be authenticated](../service-users/authenticate-service-users) using private key JWT, client credentials, or personal access tokens.
4. **Access ZITADEL APIs with the token**: The OAuth token must be included in the Authorization Header of calls to ZITADEL APIs.
### Accessing Auth API
The Auth API can be used for all operations on the requesting user, meaning the user id in the `sub` claim of the used token.
Using this API doesn't require a service user to be authenticated.
Instead, you call the Auth API with the token of the user.
[Reference documentation for authentication API](/apis/introduction#authentication)
### Accessing System API
With the System API developers can manage different ZITADEL instances.
The System API can't be accessed by service users and requires a special configuration and authentication that can be found in our [guide to access ZITADEL's System API](./access-zitadel-system-api).
[Reference documentation for system API](/apis/introduction#system)
## 1. Create a service user
First, you need to create a new service user through the management console or ZITADEL APIs.
Via Management Console:
1. In an organization, navigate to Users > Service Users
2. Click on **New**
3. Enter a username and a display name
4. Click on **Create**
Via APIs23: * [Create User (Machine)](/reference/api/management/zitadel.management.v1.ManagementService.AddMachineUser)
## 2. Grant an Administrator Role to the Service User
ZITADEL Managers are Users who have permission to manage ZITADEL itself.
There are some different levels for managers.
- **IAM Managers**: This is the highest level. Users with IAM Administrator roles are able to manage the whole instance.
- **Org Managers**: Managers in the Organization Level are able to manage everything within the granted Organization.
- **Project Managers**: At this level, the user is able to manage a project.
- **Project Grant Manager**: The project grant manager is for projects, which are granted of another organization.
There are different roles on each level. You can find more about the different roles here: [ZITADEL Administrator Roles](/guides/manage/console/managers#roles)
To be able to access the ZITADEL APIs your service user needs permissions to ZITADEL.
1. Go to the detail page of your organization
2. Click in the top right corner the "+" button
3. Search for your service user
4. Give the user the role you need, for the example we choose Org Owner (More about [ZITADEL Permissions](/guides/manage/console/managers))
![](../../../../public/img/console_org_manager_add.gif)
## 3. Authenticate service user and request token
Service users can be authenticated using private key JWT, client credentials, or personal access tokens.
The [service user authentication](../service-users/authenticate-service-users) can be used to make machine-to-machine requests to any Resource Server (eg, a backend service / API) by requesting a token from the Authorization Server (ZITADEL) and sending the short-lived token (access token) in the Header of requests.
This guide covers a specific case of service user authentication when requesting access to the [ZITADEL APIs](/apis/introduction).
While PAT can be used directly to access the ZITADEL APIS, the more secure authentication methods private key JWT and client credentials must include the [reserved scope](/apis/openidoauth/scopes) `urn:zitadel:iam:org:project:id:zitadel:aud` when requesting an access from the token endpoint.
This scope will add the ZITADEL APIs to the audience of the access token.
ZITADEL APIs will check if they are in the audience of the access token, and reject the token in case they are not in the audience.
The following sections will explain the more specific authentication to access the ZITADEL APIs.
### Authenticate with private key JWT
Follow the steps in this guide to [generate an key file](../service-users/private-key-jwt#2-register-a-private-key-for-your-service-user) and [create a JWT and sign with private key](../service-users/private-key-jwt#3-create-a-jwt-and-sign-it-with-your-private-key).
With the encoded JWT (assertion) from the prior step, you will need to craft a POST request to ZITADEL's token endpoint.
**To access the ZITADEL APIs you need the ZITADEL Project ID in the audience of your token.**
This is possible by sending a [reserved scope](/apis/openidoauth/scopes) for the audience.
Use the scope `urn:zitadel:iam:org:project:id:zitadel:aud` to include the ZITADEL project id in your audience
A sample request will look like this
```bash {5}
curl --request POST \
--url ${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \
--data scope='openid profile urn:zitadel:iam:org:project:id:zitadel:aud' \
--data assertion=eyJ0eXAiOiJKV1QiL...
```
where
- `grant_type` must be set to `urn:ietf:params:oauth:grant-type:jwt-bearer`
- `scope` should contain any [Scopes](/apis/openidoauth/scopes) you want to include, but must include `openid` and `urn:zitadel:iam:org:project:id:zitadel:aud` to access the ZITADEL APIs. For this example include `profile`.
- `assertion` is the encoded value of the JWT that was signed with your private key from the prior step
You should receive a successful response with `access_token`, `token_type` and time to expiry in seconds as `expires_in`.
```bash
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "MtjHodGy4zxKylDOhg6kW90WeEQs2q...",
"token_type": "Bearer",
"expires_in": 43199
}
```
Use the access_token in the Authorization header to make requests to the ZITADEL APIs.
In the following example, we read the organization of the service user.
```bash
curl --request GET \
--url ${CUSTOM_DOMAIN}/management/v1/orgs/me \
--header 'Authorization: Bearer ${TOKEN}'
```
### Client credentials
Get the client id and client secret by
1. navigating to the service user, then
2. Open **Actions** in the top right corner and click on **Generate Client Secret**
3. Copy the **ClientID** and **ClientSecret** from the dialog
![](../../../../public/img/console_serviceusers_secret.gif)
With the ClientId and ClientSecret from the prior step, you will need to craft a POST request to ZITADEL's token endpoint.
#### Audience scope
**To access the ZITADEL APIs you need the ZITADEL Project ID in the audience of your token.**
This is possible by sending a [reserved scope](/apis/openidoauth/scopes) for the audience.
Use the scope `urn:zitadel:iam:org:project:id:zitadel:aud` to include the ZITADEL project id in your audience
In this step we will authenticate a service user and receive an access_token to use against the ZITADEL API.
#### Basic authentication
When using `client_secret_basic` on the token or introspection endpoints, provide an `Authorization` header with a Basic auth value in the following form:
```markdown
Authorization: "Basic " + base64( formUrlEncode(client_id) + ":" + formUrlEncode(client_secret) )
```
For an example see the [client secret basic authentication method reference](/apis/openidoauth/authn-methods#client-secret-basic).
We recommend using an OpenID / OAuth library that handles the encoding for you.
#### Post request
You will need to craft a POST request to ZITADEL's token endpoint:
```bash {6}
curl --request POST \
--url https://${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic ${BASIC_AUTH}' \
--data grant_type=client_credentials \
--data scope='openid profile urn:zitadel:iam:org:project:id:zitadel:aud'
```
where
* `grant_type` should be set to `client_credentials`
* `scope` should contain any [Scopes](/apis/openidoauth/scopes) you want to include, but must include `openid`. For this example, please include `profile`
and `urn:zitadel:iam:org:project:id:zitadel:aud`. The latter provides access to the ZITADEL API.
You should receive a successful response with `access_token`, `token_type` and time to expiry in seconds as `expires_in`.
```bash
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "MtjHodGy4zxKylDOhg6kW90WeEQs2q...",
"token_type": "Bearer",
"expires_in": 43199
}
```
Because the received token includes the `urn:zitadel:iam:org:project:id:zitadel:aud` scope, we can send it in your requests to the ZITADEL API as the Authorization Header.
In this example we read the organization of the service user.
```bash
curl --request GET \
--url ${CUSTOM_DOMAIN}/management/v1/orgs/me \
--header 'Authorization: Bearer ${TOKEN}'
```
### Personal access token (PAT)
A Personal Access Token (PAT) is a ready-to-use token which can be used as _Authorization_ header.
Because the PAT is a ready-to-use token, you can add it as Authorization Header and send it in your requests to the ZITADEL API.
In this example, we read the organization of the service user.
```bash
curl --request GET \
--url ${CUSTOM_DOMAIN}/management/v1/orgs/me \
--header 'Authorization: Bearer {PAT}'
```
## Notes
- [Example application in Go](./example-zitadel-api-with-go) to access ZITADEL APIs
- [Example application in .NET](./example-zitadel-api-with-dot-net) to access ZITADEL APIs
- Learn how to use the [Event API](./event-api) to retrieve your audit trail
- Read about the [different methods to authenticate service users](../service-users/authenticate-service-users)
@@ -0,0 +1,187 @@
---
title: Access ZITADEL System API
sidebar_label: System API
---
<Callout>
This guide focuses on the ZITADEL System API. To access the other APIs (Admin, Auth, Management), please checkout [this guide](./access-zitadel-apis).
The ZITADEL System API is currently only available for ZITADEL Self-Hosted deployments.
</Callout>
## System API User
The System API works superordinate over all instances. Therefore, you need to define a separate users to get access to this API.
You can do so by customizing the [runtime configuration](/self-hosting/manage/configure/configure#runtime-configuration-file).
To authenticate the user a self-signed JWT will be created and utilized.
You can define any id for your user. This guide will assume it's `system-user-1`.
**NOTE:** system user id cannot contain capital letters
## Generate an RSA keypair
Generate an RSA private key with 2048 bit modulus:
```bash
openssl genrsa -traditional -out system-user-1.pem 2048
```
and export a public key from the newly created private key:
```bash
openssl rsa -in system-user-1.pem -outform PEM -pubout -out system-user-1.pub
```
## Runtime Configuration
Provide the **public** key to the ZITADEL runtime configuration.
Either with the path to the key:
```yaml
SystemAPIUsers:
- system-user-1:
Path: /system-user-1.pub
```
or with a base64 encoded value of the key:
```yaml
SystemAPIUsers:
- system-user-1:
KeyData: <base64 encoded value of system-user-1.pub>
```
You can define memberships for the user as well:
```yaml
SystemAPIUsers:
- system-user-1:
Path: /system-user-1.pub
Memberships:
# MemberType System allows the user to access all APIs for all instances or organizations
- MemberType: System
Roles:
- "SYSTEM_OWNER"
- "IAM_OWNER"
- "ORG_OWNER"
# MemberType IAM and Organization let you restrict access to a specific instance or organization by specifying the AggregateID
- MemberType: IAM
Roles: "IAM_OWNER"
AggregateID: "123456789012345678"
- MemberType: Organization
Roles: "ORG_OWNER"
AggregateID: "123456789012345678"
- superuser2:
# If no memberships are specified, the user has a membership of type System with the role "SYSTEM_OWNER"
KeyData: <base64 encoded key> # or you can directly embed it as base64 encoded value
```
If you don't specify any memberships, you are allowed to access the whole [ZITADEL System API](/reference/api/system).
## Generate JWT
Similar to the OAuth 2.0 JWT Profile, we will create and sign a JWT. For this API, the JWT will not be used to authenticate against ZITADEL Authorization Server, but rather directly to the API itself.
The JWT payload will need to contain the following claims:
```json
{
"iss": "<userid>",
"sub": "<userid>",
"aud": "<https://${CUSTOM_DOMAIN}>",
"exp": <now+1h>,
"iat": <now>
}
```
So for your instance running on `custom-domain.com` the claims could look like this:
```json
{
"iss": "system-user-1",
"sub": "system-user-1",
"aud": "https://custom-domain.com",
"iat": 1659957184,
"exp": 1659960784
}
```
<Callout>
If your system is exposed without TLS or on a dedicated port, be sure to provide this in your audience, e.g. http://localhost:8080
</Callout>
### ZITADEL Tools
If you want to manually create a JWT for a test, you can also use our [ZITADEL Tools](https://github.com/zitadel/zitadel-tools). Download the latest release and run:
```bash
zitadel-tools key2jwt --audience=https://custom-domain.com --key=system-user-1.pem --issuer=system-user-1
```
## Call the System API
Now that you configured ZITADEL and created a JWT, you can call the System API and authenticate using the token:
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/system/v1/instances/_search \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json'
```
You should get a successful response with a `totalResult` number of 1 and the details of your instance:
```json
{
"details": {
"totalResult": "1"
},
"result": [
{
"id": "172698969497928101",
"details": {
"sequence": "102",
"creationDate": "2022-08-02T09:30:10.781068Z",
"changeDate": "2022-08-02T09:30:10.781068Z",
"resourceOwner": "172698969497928101"
},
"state": "STATE_RUNNING",
"name": "ZITADEL",
"domains": [
{
"details": {
"sequence": "108",
"creationDate": "2022-08-02T09:30:10.781068Z",
"changeDate": "2022-08-02T09:30:10.781068Z",
"resourceOwner": "172698969497928101"
},
"domain": "custom-domain.com",
"primary": true
},
{
"details": {
"sequence": "108",
"creationDate": "2022-08-02T09:30:10.781068Z",
"changeDate": "2022-08-02T09:30:10.781068Z",
"resourceOwner": "172698969497928101"
},
"domain": "zitadel-gnft7o.custom-domain.com",
"generated": true
}
]
}
]
}
```
## Summary
* Create an RSA keypair
* Provide the public key with a userID to ZITADEL using the runtime configuration
* Authorize the request with a JWT signed with your private key
Where to go from here:
* [ZITADEL API Documentation](/apis/introduction)
@@ -0,0 +1,192 @@
---
title: Get Events from ZITADEL
sidebar_label: Event API
---
ZITADEL leverages the power of eventsourcing, meaning every action and change within the system generates a corresponding event that is stored in the database.
To provide you with greater flexibility and access to these events, ZITADEL has introduced an Event API.
This API allows you to easily retrieve and utilize the events generated within the system, enabling you to integrate them into your own system and respond to specific events as they occur.
You need to assign a user the [administrator role](/guides/manage/console/managers) IAM_OWNER_VIEWER or IAM_OWNER to access the Event API.
If you like to know more about eventsourcing/eventstore and how this works in ZITADEL, head over to our [concepts](/concepts/eventstore/overview).
## Request Events
Call the [ListEvents](/reference/api/admin/zitadel.admin.v1.AdminService.ListEvents) endpoint in the Administration API to get all the events you need.
To further restrict your result you can add the following filters:
- sequence
- editor user id
- event types
- aggregate id
- aggregate types
- resource owner
- creation date
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/events/_search \
--header "Authorization: Bearer $TOKEN"
```
## Get event types
To be able to filter for the different event types ZITADEL knows, you can request the [EventTypesList](/reference/api/admin/zitadel.admin.v1.AdminService.ListEventTypes)
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/events/types/_search \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
'
```
The response will give you a list of event types. The type is what the event is called in ZITADEL itself (technical).
You can also find a translation for the event to better reflect it for an enduser perspective.
The following example shows you the event types for a password check (failed/succeeded).
```bash
...
{
"type": "user.human.password.check.failed",
"localized": {
"key": "EventTypes.user.human.password.check.failed",
"localizedMessage": "Password check failed"
}
},
{
"type": "user.human.password.check.succeeded",
"localized": {
"key": "EventTypes.user.human.password.check.succeeded",
"localizedMessage": "Password check succeeded"
}
},
...
```
## Get aggregate types
To be able to filter for the different aggregate types (resources) ZITADEL knows, you can request the [AggregateTypesList](/reference/api/admin/zitadel.admin.v1.AdminService.ListAggregateTypes)
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/aggregates/types/_search \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json'
```
The response will give you a list of aggregate types. The type is what the aggregate is called in ZITADEL itself (technical).
You can also find a translation for the aggregate to better reflect it for an enduser perspective.
The following example shows you the aggregate type for the user.
```bash
...
{
"type": "user",
"localized": {
"key": "AggregateTypes.user",
"localizedMessage": "User"
}
},
...
```
## Example: Get user changes since a specific date
Assuming you use ZITADEL as your single source of truth for your user data.
Now you like to react to changes on the users to update data in other your other systems.
This example shows you how to get all events from users, filtered with the creation_date (e.g since last day/hour, etc).
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/events/_search \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"asc": false,
"limit": 1000,
"creation_date": "2023-02-01T10:00:00.000000Z",
"aggregate_types": [
"user"
]
}'
```
## Example: Find out which users have authenticated
### OIDC session
The following example shows you how you could use the events search to get all events where a user has authenticated using OIDC.
Also we include the refresh tokens in this example to know when the user has received a new token.
Sessions without tokens events may by created during implicit flow with ID Token only, which do not create an access token.
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/events/_search \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"asc": true,
"limit": 1000,
"eventTypes": [
"oidc_session.added",
"oidc_session.access_token.added",
"oidc_session.refresh_token.added",
"oidc_session.refresh_token.renewed"
],
"aggregateTypes": [
"oidc_session"
]
}'
```
### SAML session
The following example shows you how you could use the events search to get all events where a user has authenticated using SAML.
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/events/_search \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"asc": true,
"limit": 1000,
"eventTypes": [
"saml_session.added",
"saml_session.saml_response.added"
],
"aggregateTypes": [
"saml_session"
]
}'
```
## Example: Get failed login attempt
The following example shows you how you could use the events search to find out the failed login attempts of your users.
You have to include all the event types that tell you that a login attempt has failed.
In this case these are the following events:
- Password verification failed
- One-time password (OTP) check failed (Authenticator Apps like Authy, Google Authenticator, etc)
- Universal Second Factor (U2F) check failed (FaceID, WindowsHello, FingerPrint, etc)
- Passkey check failed (FaceID, WindowsHello, FingerPrint, etc)
```bash
curl --request POST \
--url ${CUSTOM_DOMAIN}/admin/v1/events/_search \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"asc": true,
"limit": 1000,
"event_types": [
"user.human.password.check.failed",
"user.mfa.otp.check.failed",
"user.human.mfa.u2f.token.check.failed",
"user.human.passwordless.token.check.failed"
]
}'
```
@@ -0,0 +1,121 @@
---
title: Integrate ZITADEL APIs into a .NET Application
sidebar_label: Example .NET
---
This integration guide shows you how to integrate **ZITADEL** into your .NET application.
It demonstrates how to fetch some data from the ZITADEL management API.
At the end of the guide you should have an application able to read the details of your organization.
If you need any other information about the .NET SDK go to the [documentation](https://github.com/smartive/zitadel-net) of the SDK itself.
## Prerequisites
The client [SDK](https://github.com/zitadel/zitadel-net) will handle all necessary OAuth 2.0 requests and send the required headers to the ZITADEL API.
All that is required, is a service account with an Org Owner (or another role, depending on the needed api requests) role assigned and its key JSON.
However, we recommend you read the guide on [how to access ZITADEL API](/guides/integrate/zitadel-apis/access-zitadel-apis) and the associated guides for a basic knowledge of :
- [Recommended Authorization Flows](/guides/integrate/login/oidc/oauth-recommended-flows)
- [Service Users](/guides/integrate/service-users/authenticate-service-users)
> Be sure to have a valid key JSON and that its service account is either ORG_OWNER or at least ORG_OWNER_VIEWER before you continue with this guide.
## .NET Setup
### Create a .NET application
Use the IDE of your choice or the command line to create a new application.
```bash
dotnet new web
```
### Install the package
Install the package via nuget
```bash
dotnet add package Zitadel.Api
```
### Create example client
Change the program.cs file to the content below. This will create a client for the management api and call its `GetMyUsers` function.
The SDK will make sure you will have access to the API by retrieving a Bearer Token using JWT Profile with the provided scopes (`openid` and `urn:zitadel:iam:org:project:id:zitadel:aud`).
Make sure to fill the const `apiUrl`, and `personalAccessToken` with your own instance data. The used vars below are from a test instance, to show you how it should look.
The apiURL is the domain of your instance you can find it on the instance detail in the Customer Portal or in the Management Console
```csharp
// This file contains two examples:
// 1. An example with a service account "personal access token" to access the ZITADEL API.
// 2. An example with a service account "jwt profile key" to access the ZITADEL API.
using Zitadel.Api;
using Zitadel.Credentials;
const string apiUrl = "https://zitadel-libraries-l8boqa.zitadel.cloud";
const string personalAccessToken = "ge85fvmgTX4XAhjpF0XGpelB2vn9LZanJaqmUQDuf7iTpKVowb44LFl-86pqY2mfJCEoIOk";
// or create the token provider directly:
// new StaticTokenProvider(token)
var client = Clients.AuthService(new(apiUrl, ITokenProvider.Static(personalAccessToken)));
var result = await client.GetMyUserAsync(new());
Console.WriteLine($"User: {result.User}");
// This adds the urn:zitadel:iam:org:project:id:zitadel:aud scope to the authorization request, enabling access to ZITADEL APIs.
const string apiProject = "zitadel";
var serviceAccount = ServiceAccount.LoadFromJsonString(
@"
{
""type"": ""serviceaccount"",
""keyId"": ""170084658355110145"",
""key"": ""-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAnQisbU4FuLmjLR9I2Q01Rm9Mx6WySat2mbxgmOzu04oXuESI\nyS+RkiimdN0khjqouBftYqtVes7yngMLq3E8hMCwv/kLE+YeXphZXnn8tps8M2gV\n7S//uCp9LooK9qeh0lSkOqIsh0atj/l7NAHFxnhuNhfmn8XIYJNLVNSj5yzTri5E\nSn92SAsUQLSONgr7IEmIjcuPtYeU0iLvVno52ljZHnPX2WJ0HEZv44nZpkR4qBfv\n3hJzNx7sd4TdPGHHugJD8jdG/X4bAxwL5XGHZu18cUVM5RerSMpFQHSuIGgpKmK4\nWlM1AJGeut6EX/SrCxUDvhyOnXAgqhunTUmi6QIDAQABAoIBAHn7y92Y1y743X3m\nqHMbJIBTYyRPXaCGljm0MKF6o8clpWlZq5wE3KLZ+vwa8Q1oMbnXtGqKR3t/mM4P\n9Ze2/djtyh9GOUm632qCFCIkxp+fFPOl7ipyt8V7FAT77KpP6490eqKlacunppmJ\nph/vJJAY6xwQEvGX9SC4KrN5/txLKXbVtR3V2RXy9sxbbL4cpnklmRBMeXQkpwEM\nTKELUr5Rmhg9KvS3yALgVv0dIRtOA8Z995R234hXfY0St48YEvZtsxeme47u2CVl\nHJcVH4aa9Sw6XlgAEQBxqbQHpcLvUIu3XempO7VfGklWE6OlGuEcnUWpJCD8jMZW\nPYtt9LUCgYEAwi8josS3Iyto+DMJjJKCw175N2cmFMxBGu9Rw4aHjTiN57z7AUkn\nbmT44WnSmc1bCLC+nMB34vhiEyBKXYrH7zgbeMO8QDG3aO6gXdod/IdsieZR8E3b\ngUA1wtZYyRbc7eo8U4Nqkv1NXVRuDJkz/Mfoy+m1BVKcW7YeZaaZN9MCgYEAzwYB\n/LAiJoyx5UPwuieizlT7kHI7uvZRo4oLx+cZipNCJ0NGKgX4l1NIYLaNDbCoT9N0\nylico+kn+nihzDmD6SjY2hHGSIHk7AnJOcW+Bk5TfsYb8clxfgX40udLMIS0F13R\nrJt0gD9x0O3AZv4MV9cSI0/Md0tbWePgrLI44NMCgYEAojj7TlmEnY8AbIlGqvci\n4tCO5qf3elyA712LMwtKZsIeWsDX+OUCWglkmfvsAq06JfJx60YnYagbVtsdBTSR\nftmiqarrs71U+gaQVpeHgZYpKLMPNO/2Nu5Le2/SUHwXKXML3sDk4dNXNGb6YPAE\nLGNdqiyeG8o98agdkNIzIh0CgYEAlTGhMPfGRL3UXoNN8vopjEUWXozUmvJ090S/\nJLtZXtKtNBp5cEOJWZT9biVhFeKgCZc8ba7ahA29b/aLs+AnPlrfnJh+qzZhQfHz\ngJ0PSwAbkBs5fFBOaCHppiRlvXuFRemo95m4pcwTPBx7Mj4Xqx4lxij2E2rNVMSy\n4AI4l10CgYBwefqXt8B+D+0EvmhyHk19Tk8/fPelclJUv/IVI59c0F9UMAA2rD1U\nNW6k9251OGU7mQkztluNvl13qtAW/DveOjkFeDJIMzhFjravpLQXhUK4ETnM44YL\nFbClVGJaHYSHgOkNpcN5lYVLoyEvzv9rEPwBqpZRVnwWj6L+/I2L5Q==\n-----END RSA PRIVATE KEY-----\n"",
""userId"": ""170079991923474689""
}");
client = Clients.AuthService(
new(
apiUrl,
ITokenProvider.ServiceAccount(
serviceAccount,
apiUrl,
apiProject)));
result = await client.GetMyUserAsync(new());
Console.WriteLine($"User: {result.User}");
```
### Test client
After you have configured everything correctly, you can simply start the example by:
```bash
dotnet run
```
This will output something similar to:
```
User: {"FirstName": "MyName", "LastName": "MyLastName" ... }
```
## Completion
You have successfully used the ZITADEL .NET SDK to call the auth API!
To use the auth API you will not need a specific role, because only an authenticated user is needed.
For accessing the admin or management API the user will need some specific roles.
If you encountered an error (e.g. `code = PermissionDenied desc = No matching permissions found`),
ensure your service user has the required permissions by assigning the `ORG_OWNER` or `ORG_OWNER_VIEWER` role
and check the mentioned [guides](#prerequisites) at the beginning.
If you've run into any other problem, don't hesitate to contact us or raise an issue on [ZITADEL](https://github.com/zitadel/zitadel/issues) or in the [SDK](https://github.com/zitadel/zitadel-go/issues).
### Whats next?
Now you can proceed implementing our APIs by adding more calls.
Checkout more [examples from the SDK](https://github.com/zitadel/zitadel-go/blob/main/example) or refer to our [API Docs](/apis/introduction).
> This guide will be updated soon to show you how to use the SDK for your own API as well.
@@ -0,0 +1,86 @@
---
title: Integrate ZITADEL APIs into a Go Application
sidebar_label: Example Go
---
This integration guide shows you how to integrate **ZITADEL** into your Go application.
It demonstrates how to fetch some data from the ZITADEL management API.
> ℹ️ These examples and guides are based on our official [Go SDK](https://github.com/zitadel/zitadel-go).
>
> The SDK is a convenient wrapper around our low-level [OIDC library](https://github.com/zitadel/oidc). For most use cases, using the helpers provided in our [Go SDK](https://github.com/zitadel/zitadel-go) is the recommended approach for implementing authentication.
At the end of the guide you should have an application able to read the details of your organization.
> This documentation references our [CLI example](https://github.com/zitadel/zitadel-go/blob/next/example/client/cli/cli.go).
## Prerequisites
The client [SDK](https://github.com/zitadel/zitadel-go) will handle all necessary OAuth 2.0 requests and send the required headers to the ZITADEL API using our [Go SDK](https://github.com/zitadel/zitadel-go).
All that is required, is a service account with an Org Owner (or another role, depending on the needed api requests) role assigned and its key JSON.
However, we recommend you read the guide on [how to access ZITADEL API](/guides/integrate/zitadel-apis/access-zitadel-apis)) and the associated guides for a basic knowledge of :
- [Recommended Authorization Flows](/guides/integrate/login/oidc/oauth-recommended-flows)
- [Service Users](/guides/integrate/service-users/authenticate-service-users)
> Be sure to have a valid key JSON and that its service account is either ORG_OWNER or at least ORG_OWNER_VIEWER before you continue with this guide.
## Go Setup
### Add Go SDK to your project
You need to add the SDK into Go Modules by:
```bash
go get -u github.com/zitadel/zitadel-go/v3
```
### Create example client
Create a new go file with the content below. This will create a client and call its `GetMyOrg` function on the ManagementService.
The SDK will make sure you will have access to the API by retrieving a Bearer Token using JWT Profile with the provided scopes (`openid` and `urn:zitadel:iam:org:project:id:zitadel:aud`).
```go reference
https://github.com/zitadel/zitadel-go/blob/next/example/client/cli/cli.go
```
### Test
After you have configured everything correctly, you can simply start the example by:
```bash
go run cli.go --domain <custom domain> --key <path>
```
This could look like:
```bash
go run cli.go --domain my-domain.zitadel.cloud --key ./api.json
```
This will output something similar to:
```
2023/12/20 08:48:23 INFO retrieved the organisation orgID=165467338479501569 name=DemoOrg
```
## Completion
You have successfully used the ZITADEL Go SDK to call the management API!
If you encountered an error (e.g. `code = PermissionDenied desc = No matching permissions found`),
ensure your service user has the required permissions by assigning the `ORG_OWNER` or `ORG_OWNER_VIEWER` role
and check the mentioned [guides](#prerequisites) at the beginning.
If you've run into any other problem, don't hesitate to contact us or raise an issue on [ZITADEL](https://github.com/zitadel/zitadel/issues) or in the [SDK](https://github.com/zitadel/zitadel-go/issues).
### Whats next?
Now you can proceed implementing our APIs by adding more calls or using a different service like the SessionService:
```go
api.SessionService().CreateSession(ctx, &session.CreateSessionRequest{})
```
Checkout more [examples from the SDK](https://github.com/zitadel/zitadel-go/blob/next/example),
like how you can integrate the [client in your own API](https://github.com/zitadel/zitadel-go/blob/next/example/api/client/main.go)
or refer to our [API Docs](/apis/introduction).