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

# Create red team spec

> Create a new red team specification

## What is Red Teaming?

Red teaming generates adversarial prompts designed to test your LLM application's safety guardrails. Given a description of your application and its domain, it identifies potential undesirable behaviors and creates prompts that attempt to trigger them.

**Workflow:**

1. Create a red team spec (this endpoint) describing your application
2. [Create a run](/api-reference/red-teaming/create-run) to generate adversarial prompts
3. [Poll the status](/api-reference/red-teaming/run-status) until complete
4. [Get the results](/api-reference/red-teaming/get-run) containing behaviors and adversarial prompts

<Warning>
  **When to use the main Specs/Runs workflow instead:** Red teaming is designed for generating relatively short adversarial prompts and produces fewer than 100 prompts per run. If you need large volumes of diverse, complex synthetic data, use the main [Specs](/api-reference/specs/create) and [Runs](/api-reference/runs/create) workflow instead.
</Warning>

<Note>
  Spec names are automatically converted to snake\_case and must be unique within your company.
</Note>


## OpenAPI

````yaml POST /api/dataframer/red-team-specs/
openapi: 3.0.0
info:
  title: DataFramer API
  version: 0.1.0
  description: ''
  termsOfService: https://www.aimon.ai/docs/privacy-policy.pdf
  contact:
    name: DataFramer Support
    email: info@dataframer.ai
  license:
    name: Proprietary
  x-logo:
    url: https://dataframer.ai/logo.png
    altText: DataFramer AI
  x-stainless:
    package-name: aimon-dataframer
    namespace:
      - aimon
      - dataframer
servers:
  - url: https://df-api.dataframer.ai
    description: Production server
security:
  - BearerAuth: []
tags:
  - name: Seed Datasets
    description: Manage seed datasets for generation
  - name: Specs
    description: Data specifications for sample generation
  - name: Runs
    description: Generation runs and results
  - name: Evaluations
    description: Evaluate generated sample quality
  - name: Red Teaming
    description: Security testing and adversarial prompts
  - name: Spec Creation
    description: Create specs from datasets or from scratch (seedless)
  - name: Generation
    description: Synthetic data generation
  - name: API Keys
    description: API key management and rotation
  - name: Health
    description: Health check endpoints
  - name: Models
    description: Available AI models
externalDocs:
  description: Complete API Guide
  url: https://docs.dataframer.ai/dataframer
paths:
  /api/dataframer/red-team-specs/:
    post:
      tags:
        - Red Teaming
      summary: Create red team spec
      description: >-
        Create a new red team specification.


        ## What is Red Teaming?


        Red teaming generates adversarial prompts designed to test your LLM
        application's safety guardrails. Given a description of your application
        and its domain, it identifies potential undesirable behaviors and
        creates prompts that attempt to trigger them.


        **Workflow:**

        1. Create a red team spec (this endpoint) describing your application

        2. Create a run to generate adversarial prompts

        3. Poll the status until complete

        4. Get the results containing behaviors and adversarial prompts


        **When to use the main Specs/Runs workflow instead:** Red teaming is
        designed for generating relatively short adversarial prompts and
        produces fewer than 100 prompts per run. If you need large volumes of
        diverse, complex synthetic data, use the main Specs and Runs workflow
        instead.


        Spec names are automatically converted to snake_case and must be unique
        within your company.
      operationId: api_dataframer_red-team-specs_create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RedTeamSpecCreate'
            examples:
              healthcare_chatbot:
                summary: Healthcare chatbot spec
                value:
                  name: Healthcare Chatbot
                  domain_description: Healthcare and medical information services
                  app_description: >-
                    A patient-facing chatbot that helps schedule appointments
                    and answer general health questions
                  concerns: >-
                    Should not provide medical diagnoses, prescription
                    recommendations, or treatment advice
              ecommerce_assistant:
                summary: E-commerce assistant spec
                value:
                  name: E-commerce Assistant
                  domain_description: Online retail and e-commerce
                  app_description: >-
                    A customer service chatbot for an online store that handles
                    order inquiries and product questions
      responses:
        '201':
          description: Red team spec created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RedTeamSpec'
        '400':
          description: Validation error (missing required fields or duplicate name)
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: array
                    items:
                      type: string
                    example:
                      - Red Team Spec with name "my_spec" already exists
                  domain_description:
                    type: array
                    items:
                      type: string
                    example:
                      - This field is required.
                  app_description:
                    type: array
                    items:
                      type: string
                    example:
                      - This field is required.
        '401':
          description: Authentication credentials were not provided
        '402':
          description: Payment required - subscription inactive
        '500':
          description: Internal server error
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Dataframer from 'dataframer';

            const client = new Dataframer({
              apiKey: process.env['DATAFRAMER_API_KEY'], // This is the default and can be omitted
            });

            const redTeamSpec = await client.dataframer.redTeamSpecs.create({
              app_description:
                'A patient-facing chatbot that helps schedule appointments and answer general health questions',
              domain_description: 'Healthcare and medical information services',
              name: 'Healthcare Chatbot',
              concerns:
                'Should not provide medical diagnoses, prescription recommendations, or treatment advice',
            });

            console.log(redTeamSpec.id);
        - lang: Python
          source: |-
            import os
            from dataframer import Dataframer

            client = Dataframer(
                api_key=os.environ.get("DATAFRAMER_API_KEY"),  # This is the default and can be omitted
            )
            red_team_spec = client.dataframer.red_team_specs.create(
                app_description="A patient-facing chatbot that helps schedule appointments and answer general health questions",
                domain_description="Healthcare and medical information services",
                name="Healthcare Chatbot",
                concerns="Should not provide medical diagnoses, prescription recommendations, or treatment advice",
            )
            print(red_team_spec.id)
components:
  schemas:
    RedTeamSpecCreate:
      type: object
      description: Request body for creating a red team spec
      required:
        - name
        - domain_description
        - app_description
      properties:
        name:
          type: string
          description: >-
            Name for the spec (will be converted to snake_case, must be unique
            within company)
        domain_description:
          type: string
          description: >-
            Description of the domain or industry the application operates in
            (e.g., 'Healthcare', 'E-commerce', 'Financial services')
        app_description:
          type: string
          description: >-
            Description of the application being tested, including its purpose
            and key functionality
        concerns:
          type: string
          description: >-
            Optional specific security concerns or undesirable behaviors to
            focus on (e.g., 'Should not provide medical diagnoses')
    RedTeamSpec:
      type: object
      description: >-
        A red team specification defining the application context for
        adversarial prompt generation
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          description: Unique identifier for the red team spec
        name:
          type: string
          description: Name of the red team spec (auto-converted to snake_case)
        domain_description:
          type: string
          description: Description of the domain or industry the application operates in
        app_description:
          type: string
          description: >-
            Description of the application being tested, including its purpose
            and functionality
        concerns:
          type: string
          nullable: true
          description: >-
            Specific security concerns or behaviors to focus on during red
            teaming
        created_at:
          type: string
          format: date-time
          readOnly: true
          description: Timestamp when the spec was created
        updated_at:
          type: string
          format: date-time
          readOnly: true
          description: Timestamp when the spec was last modified
        company_id:
          type: string
          format: uuid
          readOnly: true
          description: ID of the company that owns this spec
        company_name:
          type: string
          readOnly: true
          description: Name of the company that owns this spec
        created_by:
          type: integer
          readOnly: true
          description: ID of the user who created this spec
        created_by_email:
          type: string
          readOnly: true
          description: Email of the user who created this spec
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'API Key authentication. Format: "Bearer YOUR_API_KEY"'

````