> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# Ingest traces (OTLP)

POST https://api.respan.ai/api/v2/traces
Content-Type: application/json

Accepts [OTLP/HTTP](https://opentelemetry.io/docs/specs/otlp/) JSON or protobuf. The span fields accepted by `POST /api/request-logs/` are not valid here. The `Sample two-span trace` example creates a workflow root span and one chat child span. Before rerunning it, replace `traceId` and `spanId` with new 32-hex and 16-hex IDs to create a separate trace.

For SDK setup, see the [Tracing quickstart](/docs/documentation/features/tracing/quickstart) or the [OpenTelemetry integration](/docs/integrations/opentelemetry), which configures the exporter automatically.

Reference: https://respan.ai/docs/apis/traces/ingest-traces-otlp

## Authentication

- `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \<RESPAN\_API\_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan\_params.credential\_override in the request body, not in this authentication field.

## Request

### Body (application/json)

This endpoint expects an object.

- `resourceSpans` (list of ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItems, required) — Array of resource spans. Each element represents spans from a single resource (service).

## Response

### 200

Spans accepted.

- `partialSuccess` (ApiV2TracesPostResponsesContentApplicationJsonSchemaPartialSuccess, optional)

## Errors

### 400 Bad Request Error

The payload isn't valid OTLP JSON.

- `detail` (string, required)

### 403 Forbidden Error

The API key is missing, invalid or expired.

- `detail` (string, required)

## Types

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItems

- `resource` (ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsResource, optional) — Resource metadata. Set `service.name` attribute to identify your application.
- `scopeSpans` (list of ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItems, optional) — Array of instrumentation scope spans.

### ApiV2TracesPostResponsesContentApplicationJsonSchemaPartialSuccess

- `rejectedSpans` (integer, optional) — Number of spans that failed to ingest.
- `errorMessage` (string, optional) — Error description (empty on success).

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsResource

Resource metadata. Set `service.name` attribute to identify your application.

- `attributes` (list of ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsResourceAttributesItems, optional) — Key-value attributes identifying the resource.

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItems

- `scope` (ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsScope, optional) — Instrumentation scope (library name and version).
- `spans` (list of ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItems, optional) — Array of span objects.

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsResourceAttributesItems

- `key` (string, optional)
- `value` (ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsResourceAttributesItemsValue, optional) — OTLP typed value. Use `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`.

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsScope

Instrumentation scope (library name and version).

- `name` (string, optional)
- `version` (string, optional)

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItems

- `traceId` (string, required) — Hex-encoded trace ID (32 hex chars).
- `spanId` (string, required) — Hex-encoded span ID (16 hex chars).
- `name` (string, required) — Span operation name.
- `startTimeUnixNano` (string, required) — Start time as nanoseconds since Unix epoch.
- `endTimeUnixNano` (string, required) — End time as nanoseconds since Unix epoch.
- `parentSpanId` (string, optional) — Parent span ID. Empty for root spans.
- `status` (ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsStatus, optional) — Span status.
- `attributes` (list of ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsAttributesItems, optional) — Span attributes as OTLP key-value pairs. Values use OTLP typed wrappers: `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`. **Trace shape:** use `traceloop.span.kind` (`workflow`, `task`, `tool`, `chat`, etc.) to classify spans, and `traceloop.workflow.name` to make the workflow name searchable. For chat/completion child spans, include `llm.request.type` (`chat` or `completion`) so model, messages, and token fields are promoted. **LLM fields:** `gen_ai.request.model`, `gen_ai.response.model`, `gen_ai.usage.prompt_tokens`, `gen_ai.usage.completion_tokens`, `gen_ai.usage.total_tokens`, `gen_ai.prompt.{N}.role`, `gen_ai.prompt.{N}.content`, `gen_ai.completion.{N}.role`, `gen_ai.completion.{N}.content`. **Respan fields:** `respan.customer_params.customer_identifier`, `respan.customer_params.email`, `respan.customer_params.name`, `respan.threads.thread_identifier`, `respan.trace.trace_group_identifier`, and `respan.metadata.<key>` for custom metadata. All other attributes are stored in metadata and queryable via metadata filters.
- `events` (list of ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsEventsItems, optional) — Span events (e.g. exceptions). Each has `name`, `timeUnixNano`, and `attributes`.

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsResourceAttributesItemsValue

OTLP typed value. Use `stringValue`, `intValue`, `doubleValue`, `boolValue`, `arrayValue`, or `kvlistValue`.

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsStatus

Span status.

- `code` (enum, optional) — `1` = OK, `2` = ERROR.
  - Allowed values: `1`, `2`
- `message` (string, optional) — Error description (when code=2).

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsAttributesItems

- `key` (string, optional)
- `value` (ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsAttributesItemsValue, optional)

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsEventsItems

### ApiV2TracesPostRequestBodyContentApplicationJsonSchemaResourceSpansItemsScopeSpansItemsSpansItemsAttributesItemsValue

## Examples

### Traces_createTrace_example

**Response**

```json
{
  "partialSuccess": {
    "rejectedSpans": 0,
    "errorMessage": ""
  }
}
```

**SDK Code**

```python Traces_createTrace_example
import requests

url = "https://api.respan.ai/api/v2/traces"

headers = {"Authorization": "Bearer <respanApiKey>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Traces_createTrace_example
const url = 'https://api.respan.ai/api/v2/traces';
const options = {method: 'POST', headers: {Authorization: 'Bearer <respanApiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Traces_createTrace_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.respan.ai/api/v2/traces"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <respanApiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Traces_createTrace_example
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/v2/traces")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <respanApiKey>'

response = http.request(request)
puts response.read_body
```

```java Traces_createTrace_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.respan.ai/api/v2/traces")
  .header("Authorization", "Bearer <respanApiKey>")
  .asString();
```

```php Traces_createTrace_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.respan.ai/api/v2/traces', [
  'headers' => [
    'Authorization' => 'Bearer <respanApiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Traces_createTrace_example
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/v2/traces");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <respanApiKey>");
IRestResponse response = client.Execute(request);
```

```swift Traces_createTrace_example
import Foundation

let headers = ["Authorization": "Bearer <respanApiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/v2/traces")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Sample two-span trace

**Request**

```json
{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {
            "key": "service.name",
            "value": {
              "stringValue": "respan-docs-api-reference"
            }
          }
        ]
      },
      "scopeSpans": [
        {
          "scope": {
            "name": "manual-api-reference",
            "version": "1.0.0"
          },
          "spans": [
            {
              "traceId": "11111111111111111111111111111111",
              "spanId": "2222222222222222",
              "name": "sample_trace",
              "startTimeUnixNano": "1780000000000000000",
              "endTimeUnixNano": "1780000001000000000",
              "status": {
                "code": 1
              },
              "attributes": [
                {
                  "key": "traceloop.span.kind",
                  "value": {
                    "stringValue": "workflow"
                  }
                },
                {
                  "key": "traceloop.workflow.name",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.trace.trace_group_identifier",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.customer_params.customer_identifier",
                  "value": {
                    "stringValue": "docs-sample-user"
                  }
                },
                {
                  "key": "respan.metadata.source",
                  "value": {
                    "stringValue": "api-reference-create-trace"
                  }
                }
              ]
            },
            {
              "traceId": "11111111111111111111111111111111",
              "spanId": "3333333333333333",
              "name": "sample_llm_call",
              "startTimeUnixNano": "1780000000100000000",
              "endTimeUnixNano": "1780000000900000000",
              "parentSpanId": "2222222222222222",
              "status": {
                "code": 1
              },
              "attributes": [
                {
                  "key": "traceloop.span.kind",
                  "value": {
                    "stringValue": "chat"
                  }
                },
                {
                  "key": "llm.request.type",
                  "value": {
                    "stringValue": "chat"
                  }
                },
                {
                  "key": "traceloop.workflow.name",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.trace.trace_group_identifier",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.customer_params.customer_identifier",
                  "value": {
                    "stringValue": "docs-sample-user"
                  }
                },
                {
                  "key": "gen_ai.system",
                  "value": {
                    "stringValue": "openai"
                  }
                },
                {
                  "key": "gen_ai.request.model",
                  "value": {
                    "stringValue": "gpt-4o-mini"
                  }
                },
                {
                  "key": "gen_ai.response.model",
                  "value": {
                    "stringValue": "gpt-4o-mini"
                  }
                },
                {
                  "key": "gen_ai.prompt.0.role",
                  "value": {
                    "stringValue": "user"
                  }
                },
                {
                  "key": "gen_ai.prompt.0.content",
                  "value": {
                    "stringValue": "Hello from the Create a trace API reference."
                  }
                },
                {
                  "key": "gen_ai.completion.0.role",
                  "value": {
                    "stringValue": "assistant"
                  }
                },
                {
                  "key": "gen_ai.completion.0.content",
                  "value": {
                    "stringValue": "Hello! This is a sample trace."
                  }
                },
                {
                  "key": "gen_ai.usage.prompt_tokens",
                  "value": {
                    "intValue": "9"
                  }
                },
                {
                  "key": "gen_ai.usage.completion_tokens",
                  "value": {
                    "intValue": "8"
                  }
                },
                {
                  "key": "gen_ai.usage.total_tokens",
                  "value": {
                    "intValue": "17"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
```

**Response**

```json
{
  "partialSuccess": {
    "rejectedSpans": 0,
    "errorMessage": ""
  }
}
```

**SDK Code**

```python Sample two-span trace
import requests

url = "https://api.respan.ai/api/v2/traces"

payload = { "resourceSpans": [
        {
            "resource": { "attributes": [
                    {
                        "key": "service.name",
                        "value": { "stringValue": "respan-docs-api-reference" }
                    }
                ] },
            "scopeSpans": [
                {
                    "scope": {
                        "name": "manual-api-reference",
                        "version": "1.0.0"
                    },
                    "spans": [
                        {
                            "traceId": "11111111111111111111111111111111",
                            "spanId": "2222222222222222",
                            "name": "sample_trace",
                            "startTimeUnixNano": "1780000000000000000",
                            "endTimeUnixNano": "1780000001000000000",
                            "status": { "code": 1 },
                            "attributes": [
                                {
                                    "key": "traceloop.span.kind",
                                    "value": { "stringValue": "workflow" }
                                },
                                {
                                    "key": "traceloop.workflow.name",
                                    "value": { "stringValue": "api-reference-sample-trace" }
                                },
                                {
                                    "key": "respan.trace.trace_group_identifier",
                                    "value": { "stringValue": "api-reference-sample-trace" }
                                },
                                {
                                    "key": "respan.customer_params.customer_identifier",
                                    "value": { "stringValue": "docs-sample-user" }
                                },
                                {
                                    "key": "respan.metadata.source",
                                    "value": { "stringValue": "api-reference-create-trace" }
                                }
                            ]
                        },
                        {
                            "traceId": "11111111111111111111111111111111",
                            "spanId": "3333333333333333",
                            "name": "sample_llm_call",
                            "startTimeUnixNano": "1780000000100000000",
                            "endTimeUnixNano": "1780000000900000000",
                            "parentSpanId": "2222222222222222",
                            "status": { "code": 1 },
                            "attributes": [
                                {
                                    "key": "traceloop.span.kind",
                                    "value": { "stringValue": "chat" }
                                },
                                {
                                    "key": "llm.request.type",
                                    "value": { "stringValue": "chat" }
                                },
                                {
                                    "key": "traceloop.workflow.name",
                                    "value": { "stringValue": "api-reference-sample-trace" }
                                },
                                {
                                    "key": "respan.trace.trace_group_identifier",
                                    "value": { "stringValue": "api-reference-sample-trace" }
                                },
                                {
                                    "key": "respan.customer_params.customer_identifier",
                                    "value": { "stringValue": "docs-sample-user" }
                                },
                                {
                                    "key": "gen_ai.system",
                                    "value": { "stringValue": "openai" }
                                },
                                {
                                    "key": "gen_ai.request.model",
                                    "value": { "stringValue": "gpt-4o-mini" }
                                },
                                {
                                    "key": "gen_ai.response.model",
                                    "value": { "stringValue": "gpt-4o-mini" }
                                },
                                {
                                    "key": "gen_ai.prompt.0.role",
                                    "value": { "stringValue": "user" }
                                },
                                {
                                    "key": "gen_ai.prompt.0.content",
                                    "value": { "stringValue": "Hello from the Create a trace API reference." }
                                },
                                {
                                    "key": "gen_ai.completion.0.role",
                                    "value": { "stringValue": "assistant" }
                                },
                                {
                                    "key": "gen_ai.completion.0.content",
                                    "value": { "stringValue": "Hello! This is a sample trace." }
                                },
                                {
                                    "key": "gen_ai.usage.prompt_tokens",
                                    "value": { "intValue": "9" }
                                },
                                {
                                    "key": "gen_ai.usage.completion_tokens",
                                    "value": { "intValue": "8" }
                                },
                                {
                                    "key": "gen_ai.usage.total_tokens",
                                    "value": { "intValue": "17" }
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ] }
headers = {
    "Authorization": "Bearer <respanApiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Sample two-span trace
const url = 'https://api.respan.ai/api/v2/traces';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <respanApiKey>', 'Content-Type': 'application/json'},
  body: '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"respan-docs-api-reference"}}]},"scopeSpans":[{"scope":{"name":"manual-api-reference","version":"1.0.0"},"spans":[{"traceId":"11111111111111111111111111111111","spanId":"2222222222222222","name":"sample_trace","startTimeUnixNano":"1780000000000000000","endTimeUnixNano":"1780000001000000000","status":{"code":1},"attributes":[{"key":"traceloop.span.kind","value":{"stringValue":"workflow"}},{"key":"traceloop.workflow.name","value":{"stringValue":"api-reference-sample-trace"}},{"key":"respan.trace.trace_group_identifier","value":{"stringValue":"api-reference-sample-trace"}},{"key":"respan.customer_params.customer_identifier","value":{"stringValue":"docs-sample-user"}},{"key":"respan.metadata.source","value":{"stringValue":"api-reference-create-trace"}}]},{"traceId":"11111111111111111111111111111111","spanId":"3333333333333333","name":"sample_llm_call","startTimeUnixNano":"1780000000100000000","endTimeUnixNano":"1780000000900000000","parentSpanId":"2222222222222222","status":{"code":1},"attributes":[{"key":"traceloop.span.kind","value":{"stringValue":"chat"}},{"key":"llm.request.type","value":{"stringValue":"chat"}},{"key":"traceloop.workflow.name","value":{"stringValue":"api-reference-sample-trace"}},{"key":"respan.trace.trace_group_identifier","value":{"stringValue":"api-reference-sample-trace"}},{"key":"respan.customer_params.customer_identifier","value":{"stringValue":"docs-sample-user"}},{"key":"gen_ai.system","value":{"stringValue":"openai"}},{"key":"gen_ai.request.model","value":{"stringValue":"gpt-4o-mini"}},{"key":"gen_ai.response.model","value":{"stringValue":"gpt-4o-mini"}},{"key":"gen_ai.prompt.0.role","value":{"stringValue":"user"}},{"key":"gen_ai.prompt.0.content","value":{"stringValue":"Hello from the Create a trace API reference."}},{"key":"gen_ai.completion.0.role","value":{"stringValue":"assistant"}},{"key":"gen_ai.completion.0.content","value":{"stringValue":"Hello! This is a sample trace."}},{"key":"gen_ai.usage.prompt_tokens","value":{"intValue":"9"}},{"key":"gen_ai.usage.completion_tokens","value":{"intValue":"8"}},{"key":"gen_ai.usage.total_tokens","value":{"intValue":"17"}}]}]}]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Sample two-span trace
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.respan.ai/api/v2/traces"

	payload := strings.NewReader("{\n  \"resourceSpans\": [\n    {\n      \"resource\": {\n        \"attributes\": [\n          {\n            \"key\": \"service.name\",\n            \"value\": {\n              \"stringValue\": \"respan-docs-api-reference\"\n            }\n          }\n        ]\n      },\n      \"scopeSpans\": [\n        {\n          \"scope\": {\n            \"name\": \"manual-api-reference\",\n            \"version\": \"1.0.0\"\n          },\n          \"spans\": [\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"2222222222222222\",\n              \"name\": \"sample_trace\",\n              \"startTimeUnixNano\": \"1780000000000000000\",\n              \"endTimeUnixNano\": \"1780000001000000000\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"workflow\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"respan.metadata.source\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-create-trace\"\n                  }\n                }\n              ]\n            },\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"3333333333333333\",\n              \"name\": \"sample_llm_call\",\n              \"startTimeUnixNano\": \"1780000000100000000\",\n              \"endTimeUnixNano\": \"1780000000900000000\",\n              \"parentSpanId\": \"2222222222222222\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"llm.request.type\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.system\",\n                  \"value\": {\n                    \"stringValue\": \"openai\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.request.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.response.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello from the Create a trace API reference.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"assistant\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello! This is a sample trace.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.prompt_tokens\",\n                  \"value\": {\n                    \"intValue\": \"9\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.completion_tokens\",\n                  \"value\": {\n                    \"intValue\": \"8\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.total_tokens\",\n                  \"value\": {\n                    \"intValue\": \"17\"\n                  }\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <respanApiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Sample two-span trace
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/v2/traces")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <respanApiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"resourceSpans\": [\n    {\n      \"resource\": {\n        \"attributes\": [\n          {\n            \"key\": \"service.name\",\n            \"value\": {\n              \"stringValue\": \"respan-docs-api-reference\"\n            }\n          }\n        ]\n      },\n      \"scopeSpans\": [\n        {\n          \"scope\": {\n            \"name\": \"manual-api-reference\",\n            \"version\": \"1.0.0\"\n          },\n          \"spans\": [\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"2222222222222222\",\n              \"name\": \"sample_trace\",\n              \"startTimeUnixNano\": \"1780000000000000000\",\n              \"endTimeUnixNano\": \"1780000001000000000\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"workflow\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"respan.metadata.source\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-create-trace\"\n                  }\n                }\n              ]\n            },\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"3333333333333333\",\n              \"name\": \"sample_llm_call\",\n              \"startTimeUnixNano\": \"1780000000100000000\",\n              \"endTimeUnixNano\": \"1780000000900000000\",\n              \"parentSpanId\": \"2222222222222222\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"llm.request.type\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.system\",\n                  \"value\": {\n                    \"stringValue\": \"openai\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.request.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.response.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello from the Create a trace API reference.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"assistant\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello! This is a sample trace.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.prompt_tokens\",\n                  \"value\": {\n                    \"intValue\": \"9\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.completion_tokens\",\n                  \"value\": {\n                    \"intValue\": \"8\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.total_tokens\",\n                  \"value\": {\n                    \"intValue\": \"17\"\n                  }\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Sample two-span trace
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.respan.ai/api/v2/traces")
  .header("Authorization", "Bearer <respanApiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"resourceSpans\": [\n    {\n      \"resource\": {\n        \"attributes\": [\n          {\n            \"key\": \"service.name\",\n            \"value\": {\n              \"stringValue\": \"respan-docs-api-reference\"\n            }\n          }\n        ]\n      },\n      \"scopeSpans\": [\n        {\n          \"scope\": {\n            \"name\": \"manual-api-reference\",\n            \"version\": \"1.0.0\"\n          },\n          \"spans\": [\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"2222222222222222\",\n              \"name\": \"sample_trace\",\n              \"startTimeUnixNano\": \"1780000000000000000\",\n              \"endTimeUnixNano\": \"1780000001000000000\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"workflow\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"respan.metadata.source\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-create-trace\"\n                  }\n                }\n              ]\n            },\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"3333333333333333\",\n              \"name\": \"sample_llm_call\",\n              \"startTimeUnixNano\": \"1780000000100000000\",\n              \"endTimeUnixNano\": \"1780000000900000000\",\n              \"parentSpanId\": \"2222222222222222\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"llm.request.type\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.system\",\n                  \"value\": {\n                    \"stringValue\": \"openai\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.request.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.response.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello from the Create a trace API reference.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"assistant\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello! This is a sample trace.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.prompt_tokens\",\n                  \"value\": {\n                    \"intValue\": \"9\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.completion_tokens\",\n                  \"value\": {\n                    \"intValue\": \"8\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.total_tokens\",\n                  \"value\": {\n                    \"intValue\": \"17\"\n                  }\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Sample two-span trace
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.respan.ai/api/v2/traces', [
  'body' => '{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {
            "key": "service.name",
            "value": {
              "stringValue": "respan-docs-api-reference"
            }
          }
        ]
      },
      "scopeSpans": [
        {
          "scope": {
            "name": "manual-api-reference",
            "version": "1.0.0"
          },
          "spans": [
            {
              "traceId": "11111111111111111111111111111111",
              "spanId": "2222222222222222",
              "name": "sample_trace",
              "startTimeUnixNano": "1780000000000000000",
              "endTimeUnixNano": "1780000001000000000",
              "status": {
                "code": 1
              },
              "attributes": [
                {
                  "key": "traceloop.span.kind",
                  "value": {
                    "stringValue": "workflow"
                  }
                },
                {
                  "key": "traceloop.workflow.name",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.trace.trace_group_identifier",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.customer_params.customer_identifier",
                  "value": {
                    "stringValue": "docs-sample-user"
                  }
                },
                {
                  "key": "respan.metadata.source",
                  "value": {
                    "stringValue": "api-reference-create-trace"
                  }
                }
              ]
            },
            {
              "traceId": "11111111111111111111111111111111",
              "spanId": "3333333333333333",
              "name": "sample_llm_call",
              "startTimeUnixNano": "1780000000100000000",
              "endTimeUnixNano": "1780000000900000000",
              "parentSpanId": "2222222222222222",
              "status": {
                "code": 1
              },
              "attributes": [
                {
                  "key": "traceloop.span.kind",
                  "value": {
                    "stringValue": "chat"
                  }
                },
                {
                  "key": "llm.request.type",
                  "value": {
                    "stringValue": "chat"
                  }
                },
                {
                  "key": "traceloop.workflow.name",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.trace.trace_group_identifier",
                  "value": {
                    "stringValue": "api-reference-sample-trace"
                  }
                },
                {
                  "key": "respan.customer_params.customer_identifier",
                  "value": {
                    "stringValue": "docs-sample-user"
                  }
                },
                {
                  "key": "gen_ai.system",
                  "value": {
                    "stringValue": "openai"
                  }
                },
                {
                  "key": "gen_ai.request.model",
                  "value": {
                    "stringValue": "gpt-4o-mini"
                  }
                },
                {
                  "key": "gen_ai.response.model",
                  "value": {
                    "stringValue": "gpt-4o-mini"
                  }
                },
                {
                  "key": "gen_ai.prompt.0.role",
                  "value": {
                    "stringValue": "user"
                  }
                },
                {
                  "key": "gen_ai.prompt.0.content",
                  "value": {
                    "stringValue": "Hello from the Create a trace API reference."
                  }
                },
                {
                  "key": "gen_ai.completion.0.role",
                  "value": {
                    "stringValue": "assistant"
                  }
                },
                {
                  "key": "gen_ai.completion.0.content",
                  "value": {
                    "stringValue": "Hello! This is a sample trace."
                  }
                },
                {
                  "key": "gen_ai.usage.prompt_tokens",
                  "value": {
                    "intValue": "9"
                  }
                },
                {
                  "key": "gen_ai.usage.completion_tokens",
                  "value": {
                    "intValue": "8"
                  }
                },
                {
                  "key": "gen_ai.usage.total_tokens",
                  "value": {
                    "intValue": "17"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <respanApiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Sample two-span trace
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/v2/traces");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <respanApiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"resourceSpans\": [\n    {\n      \"resource\": {\n        \"attributes\": [\n          {\n            \"key\": \"service.name\",\n            \"value\": {\n              \"stringValue\": \"respan-docs-api-reference\"\n            }\n          }\n        ]\n      },\n      \"scopeSpans\": [\n        {\n          \"scope\": {\n            \"name\": \"manual-api-reference\",\n            \"version\": \"1.0.0\"\n          },\n          \"spans\": [\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"2222222222222222\",\n              \"name\": \"sample_trace\",\n              \"startTimeUnixNano\": \"1780000000000000000\",\n              \"endTimeUnixNano\": \"1780000001000000000\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"workflow\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"respan.metadata.source\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-create-trace\"\n                  }\n                }\n              ]\n            },\n            {\n              \"traceId\": \"11111111111111111111111111111111\",\n              \"spanId\": \"3333333333333333\",\n              \"name\": \"sample_llm_call\",\n              \"startTimeUnixNano\": \"1780000000100000000\",\n              \"endTimeUnixNano\": \"1780000000900000000\",\n              \"parentSpanId\": \"2222222222222222\",\n              \"status\": {\n                \"code\": 1\n              },\n              \"attributes\": [\n                {\n                  \"key\": \"traceloop.span.kind\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"llm.request.type\",\n                  \"value\": {\n                    \"stringValue\": \"chat\"\n                  }\n                },\n                {\n                  \"key\": \"traceloop.workflow.name\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.trace.trace_group_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"api-reference-sample-trace\"\n                  }\n                },\n                {\n                  \"key\": \"respan.customer_params.customer_identifier\",\n                  \"value\": {\n                    \"stringValue\": \"docs-sample-user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.system\",\n                  \"value\": {\n                    \"stringValue\": \"openai\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.request.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.response.model\",\n                  \"value\": {\n                    \"stringValue\": \"gpt-4o-mini\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"user\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.prompt.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello from the Create a trace API reference.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.role\",\n                  \"value\": {\n                    \"stringValue\": \"assistant\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.completion.0.content\",\n                  \"value\": {\n                    \"stringValue\": \"Hello! This is a sample trace.\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.prompt_tokens\",\n                  \"value\": {\n                    \"intValue\": \"9\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.completion_tokens\",\n                  \"value\": {\n                    \"intValue\": \"8\"\n                  }\n                },\n                {\n                  \"key\": \"gen_ai.usage.total_tokens\",\n                  \"value\": {\n                    \"intValue\": \"17\"\n                  }\n                }\n              ]\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Sample two-span trace
import Foundation

let headers = [
  "Authorization": "Bearer <respanApiKey>",
  "Content-Type": "application/json"
]
let parameters = ["resourceSpans": [
    [
      "resource": ["attributes": [
          [
            "key": "service.name",
            "value": ["stringValue": "respan-docs-api-reference"]
          ]
        ]],
      "scopeSpans": [
        [
          "scope": [
            "name": "manual-api-reference",
            "version": "1.0.0"
          ],
          "spans": [
            [
              "traceId": "11111111111111111111111111111111",
              "spanId": "2222222222222222",
              "name": "sample_trace",
              "startTimeUnixNano": "1780000000000000000",
              "endTimeUnixNano": "1780000001000000000",
              "status": ["code": 1],
              "attributes": [
                [
                  "key": "traceloop.span.kind",
                  "value": ["stringValue": "workflow"]
                ],
                [
                  "key": "traceloop.workflow.name",
                  "value": ["stringValue": "api-reference-sample-trace"]
                ],
                [
                  "key": "respan.trace.trace_group_identifier",
                  "value": ["stringValue": "api-reference-sample-trace"]
                ],
                [
                  "key": "respan.customer_params.customer_identifier",
                  "value": ["stringValue": "docs-sample-user"]
                ],
                [
                  "key": "respan.metadata.source",
                  "value": ["stringValue": "api-reference-create-trace"]
                ]
              ]
            ],
            [
              "traceId": "11111111111111111111111111111111",
              "spanId": "3333333333333333",
              "name": "sample_llm_call",
              "startTimeUnixNano": "1780000000100000000",
              "endTimeUnixNano": "1780000000900000000",
              "parentSpanId": "2222222222222222",
              "status": ["code": 1],
              "attributes": [
                [
                  "key": "traceloop.span.kind",
                  "value": ["stringValue": "chat"]
                ],
                [
                  "key": "llm.request.type",
                  "value": ["stringValue": "chat"]
                ],
                [
                  "key": "traceloop.workflow.name",
                  "value": ["stringValue": "api-reference-sample-trace"]
                ],
                [
                  "key": "respan.trace.trace_group_identifier",
                  "value": ["stringValue": "api-reference-sample-trace"]
                ],
                [
                  "key": "respan.customer_params.customer_identifier",
                  "value": ["stringValue": "docs-sample-user"]
                ],
                [
                  "key": "gen_ai.system",
                  "value": ["stringValue": "openai"]
                ],
                [
                  "key": "gen_ai.request.model",
                  "value": ["stringValue": "gpt-4o-mini"]
                ],
                [
                  "key": "gen_ai.response.model",
                  "value": ["stringValue": "gpt-4o-mini"]
                ],
                [
                  "key": "gen_ai.prompt.0.role",
                  "value": ["stringValue": "user"]
                ],
                [
                  "key": "gen_ai.prompt.0.content",
                  "value": ["stringValue": "Hello from the Create a trace API reference."]
                ],
                [
                  "key": "gen_ai.completion.0.role",
                  "value": ["stringValue": "assistant"]
                ],
                [
                  "key": "gen_ai.completion.0.content",
                  "value": ["stringValue": "Hello! This is a sample trace."]
                ],
                [
                  "key": "gen_ai.usage.prompt_tokens",
                  "value": ["intValue": "9"]
                ],
                [
                  "key": "gen_ai.usage.completion_tokens",
                  "value": ["intValue": "8"]
                ],
                [
                  "key": "gen_ai.usage.total_tokens",
                  "value": ["intValue": "17"]
                ]
              ]
            ]
          ]
        ]
      ]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/v2/traces")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```