---
title: "Assert Deal"
method: PUT
path: "/deals/assert"
tags: ["Assert / Upsert"]
---

# Assert Deal

`PUT /deals/assert`

## Request

- Base URL: `https://be.graph8.com/api/v1`
- URL: `https://be.graph8.com/api/v1/deals/assert`
- Auth: HTTP bearer

Create or update a deal. Matches by name + company_id.

Deliberately NOT wired into the closed-stage gates or the completeness
rule: assert is the sync-shaped surface (external systems pushing state,
no human to answer a 400), the same category the internal router excludes
for POST /v1/deals/webhook/sync and the CRM pull worker (#15530
"Out of scope"). Only input hygiene applies here: ids must exist and
close_date must parse.

#16060: a stage move made here now emits ``deal.stage_changed`` and writes
``cb_deal_stage_history``, like every other stage writer. ``background_tasks``
is injected (not a body field, so the request schema is unchanged) and the
publish is queued only after the session context has exited — a rolled-back
assert publishes nothing. Because assert is the sync-shaped surface, the
SAME stage arrives on every tick of the caller's poll loop: the event fires
only on an actual transition, never on a re-assert of the current stage.

## Headers

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

## Request body

- DealAssertRequest
  - `name` string, required: Deal name (match key)
  - `company_id` string, nullable: Company ID (match key, combined with name)
  - `amount` number, nullable
  - `currency` string, nullable
  - `stage_id` string, nullable
  - `pipeline_id` string, nullable
  - `description` string, nullable
  - `close_date` string, nullable

## Response `200`

Successful Response

- ApiResponseDealAssertResponse
  - `data` DealAssertResponse, required
    - `action` string, required: 'created' or 'updated'
    - `deal_id` string, required
  - `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)
