PUT

Update Account

Use this API to update one of your reseller account’s direct child accounts, or to add an API credential pair to it.

This API changes only the account’s details. It can’t change the account owner, the OneLogin subdomain, or the plan. Owner and subdomain fields (email, firstname, lastname, user_password, and brand_subdomain) are ignored if you send them.

Resource URL

https://<subdomain>.onelogin.com/api/2/accounts/: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 Manage All.

The API credential must belong to a reseller account.

Content-Type

required

string

Set to application/json.

Resource Parameters

id

required

integer

Set to the id of the child account you want to update.

Request Parameters

account

required

object

The attributes to change. Attributes you leave out keep their current values. The object can't be empty, so if you only want to add an API credential, send the account's current name.

account.name, account.address1, account.address2, account.city, account.state, account.zip, account.country, account.phone, account.homepage, account.notes

string

The account details to change. See the account object.

api_credential

object

Adds an API credential pair to the child account, owned by the account owner. Existing credentials aren't changed. Send it at the top level of the body. It takes:

  • name (required): the credential's display name.

  • permission (required): the credential's scope. One of authentication_only, read_users, manage_users, read_all, or manage_all.

This works only if the child account has the Allow assuming users account setting turned on. Otherwise api_credential is ignored and the response doesn't include one.

Request Body

{
    "account": {
        "name": "Acme Inc.",
        "address1": "100 Main Street",
        "city": "Springfield",
        "state": "CA",
        "zip": "90210"
    },
    "api_credential": {
        "name": "Reporting",
        "permission": "read_all"
    }
}

Sample Responses

Returns the updated account object. If an API credential was added, the response also includes it. Store the client_secret securely.

{
    "id": 123456,
    "name": "Acme Inc.",
    "address1": "100 Main Street",
    "address2": null,
    "city": "Springfield",
    "state": "CA",
    "zip": "90210",
    "country": "US",
    "phone": "555-555-0100",
    "homepage": null,
    "notes": null,
    "remotetoken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "created_at": "2024-05-01T17:20:31.000Z",
    "updated_at": "2024-06-03T08:15:42.000Z",
    "api_credential": {
        "client_id": "<client_id>",
        "client_secret": "<client_secret>",
        "permission": "Read All",
        "display_name": "Reporting"
    }
}

The account object contains an attribute that doesn’t exist.

{
    "name": "BadRequestError",
    "message": "unknown attribute: company",
    "statusCode": 400
}

The access token is missing, invalid, or expired, or it was generated from a credential without the required scope. The Authorization header value should use this format: bearer <access_token>.

{
    "name": "UnauthorizedError",
    "message": "Unauthorized",
    "statusCode": 401
}

No account with this id exists, or it isn’t a direct child of your account.

{
    "status": 404,
    "name": "NotFound",
    "message": "The resource with the given id could not be found"
}

The request can’t be processed. The name tells you why:

  • ValidationError: the body has no account object, or it’s empty.
  • RecordInvalid: an account attribute failed validation, for example a blank name. The message lists the errors.
  • Invalid parameters: api_credential is missing its name or has an unknown permission, and the child account has Allow assuming users turned on. The account isn’t updated.
  • Insufficient privileges: the API credential doesn’t belong to a reseller account.
{
    "status": 422,
    "name": "ValidationError",
    "message": "Missing required parameters: [Account]"
}

Sample Code

cURL

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

Update Account

curl 'https://<subdomain>.onelogin.com/api/2/accounts/<id>' \
-X PUT \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
    "account": {
        "name": "Acme Inc.",
        "address1": "100 Main Street",
        "city": "Springfield",
        "state": "CA",
        "zip": "90210"
    }
}'