bland-finland-95044
07/12/2024, 6:55 PMchilly-king-10285
07/12/2024, 6:55 PMchilly-king-10285
07/12/2024, 6:55 PMmetadata_public
for a user in Ory, you can use the PUT /admin/identities/{id}
endpoint. This endpoint updates an identity, and the full identity payload (except credentials) is expected. It is also possible to update the identity's credentials. Here is an example of how you might structure your request: json PUT /admin/identities/{id} { "metadata_public": { "key": "value" } }
Replace {id}
with the ID of the identity you want to update and replace "key": "value"
with the metadata you want to update. Please note that the metadata_public
field is used to store metadata about the identity which the identity itself can see when calling for example the session endpoint. Do not store sensitive information (e.g. credit score) about the identity in this field. For more information, refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api#operation/updateIdentity).bland-finland-95044
07/12/2024, 6:59 PMcurl --location --request PUT '<http://our-url.com/admin/identities/xxx>' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"metadata_public": {
"customer": "twc"
}
}'
chilly-king-10285
07/12/2024, 6:59 PMchilly-king-10285
07/12/2024, 7:00 PMPUT /admin/identities/{{id}}
endpoint in Ory expects the full identity payload (except credentials) when updating an identity. This means that you need to include all the other fields of the identity in your request, not just the metadata_public
field. If you only include the metadata_public
field, the other fields might be set to their default values, which could be causing the issue you're seeing. Here's an example of how your request might look: json PUT /admin/identities/{{id}} { "schema_id": "default", "traits": { "email": "[email protected]" }, "metadata_public": { "customer": "twc" } }
In this example, replace {{id}}
with the ID of the identity you want to update, "default"
with the ID of the JSON Schema to be used for validating the identity's traits, and [email protected]
with the identity's email. Please note that this is just an example and you might need to include other fields in your request depending on your setup. For more information, refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api#operation/updateIdentity).bland-finland-95044
07/12/2024, 7:03 PMchilly-king-10285
07/12/2024, 7:03 PMchilly-king-10285
07/12/2024, 7:03 PMPATCH
method for updating identities. You can only use the PUT /admin/identities/{{id}}
endpoint to update an identity. However, please note that this method replaces the entire metadata object. You can't update only a single value in metadata_public
or metadata_admin
. Here's an example of how you might structure your request: json PUT /admin/identities/{{id}} {{ "metadata_public": {{ "existing_key": "existing_value", "new_key": "new_value" }} }}
Replace {{id}}
with the ID of the identity you want to update, "existing_key": "existing_value"
with the existing metadata, and "new_key": "new_value"
with the new metadata you want to add. For more information, refer to the [Ory Documentation](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#update-identity-metadata).bland-finland-95044
07/12/2024, 7:10 PMchilly-king-10285
07/12/2024, 7:10 PMchilly-king-10285
07/12/2024, 7:11 PMmetadata_public
field using the PUT /admin/identities/{id}
endpoint, it could be due to a few reasons: 1. Incomplete or Incorrect Payload: Ensure that the payload you're sending is complete and correctly formatted. The PUT
method requires the full identity payload, except for credentials. If any required field is missing or incorrectly formatted, the update may not work as expected. 2. Incorrect ID: Make sure that the ID you're using in the endpoint is correct and corresponds to the identity you want to update. 3. Permissions: Check if you have the necessary permissions to update the identity. Some fields may not be editable depending on your permissions. 4. Webhook Interference: If you have webhooks set up, they might be interfering with the update. When a webhook target returns a 200 OK response code and the response body is a JSON object with the key identity.metadata_public
or identity.metadata_admin
in it, the values from that object will be used to replace the identity metadata fields before they are saved to the database. If you're still having trouble, it might be helpful to check the server logs for any error messages or warnings. For more information, refer to the [Ory API Reference](https://www.ory.sh/docs/reference/api#operation/updateIdentity) and the [Ory Documentation on Webhooks](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#update-identity-metadata).