---
title: "Validate Formula"
method: POST
path: "/api/v1/admin/fields/validate-formula"
tags: ["admin-schema"]
---

# Validate Formula

`POST /api/v1/admin/fields/validate-formula`

Compile a formula expression against an object's current schema and
report whether it's valid.

The Setup → Fields → Formula editor calls this on every "Check syntax"
click — it lets admins surface compile errors (unknown field, type
mismatch, bad syntax) before submitting the create-field form, where
the same compile would also run but rejects the whole save instead of
just inlining a hint.

Request body::

    {"object_type": "Opportunity",
     "formula_expression": "TODAY() - close_date",
     "return_type": "number"}            # optional — when present, the
                                         # endpoint also checks that
                                         # the inferred type matches.

Response on success::

    {"valid": true,
     "return_type": "number",            # inferred from the formula
     "referenced_fields": ["close_date"]}

Response on failure (HTTP 200 with valid=false, so the UI can show the
error inline)::

    {"valid": false, "error": "Unknown field reference: close_dat"}

## Headers

- `authorization` string, nullable
- `X-API-Key` string, nullable

## Request body

- object

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/ninjavan/apis/salesforce-sales-cloud-replacement.md) · [All operations](https://skmtc.net/ninjavan/apis/salesforce-sales-cloud-replacement/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ninjavan/salesforce-sales-cloud-replacement/revisions/fd3a41a6260b/schema)
