POST

Create Custom Attribute

Use this API to create a new custom attribute in OneLogin.

Resource URL

https://<subdomain>.onelogin.com/api/2/users/custom_attributes

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.

Request Parameters

name

required

stringA descriptive name for the custom field.
shortname

required

stringA unique identifier for the custom field. Must contain only letters, digits, and underscores. Cannot be a reserved OneLogin User attribute name (e.g. id, password, status, role, roles, group, directory, state, notes, created_at, updated_at, and other internal User model attributes). Using a reserved name returns a 422 error.
positionintegerThe position of the custom field. Defaults to null if not provided.

Sample Request Body

{
    "user_field": {
        "name": "My Custom Attribute",
        "shortname": "my_custom_attribute"
    }
}

Sample Response

The newly created custom attribute is returned.

{
    "id": 183232,
    "position": null,
    "name": "My Custom Attribute",
    "shortname": "my_custom_attribute"
}
{
    "message": "unknown attribute: employee_number",
    "name": "BadRequestError",
    "statusCode": 400
}

Typically, this error means that your access token value is invalid.

{
    "message": "Unauthorized",
    "name": "UnauthorizedError",
    "statusCode": 401
}
{
    "statusCode": 400,
    "message": "Shortname has already been taken",
    "name": "BadRequestError"
}

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 {{ }}.

Run In Postman