Use this API to create a new custom attribute in OneLogin.
Resource URL
https://<subdomain>.onelogin.com/api/2/users/custom_attributesHeader 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 any one of the following scopes: |
Content-Type required string | Set to application/json. |
Request Parameters
| name required | string | A descriptive name for the custom field. |
| shortname required | string | A 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. |
| position | integer | The 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
- 201 Created
- 400 Bad Request
- 401 Unauthorized
- 422 Unprocessable Entity
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 {{ }}.
Have a Question?
Found a problem or a bug? Submit a support ticket.
Looking for walkthroughs or how-to guides? Check out our Knowledge Base.
Have a product idea or request? Share it in our Ideas Portal.