<@U04UQ68083H> how to add `metadata_public` when s...
# ory-copilot
n
@chilly-king-10285 how to add
metadata_public
when submitting registration flow on kratos
b
A message from kapa.ai
To add
metadata_public
when submitting a registration flow in Ory Kratos, you need to include it in the payload of your registration request. Here's how you can do it: 1. When submitting the registration flow, add a
metadata_public
field to your request payload alongside the other required fields like traits and password. 2. The
metadata_public
should be an object containing the public metadata you want to associate with the identity. Here's an example of how your registration payload might look:
Copy code
json {   "method": "password",   "csrf_token": "your-csrf-token",   "traits": {     "email": "<mailto:user@example.com|user@example.com>",     "tos": true   },   "password": "verystrongpassword",   "metadata_public": {     "custom_field": "custom_value"   } }
It's important to note that the
metadata_public
field is not validated using the identity's JSON schema. You must ensure that the metadata you store is valid according to your requirements [Kratos Identity Metadata & Traits](https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata). Also, keep in mind that while the identity owner can see this metadata (for example, when calling
/sessions/whoami
), they cannot modify it directly. Only administrators can update this field using the
/admin/identities
APIs [Kratos Identity Metadata & Traits](https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata). Remember to adjust the payload according to your specific identity schema and registration flow requirements.