> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morf.health/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom JSON Payloads (Deprecated)

> Legacy Morf Custom JSON event source that exposes the JSON to CEL under a fields object

<img src="https://mintcdn.com/morfhealth/EU2WCxuXGIUQcziR/images/morf.svg?fit=max&auto=format&n=EU2WCxuXGIUQcziR&q=85&s=ae6978dd2d8b4d3a340944239283af5c" alt="images/morf.svg" width="40" height="40" data-path="images/morf.svg" />

<Warning>
  This event source is deprecated and can no longer be selected when creating a new workflow. Existing workflows that use it keep working. New workflows should use [Custom JSON Payloads](/docs/events/payloads/morf/json_body) instead, which exposes the same JSON under a `body` variable.
</Warning>

This is the original form of the Morf custom JSON event source. It accepts the same arbitrary JSON as the current event source, but it exposes the JSON to CEL differently: the top-level keys live under a variable named `fields` rather than `body`.

# Events

* `MORF_API_PUSH_UPDATE`

# Accessing fields in CEL

Every key in your JSON is reachable from the `fields` variable with regular dot or bracket syntax, including nested objects and lists.

Given the example payload on the right:

| Expression                   | Result               |
| ---------------------------- | -------------------- |
| `fields.foo`                 | `"bar"`              |
| `fields["foo"]`              | `"bar"`              |
| `fields.baz`                 | `42.0`               |
| `fields.quux`                | `true`               |
| `fields.patient.address.zip` | nested object access |
| `fields.items[0].sku`        | list access          |

There is no `body` variable on this event source. Likewise, `fields` does not exist on the current event source, so expressions are not portable between the two without renaming the root variable.

## Missing keys and optionals

Accessing a key that is not present in the payload raises a `no such key` error rather than returning null. That is fine for action parameters, which treat a missing key as an empty value, but it will fail a filter or wait node. Use one of these forms when a key may be absent:

| Expression                | Result when `foo` is absent |
| ------------------------- | --------------------------- |
| `has(fields.foo)`         | `false`                     |
| `"foo" in fields`         | `false`                     |
| `fields.?foo`             | `optional.none()`           |
| `fields.?foo.orValue("")` | `""`                        |

`fields.?foo` is an *optional* value. It carries either a value or nothing, and it never errors. Call `.orValue(fallback)` to unwrap it with a default, or `.hasValue()` to test it.

<Note>
  JSON numbers arrive as CEL doubles because JSON has no integer type. Compare against `42.0` rather than `42` if you hit a type mismatch.
</Note>

<RequestExample>
  ```json Example theme={null}
  {
      "foo": "bar",
      "baz": 42,
      "quux": true
  }
  ```
</RequestExample>
