Create Attribute
POST {{apiPath}}/environments/{{envID}}/schemas/{{schemaID}}/attributes
The following sample shows the POST /environments/{{envID}}/schemas/{{schemaID}}/attributes
operation to add a new custom attribute to a specified schema resource. In the request body, the name
property is required. All other properties are optional.
An attribute can support multiple values if the multiValued
property is set to true. If the multiValued
property is set to false or is null, the User object will contain the attribute value as a single value. If multiValued
is set to true, the value in the User object will be an array. When searches are performed on User schema data, a user will match if any value of a multiValued
attribute is part of the search criteria.
Note: The sample request shows an regexValidation
property with its value returned by the request. It also shows an enumeratedValue
property (for demonstration purposes) that is commented out because the service does not support both of these properties in the same POST
request.
Prerequisites
See Schemas for important overview information.
Read all available schemas and select a
schemaID
for the endpoint.
See the Schema attributes POST, PUT, PATCH data model for full property descriptions.
Property | Type | Required? |
---|---|---|
description | String | Optional |
displayName | String | Optional |
enabled | Boolean | Required |
enumeratedValues\[\] | Array | Optional |
enumeratedValues\[\].value | String | Required |
enumeratedValues\[\].archived | Boolean | Optional |
enumeratedValues\[\].description | String | Optional |
ldapAttribute | String | Required |
multiValued | Boolean | Optional |
name | String | Required |
regexValidation | Object | Optional |
regexValidation.pattern | String | Required |
regexValidation.requirements | String | Required |
regexValidation.valuesPatternShouldMatch | Array | Optional |
regexValidation.valuesPatternShouldNotMatch | Array | Optional |
required | Boolean | Optional |
schema.id | String | Required |
schemaType | String | Required |
subAttributes | Array | Optional |
subAttributes.description | String | Optional |
subAttributes.displayName | String | Optional |
subAttributes.enabled | Boolean | Required |
subAttributes.name | String | Required |
subAttributes.required | Boolean | Optional |
subAttributes.schemaType | String | Required |
subAttributes.type | String | Optional |
subAttributes.unique | Boolean | Required |
type | String | Optional |
unique | Boolean | Required |
Request Body
{"name"=>"officeStuff{{$timestamp}}", "displayName"=>"An optional property that specifies the display name of the attribute.", "description"=>"An optional property that specifies the description of the new attribute.", "schemaType"=>"CUSTOM", "type"=>"STRING", "unique"=>false, "enabled"=>false, "multiValued"=>false, "regexValidation"=>{"pattern"=>"xs|XS|s|S|m|M|l|L|xl|XL|xxl|XXL", "requirements"=>"Must be a T-shirt size from XS to XXL", "valuesPatternShouldMatch"=>["xs", "XXL"], "valuesPatternShouldNotMatch"=>["xL", "x"]}, "#enumeratedValues"=>[{"value"=>"CUPS", "archived"=>true, "description"=>"Cups, Class: Clergy, Faculty: Emotions and love"}, {"value"=>"PENTACLES", "archived"=>true, "description"=>"Pentacles, Class: Merchants, Faculty: Material body or possessions"}, {"value"=>"SWORDS", "archived"=>true, "description"=>"Swords, Class: Nobility and military, Faculty: Reason"}, {"value"=>"WANDS", "archived"=>true, "description"=>"Wands, Class: Artisans, Faculty: Creativity and will"}]}
RESPONSES
status: Created
{"_links":{"self":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/schemas/dbaccb62-4fbb-4922-af88-70e2ea4ed5bf/attributes/8c36d189-2b42-443f-be44-e7cf888ae95c"},"environment":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"},"schema":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/schemas/dbaccb62-4fbb-4922-af88-70e2ea4ed5bf"}},"id":"8c36d189-2b42-443f-be44-e7cf888ae95c","environment":{"id":"abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"},"name":"officeStuff1675293786","displayName":"An optional property that specifies the display name of the attribute.","description":"An optional property that specifies the description of the new attribute.","schemaType":"CUSTOM","type":"STRING","unique":false,"enabled":false,"multiValued":false,"required":false,"regexValidation":{"pattern":"xs|XS|s|S|m|M|l|L|xl|XL|xxl|XXL","requirements":"Must be a T-shirt size from XS to XXL","valuesPatternShouldMatch":["xs","XXL"],"valuesPatternShouldNotMatch":["xL","x"]},"schema":{"id":"dbaccb62-4fbb-4922-af88-70e2ea4ed5bf"}}