The Freeplay HTTP API provides programmatic access to all platform capabilities. While the Freeplay SDKs offer language-native bindings for common operations, the API exposes the full range of functionality.
SDK vs. API: The Freeplay SDKs are designed to cover the most common integration patterns—prompt management, recording completions, and running tests. The HTTP API is a superset that includes additional capabilities like bulk operations, advanced search, and administrative endpoints.
Getting Started
Base URL
Your API root is your Freeplay instance URL plus/api/v2/.
| Deployment Type | Base URL |
|---|---|
| Cloud | https://app.freeplay.ai/api/v2 |
| Private | https://{your-subdomain}.freeplay.ai/api/v2 |
Authentication
Authenticate requests using your API key in the Authorization header:https://app.freeplay.ai/settings/api-access.
Error Handling
Freeplay uses standard HTTP status codes:| Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Malformed request or invalid data |
401 | Unauthorized - Invalid or missing API key |
404 | Not Found - Resource doesn’t exist or no access |
500 | Server Error - Transient issue, retry with backoff |
Observability
Freeplay organizes observability data in a hierarchy:- Sessions are created implicitly when you record your first completion with a session ID, or you can create one
- Traces are optional but required for agent workflows—they group related completions together
- Completions are the atomic unit: a prompt sent to an LLM and its response
Sessions
Sessions group related LLM completions together—typically representing a user conversation or workflow. Base URL:/api/v2/projects/<project-id>/sessions
Sessions are created implicitly when you record a completion. You only need to generate a session ID (UUID v4) client-side. For SDK usage, see Sessions.
Retrieve Sessions
GET /
Returns sessions with their completions, ordered by most recent first.
Query Parameters:
| Parameter | Type | Description | Required |
|---|---|---|---|
page | int | Page number | No (Default: 1) |
page_size | int | Results per page (max: 100) | No (Default: 10) |
from_date | str | Start date (inclusive). Format: YYYY-MM-DD | No |
to_date | str | End date (exclusive). Format: YYYY-MM-DD | No |
test_list | str | Filter by dataset name | No |
test_run_id | str | Filter by test run ID | No |
prompt_name | str | Filter by prompt template name | No |
review_queue_id | str | Filter by review queue ID | No |
custom_metadata.* | dict | Filter by session metadata | No |
Delete Session
DELETE /<session-id>
Permanently deletes a session and all associated completions.
Traces
Traces group related completions within a session. They’re essential for agent workflows where multiple LLM calls work together to accomplish a task. Base URL:/api/v2/projects/<project-id>/sessions/<session-id>/traces
For SDK usage, see Traces.
Record a Trace
POST /id/<trace-id>
Records a trace within a session. Like sessions, traces are created implicitly—generate a UUID v4 client-side and use it as the trace ID.
Request Payload:
| Parameter | Type | Description | Required |
|---|---|---|---|
input | any | Input to the trace (e.g., user query) | Yes |
output | any | Output from the trace (e.g., final response) | Yes |
agent_name | str | Name of the agent (required for agent workflows) | No |
name | str | Display name for the trace | No |
custom_metadata | dict[str, str|int|float|bool] | Custom metadata | No |
eval_results | dict[str, float|bool] | Code evaluation results | No |
parent_id | UUID | Parent trace ID for nested traces | No |
test_run_info | {test_run_id, test_case_id} | Test run association | No |
kind | "tool" | Set to "tool" for tool call traces | No |
start_time | datetime | Trace start time | No |
end_time | datetime | Trace end time | No |
Completions
Completions are the atomic unit of observability—a single LLM call with its prompt and response. Base URL:/api/v2/projects/<project-id>/sessions/<session-id>/completions
For SDK usage, see Recording Completions.
Record a Completion
POST /
Records an LLM completion to a session. This is the primary endpoint for logging LLM interactions.
Request Payload:
| Parameter | Type | Description | Required |
|---|---|---|---|
messages | list[{role, content}] | Messages sent to and received from the LLM | Yes |
inputs | dict[str, any] | Input variables used in the prompt | Yes |
prompt_info | {prompt_template_version_id, environment} | Prompt template info | Yes |
trace_info | {trace_id} | Associate completion with a trace | No |
tool_schema | list[{name, description, parameters}] | Tool definitions | No |
session_info | {custom_metadata: dict} | Session metadata | No |
call_info | {start_time, end_time, model, provider, usage, ...} | LLM call details | No |
test_run_info | {test_run_id, test_case_id} | Test run association | No |
completion_id | UUID | Custom completion ID | No |
eval_results | dict[str, bool|float] | Code evaluation results | No |
trace_info:
Prompt Templates
Create, retrieve, and manage prompt templates programmatically. For conceptual background on prompt management patterns, see Prompt Management. Base URL:/api/v2/projects/<project-id>/prompt-templates
Create Prompt Template
POST /
Creates a new prompt template (without any versions). Typically used when you want to create a template first, then add versions separately.
NOTE: The same objective can be accomplished using the create_template_if_not_exists parameter on the Create Version by Name endpoint below.
Request Payload:
| Parameter | Type | Description | Required |
|---|---|---|---|
name | str | Template name (unique within project) | Yes |
id | uuid | Custom template ID | No |
List Prompt Templates
GET /
Returns all prompt templates in a project with pagination.
Query Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
page | int | Page number | 1 |
page_size | int | Results per page (max: 100) | 30 |
Create Version by Name
POST /name/<template-name>/versions
Creates a new prompt version by template name. This is the recommended endpoint for CI/CD workflows because it supports creating the template automatically if it doesn’t exist.
Query Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
create_template_if_not_exists | boolean | Create template if not found | false |
| Parameter | Type | Description | Required |
|---|---|---|---|
template_messages | list[{role, content}] | Message array with mustache variables | Yes |
model | str | Model name | Yes |
provider | str | Provider key (openai, anthropic, etc.) | Yes |
llm_parameters | dict | Model parameters (temperature, etc.) | No |
tool_schema | list | Tool definitions | No |
output_schema | dict | Structured output schema | No |
version_name | str | Display name | No |
version_description | str | Description | No |
environments | list[str] | Environments to deploy to | No |
Retrieve by Name
POST /name/<template-name>
Fetches a prompt template in one of three forms:
| Form | Description | How to Request |
|---|---|---|
| Raw | Template with {{variable}} placeholders | No body, no format param |
| Bound | Variables inserted, provider-agnostic format | Pass variables in body |
| Formatted | Variables inserted, provider-specific format | Pass variables + format=true |
| Parameter | Type | Description | Default |
|---|---|---|---|
environment | str | Environment tag | latest |
format | boolean | Return formatted prompt | false |
Retrieve by Version ID
POST /id/<template-id>/versions/<version-id>
Fetch a specific prompt version. Useful for pinning to a known version.
Retrieve All Templates
GET /all/<environment-name>
Returns all prompt templates in an environment.
Create Version by ID
POST /id/<template-id>/versions
Adds a new version to an existing prompt template (identified only by ID). Deployed to latest by default.
Request Payload:
| Parameter | Type | Description | Required |
|---|---|---|---|
template_messages | list[{role, content}] | Message array with mustache variables | Yes |
model | str | Model name | Yes |
provider | str | Provider key (openai, anthropic, etc.) | Yes |
llm_parameters | dict | Model parameters (temperature, etc.) | No |
tool_schema | list | Tool definitions | No |
output_schema | dict | Structured output schema | No |
version_name | str | Display name | No |
version_description | str | Description | No |
environments | list[str] | Environments to deploy to | No |
Update Environments
POST /id/<template-id>/versions/<version-id>/environments
Assign a version to additional environments.
Test Runs
Execute batch tests using saved datasets. Base URL:/api/v2/projects/<project-id>/test-runs
Create Test Run
POST /
Creates a new test run from an existing dataset.
| Parameter | Type | Description | Required |
|---|---|---|---|
dataset_name | str | Name of the dataset | Yes |
include_outputs | boolean | Include expected outputs | No (Default: true) |
test_run_name | str | Display name | No |
test_run_description | str | Description | No |
Retrieve Test Run Results
GET /id/<test-run-id>
List Test Runs
GET /
| Parameter | Type | Description | Default |
|---|---|---|---|
page | int | Page number | 1 |
page_size | int | Results per page (max: 100) | 100 |
Customer Feedback
Record user feedback for completions and traces.Completion Feedback
Base URL:/api/v2/projects/<project-id>/completion-feedback
POST /id/<completion-id>
| Parameter | Type | Description | Required |
|---|---|---|---|
freeplay_feedback | str | "positive" or "negative" | Yes |
* | str|float|int|bool | Custom feedback attributes | No |
Trace Feedback
Base URL:/api/v2/projects/<project-id>/trace-feedback
POST /id/<trace-id>
Same parameters as completion feedback.
Search API
Query sessions, traces, and completions with powerful filtering. This functionality is API-only and not available through the SDKs.Endpoints
| Endpoint | Description |
|---|---|
POST /search/sessions | Search sessions |
POST /search/traces | Search traces |
POST /search/completions | Search completions |
page and page_size query parameters.
Filter Operators
| Operator | Description |
|---|---|
eq | Equals |
lt | Less than |
gt | Greater than |
lte | Less than or equal |
gte | Greater than or equal |
contains | Contains substring |
between | Within numeric range |
Available Filters
| Field | Supported Operators | Example Value |
|---|---|---|
cost | eq, lt, gt, lte, gte | 0.003 |
latency | eq, lt, gt, lte, gte | 8 |
start_time | eq, lt, gt, lte, gte | "2024-06-01 00:00:00" |
environment | eq | "staging" |
prompt_template | eq | "my-prompt" |
prompt_template_id | eq | "uuid..." |
model | eq | "gpt-4o" |
provider | eq | "openai" |
review_status | eq | "review_complete" |
agent_name | eq | "support-agent" |
trace_agent_name | eq | "my-agent" |
api_key | eq | "production-key" |
assignee | eq | "user@example.com" |
review_theme | eq | "Response Quality Issues" |
completion_output | contains | "weather" |
completion_inputs.* | contains | "topic": "weather" |
completion_feedback.* | contains | "rating": "positive" |
session_custom_metadata.* | contains | "user_type": "premium" |
trace_custom_metadata.* | contains | "workflow": "onboarding" |
trace_input.* | contains | "query": "weather" |
trace_output.* | contains | "response": "sunny" |
trace_feedback.* | contains | "rating": "positive" |
completion_evaluation_results.* | eq | "Response Quality": "4" |
completion_client_evaluation_results.* | eq | "score": "85" |
trace_evaluation_results.* | eq, gt, lt, gte, lte, contains | "Quality Score": 5 |
trace_client_eval_results.* | eq, contains | "confidence_score": 0.95 |
evaluation_notes.content | contains | "needs review" |
evaluation_notes.author | eq | "user@example.com" |
evaluation_notes.created_at | gt, lt, gte, lte | "2024-06-01 00:00:00" |
Compound Filters
Combine filters usingand, or, and not:
Additional API Endpoints
The following endpoints provide administrative and bulk operations not covered by the SDKs.Projects
Base URL:/api/v2/projects
List All Projects
GET /all
Returns all projects in your workspace.
Agents
Base URL:/api/v2/projects/<project-id>/agents
List Agents
GET /
| Parameter | Type | Description | Default |
|---|---|---|---|
page | int | Page number | 1 |
page_size | int | Results per page (max: 100) | 30 |
name | string | Filter by exact name | - |
Datasets
Base URL:/api/v2/projects/<project-id>/datasets
Retrieve Dataset Metadata
GET /name/<dataset-name> or GET /id/<dataset-id>
Retrieve Dataset Test Cases
GET /name/<dataset-name>/test-cases or GET /id/<dataset-id>/test-cases
Upload Test Cases
POST /id/<dataset-id>/test-cases
Maximum 100 test cases per request.
Completions Statistics
Base URL:/api/v2/projects/<project-id>/completions
Aggregate Statistics
POST /statistics
Returns evaluation statistics across all prompts for a date range (max 30 days).
| Parameter | Type | Description | Default |
|---|---|---|---|
from_date | str | Start date (inclusive) | 7 days ago |
to_date | str | End date (exclusive) | Today |
Statistics by Prompt
POST /statistics/<prompt-template-id>
Same parameters as aggregate statistics, filtered to a specific prompt template.
Complete Examples
End-to-End LLM Interaction
This example fetches a prompt, calls OpenAI, and records the completion:Executing a Test Run
Agent Workflow with Traces
This example shows how to record an agent workflow with multiple completions grouped by a trace:Next Steps
- SDK Setup - Language-native SDK installation
- Recording Completions - SDK-based observability
- Traces - Grouping completions for agent workflows
- Prompt Management - Managing prompts in Freeplay
- Test Runs - Batch testing concepts

