> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# With Adaline API

> Send traces and spans directly to Adaline using the REST API

The Adaline REST API gives you direct HTTP access to the entire platform. Use it when you need to send telemetry from any language, integrate with CI/CD pipelines, build custom tooling, or work from environments where the SDK isn't available.

## What the API covers

The API spans 30+ endpoints across 9 resource types. Logging traces and spans is the most common starting point, but the same API key unlocks the full platform.

| Resource        | What you can do                                                                                     |
| --------------- | --------------------------------------------------------------------------------------------------- |
| **Logs**        | Create traces with spans, add spans to existing traces, update traces with feedback or metadata.    |
| **Deployments** | Fetch deployed prompt configurations (model, messages, tools, variables) by ID or environment.      |
| **Prompts**     | Create, list, get, update, and delete prompts. Manage drafts and playground configurations.         |
| **Datasets**    | Create and manage evaluation datasets — add columns, insert rows, fetch dynamic columns.            |
| **Evaluators**  | Create and configure evaluators (LLM judge, text match, JavaScript, JSON, cost, latency, and more). |
| **Evaluations** | Run evaluations against datasets, track progress, retrieve results.                                 |
| **Projects**    | List all projects accessible by your API key.                                                       |
| **Providers**   | List configured AI providers and their available models.                                            |
| **Models**      | List all available models, optionally filtered by provider.                                         |

## Base URL

```
https://api.adaline.ai/v2
```

A staging environment is also available at `https://api.staging.adaline.ai/v2`.

## Authentication

All requests require a Bearer token in the `Authorization` header.

```bash theme={null}
curl -X GET "https://api.adaline.ai/v2/projects" \
  -H "Authorization: Bearer your-api-key"
```

Get your API key from the [Adaline Dashboard](https://app.adaline.ai) under workspace settings. See the [Authentication reference](/docs/reference/auth) for full details.

If the key is missing or invalid, the API returns `401 Unauthorized`:

```json theme={null}
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key."
  }
}
```

## Rate limits

Default limits per workspace:

| Resource             | Limit            | Window     |
| -------------------- | ---------------- | ---------- |
| Log Trace endpoints  | 60,000 requests  | per minute |
| Log Span endpoints   | 150,000 requests | per minute |
| Deployment endpoints | 60,000 requests  | per minute |
| All other endpoints  | 6,000 requests   | per minute |

When exceeded, the API returns `429 Too Many Requests`. See [Limits reference](/docs/reference/limits) for payload size limits.

## Create a trace with spans

The primary logging endpoint. Send a trace and its spans in a single request:

```bash theme={null}
curl -X POST https://api.adaline.ai/v2/logs/trace \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "projectId": "your-project-id",
    "trace": {
      "name": "user-request",
      "status": "success",
      "startedAt": 1700000000000,
      "endedAt": 1700000005000,
      "referenceId": "trace-uuid",
      "sessionId": "session-abc123",
      "attributes": {
        "userId": "user-456",
        "environment": "production",
        "featureFlag": "new-prompt-v2"
      },
      "tags": ["production", "v2.1"]
    },
    "spans": [
      {
        "name": "chat-completion",
        "status": "success",
        "startedAt": 1700000001000,
        "endedAt": 1700000004500,
        "referenceId": "span-uuid",
        "promptId": "your-prompt-id",
        "deploymentId": "your-deployment-id",
        "runEvaluation": true,
        "content": {
          "type": "Model",
          "provider": "openai",
          "model": "gpt-4",
          "input": "{\"messages\": [...]}",
          "output": "{\"choices\": [...]}",
          "cost": 0.0032
        },
        "variables": {
          "user_question": {
            "modality": "text",
            "value": "How do I reset my password?"
          }
        },
        "tags": ["llm-call"],
        "attributes": {
          "temperature": 0.7
        }
      }
    ]
  }'
```

**Response** (`200 OK`):

```json theme={null}
{
  "traceId": "generated-trace-id",
  "spanIds": ["generated-span-id"]
}
```

## Add a span to an existing trace

Append a span to a trace that was created in a previous request:

```bash theme={null}
curl -X POST https://api.adaline.ai/v2/logs/span \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "traceId": "existing-trace-id",
    "projectId": "your-project-id",
    "name": "tool-execution",
    "status": "success",
    "startedAt": 1700000002000,
    "endedAt": 1700000003000,
    "referenceId": "tool-span-uuid",
    "content": {
      "type": "Tool",
      "input": "{\"query\": \"password reset\"}",
      "output": "{\"results\": [...]}"
    }
  }'
```

## Update a trace

Use `PATCH` to update trace attributes, tags, or status after creation. This is how you [log user feedback](/docs/instrument/log-user-feedback), add metadata after the fact, or correct a status:

```bash theme={null}
curl -X PATCH https://api.adaline.ai/v2/logs/trace \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "traceId": "existing-trace-id",
    "projectId": "your-project-id",
    "status": "success",
    "attributes": {
      "user_feedback": "positive",
      "user_feedback_comment": "Very helpful!",
      "user_feedback_rating": 5
    },
    "tags": ["thumbs-up"]
  }'
```

## Fetch deployments

Retrieve deployed prompt configurations — model settings, messages, tools, and variables — so your application can use the latest version without redeploying code.

```bash theme={null}
# Fetch a specific deployment
curl -X GET "https://api.adaline.ai/v2/deployments?promptId=your-prompt-id&deploymentId=your-deployment-id" \
  -H "Authorization: Bearer your-api-key"

# Fetch the latest deployment for an environment
curl -X GET "https://api.adaline.ai/v2/deployments?promptId=your-prompt-id&deploymentId=latest&deploymentEnvironmentId=your-env-id" \
  -H "Authorization: Bearer your-api-key"
```

The response includes the full prompt configuration:

```json theme={null}
{
  "id": "deployment-id",
  "projectId": "project-id",
  "promptId": "prompt-id",
  "deploymentEnvironmentId": "env-id",
  "prompt": {
    "config": {
      "providerName": "openai",
      "providerId": "provider-id",
      "model": "gpt-4",
      "settings": { "temperature": 0.7, "maxTokens": 1000 }
    },
    "messages": [...],
    "tools": [...],
    "variables": [{ "name": "user_question", "modality": "text" }]
  }
}
```

## Next steps

<CardGroup cols={2}>
  <Card title="With Adaline SDKs" icon="code" href="/docs/instrument/with-adaline-sdks">
    Use the TypeScript or Python SDK for automatic buffering, retries, and deployment caching.
  </Card>

  <Card title="API Reference" icon="braces" href="/docs/reference/api/v2/openapi/create-log-trace">
    Full OpenAPI endpoint documentation with request/response schemas.
  </Card>

  <Card title="Log User Feedback" icon="message-circle" href="/docs/instrument/log-user-feedback">
    Attach feedback signals to traces via the PATCH endpoint.
  </Card>

  <Card title="Authentication & Limits" icon="shield" href="/docs/reference/auth">
    API key management, rate limits, and payload constraints.
  </Card>
</CardGroup>
