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/.
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:
Example Error Response:
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:
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:
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:
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:
List Prompt Templates
GET /
Returns all prompt templates in a project with pagination.
Query Parameters:
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:
Request Payload:
Retrieve by Name
POST /name/<template-name>
Fetches a prompt template in one of three forms:
Query Parameters:
Formatted Prompt (most common):
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:
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.
Retrieve Test Run Results
GET /id/<test-run-id>
List Test Runs
GET /
Customer Feedback
Record user feedback for completions and traces.Completion Feedback
Base URL:/api/v2/projects/<project-id>/completion-feedback
POST /id/<completion-id>
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
All endpoints support pagination via
page and page_size query parameters.
Filter Operators
Available Filters
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 /
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).
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

