---
title: "Create Logs"
method: POST
path: "/v0/logs"
tags: ["Logs"]
---

# Create Logs

`POST /v0/logs`

Creates one or more logs associated to a project. Logs are
LLM-call-level data that might depend on other variables.

If a context is specified and it is versioned, all logs will be versioned
and mutable. The context version will be incremented automatically when
logs are added, updated, or removed.

The context parameter can be:
- A string: Uses the string as the context name with default values (description=None, is_versioned=False)
- An object: Uses the object's name, description, and is_versioned properties

An "explicit_types" dictionary can be passed as part of the `entries`.
If present, any matching key inside this dictionary will override the
inferred type of that particular entry. The explicit_types dictionary
can also specify if a field is mutable via a 'mutable' boolean flag
and if a field is unique via a 'unique' boolean flag:

```json
{
    "field_name": {
        "type": "str",
        "mutable": false,  # Makes the field immutable (default is true)
        "unique": true     # Makes the field unique
    }
}
```

By default, all fields are mutable. Set `mutable: false` to make a field
immutable after creation. Only mutable fields can be modified through
the update endpoint.

**Response includes:**
- `log_event_ids`: List of created log event IDs
- `row_ids`: Object with `names` (unique key column names) and `ids` (nested list of values)
- `auto_counting`: Dictionary mapping auto-counting column names to their generated/provided values.
  Empty dict `{}` when no auto-counting is configured.

This method returns the ids of the new stored logs along with any auto-counting values.

## Request body

- CreateLogConfig
  - `project_name` string, required — Name of the project the stored entries will be associated to.
  - `context` union — Optional context path to update for the logs. Can use '/' for nested contexts (e.g. 'training/batch1'). Can be a string (which will be interpreted with description=None and is_versioned=False) or a ContextCreateRequest object.
    - ContextCreateRequest — Request model for creating a new context within a project.
      - `name` string, required — Context name, can be nested using '/' (e.g., 'parent/child'). Must contain only alphanumeric characters, underscores, and hyphens.
      - `description` string, nullable — Optional description of the context
      - `is_versioned` boolean — Whether the context should be versioned. If True, the context will be versioned and mutable.
      - `allow_duplicates` boolean — Whether duplicate log entries are allowed in this context. If False, attempts to add duplicate logs will be ignored.
      - `unique_keys` object, nullable — Unique key definition. Keys are column names, values are types ('str', 'int', 'float', 'bool', 'datetime', 'time', 'date', 'timedelta', 'dict', 'list').
      - `auto_counting` object, nullable — Auto-counting configuration. Keys are column names to auto-increment, values are parent counter names (None for independent counters).
      - `foreign_keys` ForeignKeyConfig[], nullable — Foreign key definitions for referential integrity
        - `name` string, required — Column name or path to nested field that references another context. Supports: - Simple column: 'department_id' - Array elements: 'images[*].image_id' - Nested object: 'metadata.user.user_id' - Mixed nesting: 'teams[*].members[*].user_id'
        - `references` string, required — Referenced context and column in format 'ContextName.column_name'
        - `on_delete` 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION' — Action to perform when referenced row is deleted
        - `on_update` 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION' — Action to perform when referenced row is updated
        - `default` unknown
        - `is_nested` boolean, nullable — Auto-set: True if this FK uses a nested path (contains . or [])
        - `path_segments` object[], nullable — Auto-set: Parsed path structure for nested FKs
    - string
  - `entries` union — Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. Values must be JSON serializable. If an `explicit_types` dictionary is present, its values will override the inferred types of the entries. The explicit_types dictionary can also specify if a field is mutable via a 'mutable' boolean flag, or unique via a 'unique' boolean flag. For enum types, use the EnumType model with 'values' list and optional 'restrict' flag. Omit 'values' to create an open enum (auto-seeding). If `infer_untyped_fields` is set to True, fields with type 'Any' (untyped) will have their type inferred from the logged values and updated, locking in the type. For contexts with nested unique IDs, parent ID values for the leftmost N-1 unique columns can be supplied as normal entry keys. The rightmost column is always auto-incremented. For example, if unique columns are ['user', 'session', 'step'], you can provide 'user' and 'session' values in entries, and 'step' will be auto-generated.
    - object
    - object[]
  - `recompute_derived` boolean — If True, recompute derived columns for the newly created logs using active ActiveDerivedLog templates. Suitable for small batches; for large ingestion workflows, leave False and rely on periodic backfill.

## Response `200`

Successful Response

- unknown

## Other responses

- `404` — Project Not Found
- `422` — Validation Error

---

[API](https://skmtc.net/unify/apis/unifyai-http-api-reference.md) · [All operations](https://skmtc.net/unify/apis/unifyai-http-api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/unify/unifyai-http-api-reference/revisions/900377f918b6/schema)
