Update User Using JSON Array
PATCH {{apiPath}}/environments/{{envID}}/users/{{userID}}
The sample shows the PATCH /environments/{{envID}}/users/{{userID}}
operation to update attribute properties using a JSON array in the request body. The operation uses the application/vnd.pingidentity.user.scim.patch+json
custom content type in the request header, and the request body must contain the Operations
property with an array as its value.
The Operations
property specifies the type of update operation in the Operations.op
attribute. Options for this attribute include add
, replace
, and remove
. The Operations.path
attibute specifies the user schema property to modify in the PATCH. The Operations.value
attribute specifies the new value for the modified user schema property.
Note: The behavior of this PATCH operation follows rules as specified by the Internet Engineering Task Force (IETF) for modifying resources with PATCH. For more information, see section 3.5.2 of RFC 7644: System for Cross-domain Identity Management: Protocol.
SCIM PATCH with multi-valued attributes
When you update a multi-valued attribute using application/json
as the Content-Type
HTTP header value, you must update the entire multi-valued attribute. The PATCH action associated with the application/vnd.pingidentity.user.scim.patch+json
is useful for updating targeted elements in a multi-valued attribute. For example, the following multi-valued attribute specifies T-shirt sizes and colors:
{
"tShirt":[
{
"tshirtSize":"XS",
"tshirtColor":"Blue"
},
{
"tshirtSize":"XL",
"tshirtColor":"Red"
}
]
}
The following PATCH request body specifies two operations. The first operation performs a replace
action; it finds all instances of tshirtSize
with a value XS
and replaces the current tshirtColor
attribute with the new color Orange
. For this modification, the Operations.path
uses a SCIM expression to find the XS
T-shirt sizes and update the associated tshirtColor
attribute. The second operation uses an add
action to add a new T-shirt size and color to the multi-valued atttribute.
{
"Operations":[
{
"op":"replace",
"path":"tShirt[tshirtSize eq \\\\\\"XS\\\\\\"].tshirtColor",
"value":"Orange"
},
{
"op":"add",
"path":"tShirt",
"value":[
{
"tshirtSize":"L",
"tshirtColor":"Yellow"
}
]
}
]
}
The multi-valued attribute looks like this after the update:
{
"tShirt":[
{
"tshirtSize":"XS",
"tshirtColor":"Orange"
},
{
"tshirtSize":"XL",
"tshirtColor":"Red"
},
{
"tshirtSize":"L",
"tshirtColor":"Yellow"
}
]
}
Prerequisites
- See Users and User Operations for important overview information.
Property | Type | Required? |
---|---|---|
accountId | String | Optional |
address.streetAddress | String | Optional |
address.countryCode | String | Optional |
address.locality | String | Optional |
address.region | String | Optional |
address.postalCode | String | Optional |
address.zipCode | String | Optional |
email | String | Optional |
locale | Array [String] | Optional |
mobilePhone | String | Optional |
name.given | String | Optional |
name.family | String | Optional |
name.middle | String | Optional |
name.honorificPrefix | String | Optional |
name.honorificSuffix | String | Optional |
name.formatted | String | Optional |
nickname | String | Optional |
photo.href | String | Optional |
population.id | String | Required |
preferredLanguage | String | Optional |
primaryPhone | String | Optional |
timeZone | String | Optional |
title | String | Optional |
type | String | Optional |
username | String | Optional |
See the User operations data model for full property descriptions.
Request Body
{"Operations"=>[{"op"=>"replace", "path"=>"email", "value"=>"test@test.com"}]}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Content-Type | string |
RESPONSES
status: OK
{"_links":{"self":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a"},"environment":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"},"population":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/populations/f22842c9-f1eb-41a5-8072-20041b609cf1"},"devices":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/devices"},"roleAssignments":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/roleAssignments"},"password":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/password"},"password.reset":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/password"},"password.set":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/password"},"password.check":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/password"},"password.recover":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/password"},"linkedAccounts":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/linkedAccounts"},"account.sendVerificationCode":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a"},"memberOfGroups":{"href":"https://api.pingone.com/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/users/788d4931-6936-43f2-82ff-178f5762298a/memberOfGroups"}},"_embedded":{"password":{"status":"PASSWORD_EXPIRED"}},"id":"788d4931-6936-43f2-82ff-178f5762298a","environment":{"id":"abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"},"account":{"canAuthenticate":true,"status":"OK"},"accountId":"5","address":{"streetAddress":"123 Fake Street","locality":"Springfield","region":"Somewhere","postalCode":"78701","countryCode":"US"},"createdAt":"2021-03-02T18:19:26.564Z","email":"test@test.com","enabled":true,"identityProvider":{"type":"PING_ONE"},"lastSignOn":{"at":"2021-03-31T19:37:12.129Z","remoteIp":"174.21.110.237"},"lifecycle":{"status":"ACCOUNT_OK"},"locale":"en-gb","mfaEnabled":false,"mobilePhone":"+1.4445552222","name":{"formatted":"Leslie Jones","given":"Leslie","middle":"L","family":"Jones","honorificPrefix":"Dr.","honorificSuffix":"IV"},"nickname":"Les","population":{"id":"f22842c9-f1eb-41a5-8072-20041b609cf1"},"preferredLanguage":"en-gb;q=0.8, en;q=0.7","primaryPhone":"+1.2225554444","timezone":"America/Los_Angeles","title":"The Great","type":"tele","updatedAt":"2021-10-28T19:32:06.911Z","username":"lesliejones@example.com","verifyStatus":"NOT_INITIATED"}