Creating custom attributes on okta using Schemas API

Okta 

        It provides cloud software that helps companies manage and secure user authentication into applications, and for developers to build identity controls into applications, website web services and devices. 

1.How to add attributes in user profile manually? 

In the Directory session Click à Profile Editor. Profile Editor page will appear on the filter click Okta which is highlighted in the image. 
Click User(default) Profile. 

Once you have clicked the user (default) Profile, it will redirect to this page and here you can see a button “Add Attributes.” By clicking it, you can create custom attribute for that profile. 

One more way to create a custom attribute is using Schemas API 

Schemas API: 

                  The Okta Schemas API provides operations to manage custom user profiles as well as endpoints to discover the structure of the Log Stream configuration. 

Prerequisites: 

1.Set Remote site settings with your Okta tenant. 

2.Must be with your Okta tenant security token. 

Now,  we are going to make callouts for creating custom attribute for user profile 
 

code snippet: 
  HttpRequest httpRequest = new HttpRequest(); 

  httpRequest.setEndpoint( 

      “https://${yourOktaDomain}/api/v1/meta/schemas/user/default” 

  ); 

  httpRequest.setMethod(“POST”); 
  httpRequest.setHeader(“Accept”,”Application/json”); 

  httpRequest.setHeader(“Content-Type”,”Application/json”);  

  httpRequest.setHeader(“Authorization”, “SSWS ${api_token}”); 

  httpRequest.setBody(‘ 

  { 

  “definitions”: { 

    “custom”: { 

      “id”: “#custom”, 

      “type”: “object”, 

      “properties”: { 

        “additionalInformation”: { 

          “title”: “Additional information”, 

          “description”: ” Additional information “, 

          “type”: “string”, 

          “required”: false, 

          “minLength”: 1, 

          “maxLength”: 20, 

          “permissions”: [ 

            { 

              “principal”: “SELF”, 

              “action”: “READ_WRITE” 

            } 

          ] 

        } 

      }, 

      “required”: [] 

    } 

  } 

  ‘); 

  HTTPResponse httpResponse = http.send(httpRequest); 

Here,  I am creating a custom attribute with the name additional information, and setting up all types like Field type, Minimum length, Maximum length. 

Once the Request was successful,  you will get a response like this. 

You can see your Custom attribute details in that response too.  

The Custom attribute is created successfully. Now, you can see that attribute in the User Profile. 

References: 

https://developer.okta.com/docs/reference/api/schemas/

https://developer.okta.com/docs/reference/core-okta-api/

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.