Admin APIs
The Admin API allows your server to manage users via a GraphQL endpoint. You can list users, search users, view user details, and many more. In fact, the user management part of the portal is built with the Admin API.
The Admin API GraphQL endpoint
The Admin API GraphQL endpoint is at /_api/admin/graphql
. For example, if your app is myapp
, then the endpoint is https://myapp.authgearapps.com/_api/admin/graphql
.
Accessing the Admin API GraphQL endpoint
Accessing the Admin API GraphQL endpoint requires your server to generate a valid JWT and include it as Authorization
HTTP header.
Obtaining the private key for signing JWT
Go to Settings -> Admin API
Click Download to download the private key. Make it available to your server.
Copy the key ID. Make it available to your server.
Generating the JWT with the private key
Here is the sample code of how to generate the JWT with the private key.
Including the JWT in the HTTP request
After generating the JWT, you must include it in EVERY request you send to the Admin API endpoint. Here is how it looks like
The header is the standard Authorization HTTP header. The token type MUST be Bearer.
Optional: Caching the JWT
As you can see in the sample code, you expiration time of the JWT is 5 minutes. You make it last longer and cache it to avoid generating it on every request.
Trying out the Admin API GraphQL endpoint
The GraphiQL tool is NOT a sandbox environment and all changes will be made on real data. Use with care!
The above instruction is for server-side integration. If you want to explore what it can do, you can visit the GraphiQL tool.
Go to Settings -> Admin API
Click on the GraphiQL tool link
Inspecting the GraphQL schema
In the GraphiQL tool, you can toggle the schema documentation by pressing the Docs button in the top right corner.
Last updated
Was this helpful?