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

# Create script

> Create a new script with optional files and metadata



## OpenAPI

````yaml /api-reference/openapi.json post /v1/scripts
openapi: 3.1.0
info:
  title: Skyvern API
  description: API for Skyvern
  version: 1.0.0
servers:
  - url: https://api.skyvern.com
    x-fern-server-name: Cloud
  - url: https://api-staging.skyvern.com
    x-fern-server-name: Staging
  - url: http://localhost:8000
    x-fern-server-name: Local
security: []
paths:
  /v1/scripts:
    post:
      tags:
        - Scripts
      summary: Create script
      description: Create a new script with optional files and metadata
      operationId: create_script_v1_scripts_post
      parameters:
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Skyvern API key for authentication. API key can be found at
              https://app.skyvern.com/settings.
            title: X-Api-Key
          description: >-
            Skyvern API key for authentication. API key can be found at
            https://app.skyvern.com/settings.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateScriptRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateScriptResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateScriptRequest:
      properties:
        workflow_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Workflow Id
          description: Associated workflow ID
        run_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Run Id
          description: Associated run ID
        files:
          anyOf:
            - items:
                $ref: '#/components/schemas/ScriptFileCreate'
              type: array
            - type: 'null'
          title: Files
          description: Array of files to include in the script
          examples:
            - content: cHJpbnQoIkhlbGxvLCBXb3JsZCEiKQ==
              encoding: base64
              mime_type: text/x-python
              path: main.py
            - content: cmVxdWVzdHM9PTIuMjguMQ==
              encoding: base64
              mime_type: text/plain
              path: requirements.txt
      type: object
      title: CreateScriptRequest
    CreateScriptResponse:
      properties:
        script_id:
          type: string
          title: Script Id
          description: Unique script identifier
          examples:
            - s_abc123
        version:
          type: integer
          title: Version
          description: Script version number
          examples:
            - 1
        run_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Run Id
          description: ID of the workflow run or task run that generated this script
        file_count:
          type: integer
          title: File Count
          description: Total number of files in the script
        file_tree:
          additionalProperties:
            $ref: '#/components/schemas/FileNode'
          type: object
          title: File Tree
          description: Hierarchical file tree structure
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the script was created
      type: object
      required:
        - script_id
        - version
        - file_count
        - file_tree
        - created_at
      title: CreateScriptResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ScriptFileCreate:
      properties:
        path:
          type: string
          title: Path
          description: File path relative to script root
          examples:
            - src/main.py
        content:
          type: string
          title: Content
          description: Base64 encoded file content
        encoding:
          $ref: '#/components/schemas/FileEncoding'
          description: Content encoding
          default: base64
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
          description: MIME type (auto-detected if not provided)
      type: object
      required:
        - path
        - content
      title: ScriptFileCreate
      description: Model representing a file in a script.
    FileNode:
      properties:
        type:
          type: string
          title: Type
          description: 'Type of node: ''file'' or ''directory'''
        size:
          anyOf:
            - type: integer
            - type: 'null'
          title: Size
          description: File size in bytes
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
          description: MIME type of the file
        content_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Hash
          description: SHA256 hash of file content
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp when the file was created
        children:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/FileNode'
              type: object
            - type: 'null'
          title: Children
          description: Child nodes for directories
      type: object
      required:
        - type
        - created_at
      title: FileNode
      description: Model representing a file or directory in the file tree.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    FileEncoding:
      type: string
      enum:
        - base64
        - utf-8
      title: FileEncoding
      description: Supported file content encodings.

````