Admin API Examples
In this section of the Authgear documentation, you'll learn about all the GraphQL queries and mutations the Admin API supports.
Authgear provides a GraphQL API that you can use to manage users and other resources right from your application or using the GraphiQL Explorer in Authgear Portal > Advanced > Admin API.
The following section shows a detailed description and examples of supported queries and mutations.
1. Queries
1.1. auditLogs
The auditLogs query returns a list of all activities (logs) from the audit log.
Schema:
auditLogs(
first: Int
last: Int
userIDs: [ID!]
sortDirection: SortDirection
before: String
after: String
rangeFrom: DateTime
rangeTo: DateTime
activityTypes: [AuditLogActivityType!]
): AuditLogConnectionExample:
1.2. users
You can use this query to fetch all registered users on your application. The users query returns a list of type User.
Schema:
Example:
1.3. node
A node represents a single object of different Types. The node query allows you to query a single object using the node ID. You learn more about node ID here: https://docs.authgear.com/reference/apis/admin-api/node-id.
Schema:
Example:
You can specify different object types to the node query to fetch an item of that type. Examples of node Types include User, AuditLog, Session, Authenticator, Authorization, and Identity.
The following example uses the AuditLog node type.
1.4. nodes
The nodes query returns a list of nodes. This works similarly to the node query except that instead of supplying a single ID, you can provide a list of IDs for the objects you are querying for.
Schema:
Example:
2. Mutations
With mutations, you can modify data from your application using the Admin API GraphQL. For example, you can use mutation to update
2.1. anonymizeUser
Calling this mutation will change a specific user account to an anonymous account. In other words, this query anonymizes a specific user. This action will delete the user's data like name and gender.
Schema:
Example:
2.2. createIdentity
The createIdentity mutation creates a new identity for a user.
Schema:
Example:
2.3. createUser
The createUser mutation makes it possible to create a new user account from the Admin API.
Schema:
Example:
2.4. deleteAuthenticator
This mutation deletes an authenticator for a specific user.
Schema:
Example:
2.5. deleteAuthorization
You can use the deleteAuthorization mutation to delete an existing authorization for a user.
Schema:
Example:
2.6. deleteIdentity
The deleteIdentity mutation deletes the identity of a user.
Schema:
Example:
2.7. deleteUser
This mutation allows you to delete a specific user using the Admin API.
Schema:
Example:
2.8. generateOOBOTPCode
Calling the generateOOBOTPCode mutation will generate a new OOB OTP Code for a user. This mutation allows you to specify the purpose and target of the OTP as input.
Schema:
Example:
2.9. resetPassword
The resetPassword mutation lets you rest a user's password from the Admin API.
Schema:
Example:
2.10. revokeAllSessions
With the revokeAllSessions mutation, you can revoke all sessions for a specific user.
Schema:
Example:
2.11. revokeSession
This mutation revokes a specific user session. You can specify the session using the session ID.
Schema:
Example:
2.12. scheduleAccountAnonymization
The scheduleAccountAnonymization mutation provides a means to schedule a user account anonymization from the Admin API.
Schema:
Example:
2.13. scheduleAccountDeletion
The scheduleAccountDeletion mutation provides a means to schedule a user account deletion from the Admin API.
Schema:
Example:
2.14. sendResetPasswordMessage
You can send a password reset message to a user from the Admin API using the sendResetPasswordMessage mutation.
Schema:
Example:
2.15. setDisabledStatus
The setDisabledStatus mutation enables you to enable or disable a user's account.
Schema:
Example:
2.16. setVerifiedStatus
You can use the setVerifiedStatus mutation to set a user as verified and unveried from the Admin API.
Schema:
Example:
2.17. unscheduleAccountAnonymization
This mutation allows you to cancel a previously scheduled mutation.
Schema:
Example:
2.18. unscheduleAccountDeletion
This mutation allows you to cancel a previously scheduled deletion.
Schema:
Example:
2.19. updateIdentity
The updateIdentity mutation updates an existing identiy of a user.
Schema:
Example:
2.20. updateUser
You can use this mutation to update an existing user's details. You can update standard attributes such as email and phone for the user. Or you can modify custom fields using the customAttributes argument.
Schema:
Example 1 (Standard Attributes):
For this updateUser example, we will be updating the standard attributes for a user. The first thing to do is to extract all the current values of the user's standard attributes into a variable. Then, add new fields or modify existing fields in the variable with new values.
Note: It is important to include the current values of the fields that you don't wish to update but still want to keep. The Admin API will delete any existing fields you omit in the variable.
The following block of code shows an example variable. If you're using GraphiQL, simply create the variable in the variable tab of GraphiQL like this:
Example 2 (Custom Attributes)
The following example shows how to update custom attributes.
Note: You must have created the custom attributes you wish to update in Authgear Portal > User Profile > Custom Attributes.

Create a variable and extract the current custom attributes into it. Modify the values of the attributes you wish to update or add new attributes.
Note: Again, it is important to include the current values of the fields that you don't wish to update but still want to keep. The Admin API will delete any existing fields you omit in the variable.
The following block of code shows an example of the variable. You can set the variable in the variable tab of GraphiQL.
Last updated
Was this helpful?