---
title: "Validate Formula"
method: POST
path: "/objects/{object_slug}/attributes/formula/validate"
tags: ["Objects"]
---

# Validate Formula

`POST /objects/{object_slug}/attributes/formula/validate`

## Request

- Base URL: `https://be.graph8.com/api/v1`
- URL: `https://be.graph8.com/api/v1/objects/{object_slug}/attributes/formula/validate`
- Auth: HTTP bearer

Dry-run type-check and cycle-check of a typed formula expression, optionally evaluated on one record.
Nothing is stored. Read-only (`objects:read`) despite the POST verb: the expression travels in the body. The
check uses YOUR view of the schema: a field you cannot see or an object you cannot read is unknown, and a preview
that names one is `valid: false` with `unknown_field` (200), exactly like a name that does not exist. An admin key
is held to the same object grants: API keys never bypass them.

## Path parameters

- `object_slug` string, required

## Headers

- `Authorization` string, nullable
- `X-Target-Org-Id` string, nullable

## Request body

- FormulaValidateRequest: Dry-run check of a typed formula expression. Nothing is persisted or locked.
  - `expression` object, required: The typed JSON expression (a node tree; a rollup is a `rollup` node).
  - `attribute_slug` string, nullable: Slug of the computed field being EDITED (checked against its own place in the dependency graph); omit for a new one.
  - `preview_record_id` string, nullable: Evaluate the expression against this record's current values.

## Response `200`

Successful Response

- ApiResponseFormulaValidateResponse
  - `data` FormulaValidateResponse, required
    - `valid` boolean, required
    - `result_type` string, nullable: number, currency, text, checkbox, date or timestamp.
    - `currency_code` string, nullable
    - `depends_on` object[]
    - `referenced_object_slugs` string[]
    - `errors` object[]: Field-level problems (`reason` is a stable code).
    - `preview_value` unknown
    - `preview_error` string, nullable: Why the preview record could not be evaluated (a code, never a value).
    - `preview_rollups` PreviewRollup[]: With a preview record: one entry per rollup in the expression, counted over the records the caller may read.
      - `node_path` string, required: Where the rollup sits in the expression: `$` is the root, `$.left`, `$.args[1]`, `$.then_branch`.
      - `matched_count` integer, required: Linked records the rollup counted for the preview record (the ones its filters keep).
  - `pagination` PaginationMeta
    - `page` integer, required: Current page number (1-indexed)
    - `limit` integer, required: Items per page
    - `total` integer, required: Total number of items
    - `has_next` boolean, required: Whether there are more pages
    - `next_cursor` string, nullable: Opaque cursor for the next page; null when there are no more items. Pass it back as the `cursor` query param to fetch the following page without computing page numbers.
    - `total_available` integer, nullable: Search endpoints only: how many records really match, when known. Can be larger than `total`, which is capped at the 10,000 results that can be paged. For company search this is a distinct-company estimate. Null when unknown; absent outside search.
    - `total_is_lower_bound` boolean, nullable: Search endpoints only: true when more records match than `total` shows (the result set is larger than the 10,000 results that can be paged). Absent outside search.
    - `notes` string[], nullable: Search endpoints only: plain-language notes about the result, e.g. that more records match than can be paged, or that a reversed `between` range was put in order.

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/graph8/apis/graph8-developer-api.md) · [All operations](https://skmtc.dev/graph8/apis/graph8-developer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/graph8/apis/graph8-developer-api/revisions/2e7cfa0ca921?raw)
