Skip to main content
When updating trusted_metadata and untrusted_metadata objects, update payloads will be merged with the existing objects at the top level only.

Adding a new field

To add a new field, pass a key-value pair. Note that this will be merged with the existing object. To add a new field, pass a key-value pair. Note that this will be merged with the existing object.
Initial
{
  "trusted_metadata": {
    "key1": "value1"
  }
}
Update
{
  "trusted_metadata": {
    "key2": "value2"
  }
}
Result
{
  "trusted_metadata": {
    "key1": "value1",
    "key2": "value2"
  }
}

Replacing an existing field

Pass a new value to an existing top-level key to replace field’s value.
Initial
{
  "untrusted_metadata": {
    "key1": "value1"
  }
}
Update
{
  "untrusted_metadata": {
    "key1": "value2"
  }
}
Result
{
  "untrusted_metadata": {
    "key1": "value2"
  }
}

Updating a deeply nested field

Stytch will not merge deeply nested objects or arrays. To add a field to a deeply nested object, or update an array, replace the entire top-level key.
Initial
{
  "trusted_metadata": {
    "key1": [{ "deep": "value1" }],
    "other_key": "other_value"
  }
}
Update
{
  "trusted_metadata": {
    "key1": [{ "deep": "value1" }, { "deep": "value2" }]
  }
}
Result
{
  "trusted_metadata": {
    "key1": [{ "deep": "value1" }, { "deep": "value2" }],
    "other_key": "other_value"
  }
}

Deleting a field

Pass a value of null to a top-level key to delete an existing field.
Initial
{
  "untrusted_metadata": {
    "key1": [{ "deep": "value1" }],
    "other_key": "other_value"
  }
}
Update
{
  "untrusted_metadata": {
    "key1": null
  }
}
Result
{
  "untrusted_metadata": {
    "other_key": "other_value"
  }
}

Deleting all fields

Pass a value of null to every top-level key to delete all fields.
Initial
{
  "trusted_metadata": {
    "key1": [{ "deep": "value1" }],
    "other_key": "other_value"
  }
}
Update
{
  "trusted_metadata": {
    "key1": null,
    "other_key": null
  }
}
Result
{
  "trusted_metadata": {}
}