See api-docs Menu

Update User by ID

Use to update a user by ID using these request parameters.

Here are some API calls you can use to make other common updates to users:

For details about each element in the User resource, see User Resource.

Resource URL

https://api.<us_or_eu>.onelogin.com/api/1/users/:id

Header Parameters

Authorization

required

string

Set to bearer:<access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

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 any one of the following scopes: Manage users or Manage All.

Content-Type

required

string

Set to application/json.

Resource Parameter

id

required

integer

Set to the id of the user that you want to update. If you don’t know the user’s id, use the Get Users API call to return all users and their id values.

Request Parameters

  • company, string

  • department, string

  • directory_id, string

  • distinguished_name, string

  • email, string

  • external_id, string

  • firstname, string

  • group_id, string

  • invalid_login_attempts, string

  • lastname, string

  • locale_code, string

  • manager_ad_id, string

  • member_of, string

  • notes, string

  • openid_name, string

  • phone, string

  • samaccountname, string

  • title, string

  • username, string

  • userprincipalname, string

Sample Request Body

{
   "lastname":"Gonzales-Jones"
}

Sample Response

{
    "status": {
        "error": false,
        "code": 200,
        "type": "success",
        "message": "Success"
    },
    "data": [
        {
            "activated_at": null,
            "created_at": "2015-11-25T03:32:44.478Z",
            "email": "justine.gonzales@test.com",
            "username": "justine@gonzales",
            "firstname": "Justine",
            "group_id": null,
            "id": 11111111,
            "invalid_login_attempts": null,
            "invitation_sent_at": null,
            "last_login": null,
            "lastname": "Gonzales-Jones",
            "locked_until": null,
            "notes": null,
            "openid_name": "justine",
            "locale_code": null,
            "password_changed_at": null,
            "phone": null,
            "status": null,
            "updated_at": "2015-12-01T18:45:53.086Z",
            "distinguished_name": null,
            "external_id": null,
            "directory_id": null,
            "member_of": null,
            "samaccountname": null,
            "userprincipalname": null,
            "manager_ad_id": null,
            "role_id": null
        }
 ]
}

Here are a few different errors that will return a 400 Bad Request status code.

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": {
            "description": "last is not a valid attribute for user model",
            "attribute": "last"
        }
 }
}

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": "Content Type is not specified or specified incorrectly. 
                    Content-Type header must be set to application/json"
 }
}

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": {
            "description": "id is an excluded attribute for put request for user",
            "attribute": "id"
        }
 }
}

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"
 }
}

Typically, this error means that the access token is invalid.

{
  "status": {
    "error": true,
    "code": 401,
    "type": "Unauthorized",
    "message": "Authentication Failure"
 }
}

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 Users or Manage All scope.

{
    "status": {
        "error": true,
        "code": 401,
        "type": "Unauthorized",
        "message": "Insufficient Permission"
    }
}
{
    "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 11111111 was not found"
 }
}

Postman Collection

Replace sample variables indicated by < > in the sample request body with your actual values. Also, be sure to set Postman-specific environment variables indicated by {{ }}.

Download for the Users API

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

curl 'https://api.<us_or_eu>.onelogin.com/api/1/users/<id>' \
-X PUT \
-H "Authorization: bearer:<access_token>" \
-H "Content-Type: application/json" \
-d '{
    "lastname":"<lastname>"
}'

Python

See Work with OAuth 2.0 Tokens, Users, and Roles.


Have a Question?

Have a how-to question? Seeing a weird error? Ask us about it on StackOverflow.

Found a bug? Submit a support ticket.

Have a product idea or request? Share it with us in our Ideas Portal.