Lock User Account
Use this call to lock a user’s account based on the policy assigned to the user, for a specific time you define in the request, or until you unlock it.
For details, see Request Parameter.
Resource URL
https://<subdomain>/api/1/users/:id/
lock_user
Header Parameters
Authorization required string |
Set to Set The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using the |
Content-Type required string |
Set to application/json . |
Resource Parameter
id required string |
Set to the |
Request Parameter
locked_until required integer |
Set to the number of minutes for which you want to lock the user account. Set to If no policy is assigned to the user, setting this value to Note that this value can not be less time that the Lock Effective Period specified on a user policy. |
Request Body
{
"locked_until":15
}
Sample Response
- 200 OK
- 400 Bad Req.
- 401 Unauth.
- 403 Forbid.
- 404 Not Found
{
"status": {
"type": "success",
"code": 200,
"message": "Success",
"error": false
}
}
{
"status": {
"error": true,
"code": 400,
"type": "bad request",
"message": "Input JSON is not valid"
}
}
Typically, the following error means that the Authorization
header is missing or incorrectly formatted. The Authorization
header should use this format: bearer:<access_token>
.
{
"status": {
"error": true,
"code": 400,
"type": "bad request",
"message": "Authorization Information is incorrect"
}
}
{
"status": {
"error": true,
"code": 400,
"type": "bad request",
"message": "locked_until should be -> integer"
}
}
Typically, the following error means that the user ID is not an integer. The user ID must be an integer.
{
"status": {
"error": true,
"code": 400,
"type": "bad request",
"message": {
"attribute": "id",
"description": "ID is incorrect"
}
}
}
Typically, the following error means that the access token used to make the call was generated using API credentials that have insufficient permissions. This API can be called using the Manage All
scope only.
{
"status": {
"error": true,
"code": 401,
"type": "Unauthorized",
"message": "Insufficient Permission"
}
}
Typically, the following error means that the access token is invalid.
{
"status": {
"error": true,
"code": 401,
"type": "Unauthorized",
"message": "Authentication Failure"
}
}
{
"status": {
"error": true,
"code": 403,
"type": "forbidden",
"message": "user is not authorized to access this User"
}
}
{
"status": {
"error": true,
"code": 404,
"type": "not found",
"message": "User for id 99999999 was not found"
}
}
Postman Collection
- Clicking Run in Postman button navigates to the page where you can fork the collection to your workspace. Forking the collection into your workspace will enable you to contribute to the source collection using pull requests. You can also view the collection in a public workspace if you like and even import a copy of the collection using the links present on the screen.
Sample Code
cURL
Replace sample values indicated by < >
with your actual values.
curl "https://<subdomain>/api/1/users/<user_id>/lock_user" \
-X PUT \
-H "Authorization: bearer:<access_token>" \
-H "Content-Type: application/json" \
-d '{
"locked_until": <integer_in_minutes>
}'
Python
See Work with OAuth 2.0 Tokens, Users, and Roles.
Have a Question?
Found a problem or a bug? Submit a support ticket.
Looking for walkthroughs or how-to guides on OneLogin's user and admin features? Check out the documentation in our Knowledge Base.
Have a product idea or request? Share it with us in our Ideas Portal.