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

# Create Scan

> Create a new scan for a repository and queue it for execution.

**Required Scope:** `write:scan`
**Security:** Repository ownership validation

Args:
    repo_id: Repository ID to scan
    request: Scan creation request with scan_type and active_models
    background_tasks: FastAPI background tasks
    auth: Authentication context
    
Returns:
    Created scan details with task ID
    
Raises:
    400: Bad request (validation errors, including if scan is already running)
    401: Unauthorized (invalid token/API key)
    403: Forbidden (insufficient scope or repository not owned by user's org)
    404: Not found (repository not found)
    500: Internal server error



## OpenAPI

````yaml api-reference/openapi.json post /api/scans/{repo_id}
openapi: 3.1.0
info:
  title: Enforster AI API
  description: Enforster AI API for code analysis and security scanning.
  version: 1.8.0
servers: []
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /api/scans/{repo_id}:
    post:
      summary: Create Scan
      description: |-
        Create a new scan for a repository and queue it for execution.

        **Required Scope:** `write:scan`
        **Security:** Repository ownership validation

        Args:
            repo_id: Repository ID to scan
            request: Scan creation request with scan_type and active_models
            background_tasks: FastAPI background tasks
            auth: Authentication context
            
        Returns:
            Created scan details with task ID
            
        Raises:
            400: Bad request (validation errors, including if scan is already running)
            401: Unauthorized (invalid token/API key)
            403: Forbidden (insufficient scope or repository not owned by user's org)
            404: Not found (repository not found)
            500: Internal server error
      operationId: create_scan_api_scans__repo_id__post
      parameters:
        - name: repo_id
          in: path
          required: true
          schema:
            type: string
            title: Repo Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              title: Request
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                title: Response Create Scan Api Scans  Repo Id  Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Use an API key in the X-API-Key header.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Clerk JWT bearer token.

````