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

# Execute ad-hoc agent

> Creates an ephemeral agent and immediately executes a run. Returns the run ID for polling status and results. This is the fastest way to run an agent without managing agent lifecycle.

**Ephemeral agent lifecycle:** The agent created by this endpoint is automatically soft-deleted and its scoped API key revoked when the run completes (whether it succeeds, fails, or times out). Ephemeral agents do not appear in GET /agent/v1/agents listings. The returned agentId is valid only for the duration of the run — do not store it for reuse. For persistent, reusable agents, use POST /agent/v1/agents instead.



## OpenAPI

````yaml /openapi.json post /agent/v1/execute
openapi: 3.1.0
info:
  title: Case.dev API
  description: >-
    The AI-native platform for legal technology. Build smarter legal
    applications with our suite of AI-powered APIs.
  version: 1.0.0
  contact:
    name: Case.dev Support
    email: support@casemark.com
    url: https://case.dev
  license:
    name: Proprietary
    url: https://case.dev/terms
servers:
  - url: https://api.case.dev
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Vaults
    description: Secure document storage with semantic search and GraphRAG
  - name: Memory
    description: >-
      Persistent memory for AI agents with semantic search and 12 generic
      indexed tag fields
  - name: OCR
    description: Extract text from PDFs, images, and scanned documents
  - name: Voice
    description: Audio transcription and text-to-speech
  - name: LLMs
    description: Access 40+ language models through a unified API
  - name: Search
    description: Web search, AI answers, and deep research
  - name: Mail
    description: Managed inboxes for agent email workflows
  - name: Media
    description: Transcript retrieval and captioned media clip generation
  - name: Legal
    description: Legal research tools including citation verification
  - name: Privilege
    description: Privilege detection for e-discovery and litigation workflows
  - name: Compute
    description: Serverless GPU and CPU infrastructure
  - name: Format
    description: Document formatting and template rendering (MD/JSON to PDF/DOCX)
  - name: SuperDoc
    description: Document conversion and template automation
  - name: Webhooks
    description: Webhook endpoint management
  - name: System
    description: Public system metadata and discovery endpoints
  - name: Usage
    description: Usage reporting and webhook subscriptions
  - name: Database
    description: Serverless PostgreSQL databases with instant branching
  - name: Translation
    description: Language detection and translation for multilingual legal workflows
  - name: Skills
    description: Search and read legal AI skills for agents
  - name: Agents
    description: >-
      Create, manage, and execute AI agents with tool access, sandbox
      environments, and async run workflows
  - name: Matters
    description: Matter-native legal workspaces and orchestration primitives
  - name: Applications Projects
    description: Web application project management
  - name: Applications Deployments
    description: Web application deployment management
  - name: Applications Domains
    description: Custom domain configuration for applications
  - name: Applications Env Vars
    description: Environment variable management for applications
paths:
  /agent/v1/execute:
    post:
      tags:
        - Agents
      summary: Execute ad-hoc agent
      description: >-
        Creates an ephemeral agent and immediately executes a run. Returns the
        run ID for polling status and results. This is the fastest way to run an
        agent without managing agent lifecycle.


        **Ephemeral agent lifecycle:** The agent created by this endpoint is
        automatically soft-deleted and its scoped API key revoked when the run
        completes (whether it succeeds, fails, or times out). Ephemeral agents
        do not appear in GET /agent/v1/agents listings. The returned agentId is
        valid only for the duration of the run — do not store it for reuse. For
        persistent, reusable agents, use POST /agent/v1/agents instead.
      operationId: executeAdHocAgent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
              properties:
                prompt:
                  type: string
                  description: Task prompt for the agent
                instructions:
                  type: string
                  description: >-
                    System instructions. Defaults to a general-purpose legal
                    assistant prompt if not provided.
                model:
                  type: string
                  description: >-
                    LLM model identifier. Defaults to
                    anthropic/claude-sonnet-4.6
                vaultIds:
                  type: array
                  items:
                    type: string
                  nullable: true
                  description: Restrict agent to specific vault IDs
                objectIds:
                  type: array
                  items:
                    type: string
                  nullable: true
                  description: >-
                    Scope this run to specific vault object IDs. The agent will
                    only access these objects.
                guidance:
                  type: string
                  nullable: true
                  description: Additional context or constraints for this run
                enabledTools:
                  type: array
                  items:
                    type: string
                  nullable: true
                  description: >-
                    Allowlist of tools the agent can use. Mutually exclusive
                    with disabledTools — set one or the other, not both.
                disabledTools:
                  type: array
                  items:
                    type: string
                  nullable: true
                  description: >-
                    Denylist of tools the agent cannot use. Mutually exclusive
                    with enabledTools — set one or the other, not both.
                sandbox:
                  type: object
                  nullable: true
                  description: Custom sandbox resources (cpu, memoryMiB)
                  properties:
                    cpu:
                      type: integer
                      description: Number of CPUs
                    memoryMiB:
                      type: integer
                      description: Memory in MiB
      responses:
        '200':
          description: Run started
          content:
            application/json:
              schema:
                type: object
                properties:
                  runId:
                    type: string
                    description: Run ID — poll /agent/v1/run/:id/status
                  agentId:
                    type: string
                    description: >-
                      Ephemeral agent ID (auto-created). This agent is
                      soft-deleted when the run completes and should not be
                      stored for reuse.
                  status:
                    type: string
                    enum:
                      - running
                  message:
                    type: string
        '400':
          description: Missing required fields (prompt)
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                  statusMessage:
                    type: string
                  message:
                    type: string
        '401':
          description: Invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                  statusMessage:
                    type: string
                  message:
                    type: string
        '403':
          description: No agent access
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                  statusMessage:
                    type: string
                  message:
                    type: string
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key starting with `sk_case_`

````