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
exportconstmanagementApiDescription=`Logto Management API is a comprehensive set of REST APIs that gives you the full control over Logto to suit your product needs and tech stack. To see the full guide on Management API interactions, visit [Interact with Management API](https://docs.logto.io/docs/recipes/interact-with-management-api/).
2
+
3
+
### Get started
4
+
5
+
The API follows the same authentication principles as other API resources in Logto, with some slight differences. To use Logto Management API:
6
+
7
+
1. A machine-to-machine (M2M) application needs to be created.
8
+
2. A machine-to-machine (M2M) role with Management API permission \`all\` needs to be assigned to the application.
9
+
10
+
Once you have them set up, you can use the \`client_credentials\` grant type to fetch an access token and use it to authenticate your requests to the Logto Management API.
11
+
12
+
### Fetch an access token
13
+
14
+
To fetch an access token, you need to make a \`POST\` request to the \`/oidc/token\` endpoint of your Logto tenant.
15
+
16
+
For Logto Cloud users, the base URL is your Logto endpoint, i.e. \`https://[tenant-id].logto.app\`. The tenant ID can be found in the following places:
17
+
18
+
- The first path segment of the URL when you are signed in to Logto Cloud. For example, if the URL is \`https://cloud.logto.io/foo/get-started\`, the tenant ID is \`foo\`.
19
+
- In the "Settings" tab of Logto Cloud.
20
+
21
+
The request should follow the OAuth 2.0 [client credentials](https://datatracker.ietf.org/doc/html/rfc6749#section-4.4) grant type. Here is a non-normative example of how to fetch an access token:
22
+
23
+
\`\`\`bash
24
+
curl --location \
25
+
--request POST 'https://[tenant-id].logto.app/oidc/token' \
Replace \`[tenant-id]\`, \`[app-id]\`, and \`[app-secret]\` with your Logto tenant ID, application ID, and application secret, respectively.
35
+
36
+
The response will be like:
37
+
38
+
\`\`\`json
39
+
{
40
+
"access_token": "eyJhbG...2g", // Use this value for accessing the Logto Management API
41
+
"expires_in": 3600, // Token expiration in seconds
42
+
"token_type": "Bearer", // Token type for your request when using the access token
43
+
"scope": "all" // Scope \`all\` for Logto Management API
44
+
}
45
+
\`\`\`
46
+
47
+
### Use the access token
48
+
49
+
Once you have the access token, you can use it to authenticate your requests to the Logto Management API. The access token should be included in the \`Authorization\` header of your requests with the \`Bearer\` authentication scheme.
50
+
51
+
Here is an example of how to list the first page of users in your Logto tenant:
52
+
53
+
\`\`\`bash
54
+
curl --location \
55
+
--request GET 'https://[tenant-id].logto.app/api/users' \
56
+
--header 'Authorization: Bearer eyJhbG...2g'
57
+
\`\`\`
58
+
59
+
Replace \`[tenant-id]\` with your Logto tenant ID and \`eyJhbG...2g\` with the access token you fetched earlier.`;
@@ -232,15 +244,24 @@ export default function swaggerRoutes<T extends AnonymousRouter, R extends Route
232
244
info: {
233
245
title: 'Logto API references',
234
246
description:
235
-
'API references for Logto services. To learn more about how to interact with Logto APIs, see [Interact with Management API](https://docs.logto.io/docs/recipes/interact-with-management-api/).'+
247
+
'API references for Logto services.'+
236
248
condString(
237
249
EnvSet.values.isCloud&&
238
250
'\n\nNote: The documentation is for Logto Cloud. If you are using Logto OSS, please refer to the response of `/api/swagger.json` endpoint on your Logto instance.'
0 commit comments