Navigation
POST data

null_coalesce

1 credit

Replace null or empty values in a dict with defaults

Endpoint

POST /api/v1/tools/data/null_coalesce

Body Parameters

data object required
defaults object required
treat_zero_as_null boolean optional default: false
treat_empty_string_as_null boolean optional default: true

Example

input Request
{
    "data": {
        "bio": "",
        "name": "Alice",
        "email": null
    },
    "defaults": {
        "bio": "No bio provided",
        "email": "unknown@example.com"
    }
}
output Response
{
    "result": {
        "bio": "No bio provided",
        "name": "Alice",
        "email": "unknown@example.com"
    },
    "replaced_keys": [
        "email",
        "bio"
    ]
}

Response Format

HTTP/1.1 200 OK SUCCESS
{
  "success": true,
  "data": {
    "result": {
        "bio": "No bio provided",
        "name": "Alice",
        "email": "unknown@example.com"
    },
    "replaced_keys": [
        "email",
        "bio"
    ]
},
  "meta": {
    "tool": "null_coalesce",
    "credits_consumed": 1
  }
}
HTTP/1.1 422 Unprocessable Entity ERROR
{
  "success": false,
  "data": null,
  "error": {
    "code": "validation_error",
    "message": "The given data was invalid."
  }
}

Sign in to try this tool directly from the docs.

Code Examples
Request Example
lightbulb Developer Tip

Credits are deducted before execution. If the upstream tool fails, credits are automatically refunded to your account.