---
title: "Create event"
method: POST
path: "/events"
tags: ["events"]
---

# Create event

`POST /events`

## Request body

- CreateEventRequestBody
  - `backfill` boolean, nullable — Requires a secret API key, and trusted_client_clock. Import historical data without affecting billing.
  - `body` union
    - object
      - `company` object — Key-value pairs to identify company associated with track event
      - `event` string, required — The name of the type of track event
      - `lease_id` string — Credit lease ID this track event is redeeming against
      - `quantity` integer — Optionally specify the quantity of the event
      - `traits` object — A map of trait names to trait values
      - `user` object — Key-value pairs to identify user associated with track event
    - object
      - `company_id` string, nullable — Schematic company ID (starting with 'comp_') of the company evaluated, if any
      - `error` string, nullable — Report an error that occurred during the flag check
      - `flag_id` string, nullable — Schematic flag ID (starting with 'flag_') for the flag matching the key, if any
      - `flag_key` string, required — The key of the flag being checked
      - `reason` string, required — The reason why the value was returned
      - `req_company` object, nullable — Key-value pairs used to to identify company for which the flag was checked
      - `req_user` object, nullable — Key-value pairs used to to identify user for which the flag was checked
      - `rule_id` string, nullable — Schematic rule ID (starting with 'rule_') of the rule that matched for the flag, if any
      - `user_id` string, nullable — Schematic user ID (starting with 'user_') of the user evaluated, if any
      - `value` boolean, required — The value of the flag for the given company and/or user
    - object
      - `company` object — Information about the company associated with the user; required only if it is a new user
        - `keys` object, required — Key-value pairs to identify the company
        - `name` string — The display name of the company; required only if it is a new company
        - `traits` object — A map of trait names to trait values
      - `keys` object, required — Key-value pairs to identify the user
      - `name` string — The display name of the user being identified; required only if it is a new user
      - `traits` object — A map of trait names to trait values
    - object
      - `cached_input_tokens` integer — Number of input tokens served from cache
      - `company` object, required — Key-value pairs to identify the company associated with the inference event
      - `cost` string — Provided cost of the inference request as a decimal string; derived from model pricing when omitted
      - `currency` string — ISO 4217 currency code for the provided cost; defaults to 'usd'
      - `event` string — Optional track event name to fan out for usage-based billing
      - `input_tokens` integer, required — Number of input tokens for the inference request
      - `operation` string — The inference operation; defaults to 'chat'
      - `output_tokens` integer, required — Number of output tokens for the inference request
      - `provider` string, required — The inference provider (e.g. 'anthropic', 'openai')
      - `reasoning_tokens` integer — Number of reasoning tokens for the inference request
      - `request_model` string — The model requested for the inference request
      - `requests` integer — Number of requests represented by this event; defaults to 1
      - `response_model` string, required — The model that served the inference response
      - `user` object — Key-value pairs to identify the user associated with the inference event
  - `event_type` 'flag_check' | 'identify' | 'inference' | 'track', required
  - `idempotency_key` string, nullable — Optional client-supplied key. Duplicate events with the same key (scoped to the environment) are dropped for 24h.
  - `sent_at` string, date-time, nullable — Optionally provide a timestamp at which the event was sent to Schematic
  - `trusted_client_clock` boolean, nullable — Requires a secret API key and sent_at. Use sent_at as the effective timestamp.

## Response `201`

Created

- object
  - `data` RawEventResponseData, required
    - `captured_at` string, date-time, required
    - `event_id` string, nullable
    - `remote_addr` string, nullable
    - `remote_ip` string, required
    - `user_agent` string, required
  - `params` object, required — Input parameters

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not found
- `500` — Server error

---

[API](https://skmtc.net/schematichq/apis/schematic-api.md) · [All operations](https://skmtc.net/schematichq/apis/schematic-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/schematichq/schematic-api/revisions/419cb5147b52/schema)
