---
title: "Create Assessment"
method: POST
path: "/webchat/assessments"
tags: ["Web Chat"]
---

# Create Assessment

`POST /webchat/assessments`

## Request

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

Create an assessment.

`definition` is the flow itself and is validated HERE, against the app's
own model - so a graph whose `start_step_id` names a step it does not
define is a 422 rather than a dead end a visitor walks into.

Note `chat_bot_id` is a QUERY parameter on this one and a BODY field on
every other webchat create. That is the app's own inconsistency, mirrored
rather than tidied: moving it into the body would send the handler a
parameter it does not take.

## Query parameters

- `chat_bot_id` string, required: Owning chat bot id (UUID).

## Headers

- `Idempotency-Key` string, nullable: Retry-safety key. Replaying it returns the FIRST result.
- `Authorization` string, nullable
- `X-Target-Org-Id` string, nullable

## Request body

- AssessmentCreateRequest: A guided question flow the widget can run with a visitor. `definition` is the flow itself - a start step, the steps, and the results they lead to. It is the app's own `AssessmentDefinition`, so a graph that names a step it does not define is a 422 here rather than a dead end the visitor walks into.
  - `name` string, required
  - `description` string, nullable
  - `definition` AssessmentDefinition, required: Complete branching graph stored as JSONB in chat_assessments.definition.
    - `start_step_id` string, required
    - `steps` AssessmentStepDef[]
      - `id` string, required
      - `question` string, required
      - `answers` AssessmentAnswerDef[]
        - `id` string, required
        - `text` string, required
        - `next_step_id` string, nullable
        - `result_id` string, nullable
      - `allow_free_text` boolean
    - `results` AssessmentResultDef[]
      - `id` string, required
      - `title` string, required
      - `body` string
      - `booking_enabled` boolean
      - `handoff_enabled` boolean
      - `links` AssessmentResultLink[]
        - `label` string, required
        - `url` string, required
  - `surface` 'external' | 'internal', nullable

## Response `201`

Successful Response

- ApiResponseWebchatPayload
  - `data` WebchatPayload, required: An open envelope for one webchat object. Open because the widget's config grows a field per product decision and a pinned schema would DROP it. Same choice the desk surface made.
  - `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)
