Why do I get “The passed json is nested too deeply.” when consuming the API?
If you receive a 400 error with the message “Body not valid! The passed json is nested too deeply.” when calling the Locize API, it means your JSON payload is too deeply nested.
Why Does This Happen?
The Locize API expects flat JSON objects for translations. Deeply nested objects are not supported (except for special context cases).
❌ Incorrect (Too Deeply Nested)
{
"new": {
"key": "default value"
},
"another": {
"existing": {
"key": "another changed value",
"phrase": "another value"
}
}
}✅ Correct (Flat JSON)
{
"new.key": "default value",
"another.existing.key": "another changed value",
"another.existing.phrase": "another value"
}Exception: Adding Context
If you want to add context information for a translation, you can use a nested object for that key:
{
"new.key": {
"value": "default value",
"context": {
"text": "description for this key"
}
},
"another.existing.key": "another changed value",
"another.existing.phrase": "another value"
}Here, new.key has a value and a context object with a description.
Best Practices
- Always send translations as flat JSON (dot notation for nested keys)
- Only use nested objects when adding context for a specific key
- Double-check your payload before sending to the API
For more details, see the API documentation.