<@U04UQ68083H> My after registration hook with res...
# ory-copilot
f
@chilly-king-10285 My after registration hook with response parse true returns this body
Copy code
{
  "identity": {
    "metadata_public": {
      "analytics_id": "id",
      "locale": "fr",
      "uuid": "id"
    }
  }
}
but the identity field metadata_public is still nil in database, do you know why?
b
A message from kapa.ai
Based on the knowledge sources, your webhook response format is correct for updating the identity's metadata_public field, and you have set response.parse: true as required. However, there are a few important caveats: - The webhook can only modify the identity during the registration and settings flows, and the entire metadata_public object is replaced by the value returned by the webhook. Partial updates are not supported; you must provide the full object if you want to retain existing values. - The webhook must return a 200 OK status code, and the response body must be a JSON object with the key identity.metadata_public containing the new value. If metadata_public is still nil in the database after registration, possible reasons (based on the documentation) include: 1. The webhook did not return a 200 OK status code. 2. The response body was not parsed as valid JSON or did not match the expected structure. 3. There may be an issue with the webhook configuration or with how Ory processes the webhook response. You should double-check: - That your webhook is returning exactly a 200 OK status. - That the response body is valid JSON and matches the structure you posted. - That the webhook is configured with response.parse: true. If all of these are correct and the issue persists, it may be a bug or a limitation not covered in the documentation. In that case, you may want to open an issue with a reproducible example, as suggested in the Ory community and issue tracker documentation. For more details, see the official guide on [webhook response handling](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#modify-identities). > When updating any of the identity fields, be aware that the whole field is replaced by the value returned by the webhook... When the 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. This method replaces the entire metadata object. You can't update only a single value in metadata_public or metadata_admin. [Webhook response handling](https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#modify-identities) If you have confirmed all the above and it still does not work, the knowledge sources do not provide further troubleshooting steps for this specific issue.
f
@chilly-king-10285 My webhook returned a 201 status code with this body
b
A message from kapa.ai
New message text here
f
@chilly-king-10285 when does kratos check if the email of new identity already exists? will it be after my webhook?
b
A message from kapa.ai
Ory Kratos checks if the email (or other unique identifier) of a new identity already exists during the registration flow. According to the documentation and issue discussions, this check happens as part of the core registration logic, not in your webhook. Specifically, the uniqueness check is performed before the identity is created in the database and before any "after registration" hooks (including webhooks) are executed. This is supported by the documentation on webhooks, which states that when using an "after" registration hook with response parsing, the webhook is called before the system creates a new identity only if response parsing is enabled. However, the uniqueness check for identifiers like email is a fundamental part of the registration process and is enforced before the identity is persisted or any hooks are run. If the email already exists, the registration will fail with an error such as "An account with the same identifier (email, phone, username, ...) exists already" and your webhook will not be called in that case [Configurable Account Enumeration protection in Account Experience](https://github.com/ory/network/issues/229) [Registration flow with an existing email and an insecure password returns only insecure password error](https://github.com/ory/kratos/issues/3082). So, to summarize: Kratos checks for existing emails before your webhook is called. If the email already exists, the registration flow is interrupted and your webhook will not be executed.