Skip to main content
POST
/
v1
/
test-cases
/
generate
curl -X POST https://api.playgent.com/v1/test-cases/generate \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_abc123",
    "source_type": "documents",
    "documents": [
      {
        "content": "Our refund policy allows returns within 30 days...",
        "name": "refund_policy.md"
      }
    ],
    "generation_config": {
      "num_test_cases": 10,
      "difficulty_distribution": { "easy": 0.3, "medium": 0.5, "hard": 0.2 },
      "include_edge_cases": true,
      "focus_areas": ["policy_violations", "ambiguous_requests"]
    }
  }'
{
  "generated_test_cases": [
    {
      "name": "Edge Case: Refund after 30 days",
      "turns": [
        {
          "input": { "text": "I bought this 45 days ago, can I return it?" },
          "expected_behavior": "Agent should explain the 30-day policy limit"
        }
      ],
      "difficulty": "hard",
      "rationale": "Tests boundary condition of refund policy"
    }
  ],
  "coverage_analysis": {
    "policy_topics_covered": ["returns", "refunds", "exchanges"],
    "gaps_identified": ["international shipping returns not covered"]
  }
}

Documentation Index

Fetch the complete documentation index at: https://playgent.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Automatically generate test cases from documents, conversation logs, or failure analysis. This endpoint uses AI to create comprehensive test suites including edge cases.
agent_id
string
required
Agent to generate test cases for
source_type
string
required
Source type: documents, conversation_logs, or failure_analysis
documents
array
Documents to generate test cases from (when source_type is documents)
conversation_logs
array
Historical conversations (when source_type is conversation_logs)
generation_config
object
Configuration for test generation
generated_test_cases
array
required
Array of generated test cases
coverage_analysis
object
required
Analysis of topic coverage
curl -X POST https://api.playgent.com/v1/test-cases/generate \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_abc123",
    "source_type": "documents",
    "documents": [
      {
        "content": "Our refund policy allows returns within 30 days...",
        "name": "refund_policy.md"
      }
    ],
    "generation_config": {
      "num_test_cases": 10,
      "difficulty_distribution": { "easy": 0.3, "medium": 0.5, "hard": 0.2 },
      "include_edge_cases": true,
      "focus_areas": ["policy_violations", "ambiguous_requests"]
    }
  }'
{
  "generated_test_cases": [
    {
      "name": "Edge Case: Refund after 30 days",
      "turns": [
        {
          "input": { "text": "I bought this 45 days ago, can I return it?" },
          "expected_behavior": "Agent should explain the 30-day policy limit"
        }
      ],
      "difficulty": "hard",
      "rationale": "Tests boundary condition of refund policy"
    }
  ],
  "coverage_analysis": {
    "policy_topics_covered": ["returns", "refunds", "exchanges"],
    "gaps_identified": ["international shipping returns not covered"]
  }
}