---
title: "Create Span"
method: POST
path: "/spans"
tags: ["Spans"]
---

# Create Span

`POST /spans`

Create a new span with the provided parameters

## Request body

- CreateSpanRequest
  - `id` string, nullable — Unique identifier for the span. If not provided, an ID will be generated.
  - `trace_id` string, required — Unique identifier for the trace this span belongs to
  - `task_id` string, nullable — ID of the task this span belongs to
  - `parent_id` string, nullable — ID of the parent span if this is a child span in a trace
  - `name` string, required — Name that describes what operation this span represents
  - `start_time` string, date-time, required — The time the span started
  - `end_time` string, date-time, nullable — The time the span ended
  - `input` union — Input parameters or data for the operation
    - object
    - object[]
  - `output` union — Output data resulting from the operation
    - object
    - object[]
  - `data` union — Any additional metadata or context for the span
    - object
    - object[]

## Response `200`

Successful Response

- Span
  - `id` string, required
  - `trace_id` string, required — Unique identifier for the trace this span belongs to
  - `task_id` string, nullable — ID of the task this span belongs to
  - `parent_id` string, nullable — ID of the parent span if this is a child span in a trace
  - `name` string, required — Name that describes what operation this span represents
  - `start_time` string, date-time, required — The time the span started
  - `end_time` string, date-time, nullable — The time the span ended
  - `input` union — Input parameters or data for the operation
    - object
    - object[]
  - `output` union — Output data resulting from the operation
    - object
    - object[]
  - `data` union — Any additional metadata or context for the span
    - object
    - object[]

## Other responses

- `422` — Validation Error

## Changes

> 55 revisions in range; 4 could not be searched.

- **2026-04-21** `eeb5bf63b18d` — 2 info
  - added the new optional request property `task_id`
  - added the optional property `task_id` to the response with the `200` status

[Change history](https://skmtc.dev/scaleapi/apis/agentex-api/changes/spans/post.md)

---

[API](https://skmtc.dev/scaleapi/apis/agentex-api.md) · [All operations](https://skmtc.dev/scaleapi/apis/agentex-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/scaleapi/agentex-api/revisions/1e0aaafd5780/schema)
