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

# Execute JavaScript

> Runs JavaScript in a secure sandbox with a timeout. Requires a **Basic** license. Code is capped at 10 KB; timeout defaults to 5000 ms (max 10000 ms). Values in `args` are exposed to the script as the `args` array.



## OpenAPI

````yaml /api-reference/utilities/openapi.json post /javascript
openapi: 3.1.0
info:
  title: Magic Meal Kits — Utilities API
  version: 1.0.0
  description: >-
    Single-purpose helper endpoints: sandboxed JavaScript execution, JSON
    extraction from mixed text, ISO 8601 duration formatting, and Markdown →
    Slack Block Kit conversion.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://{deployment}/api/v1
    description: Your Magic Meal Kits deployment
    variables:
      deployment:
        default: magic-meal-kits-xxxxx.run.app
        description: Your Cloud Run host (without protocol)
security:
  - ApiKeyAuth: []
tags:
  - name: JavaScript
    description: Execute JavaScript in a sandbox.
  - name: JSON
    description: Extract JSON from mixed text content.
  - name: ISO 8601
    description: Format and decompose ISO 8601 durations.
  - name: Slack
    description: Convert Markdown to Slack Block Kit.
paths:
  /javascript:
    post:
      tags:
        - JavaScript
      summary: Execute JavaScript
      description: >-
        Runs JavaScript in a secure sandbox with a timeout. Requires a **Basic**
        license. Code is capped at 10 KB; timeout defaults to 5000 ms (max 10000
        ms). Values in `args` are exposed to the script as the `args` array.
      operationId: executeJavaScript
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JavaScriptRequest'
            example:
              code: const x = args[0] || 'world'; `hello ${x}`
              args:
                - mmk
              timeout: 5000
      responses:
        '200':
          description: Execution result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JavaScriptResponse'
              example:
                success: true
                data:
                  result: hello mmk
        '400':
          description: Invalid request, empty/too-long code, or execution error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '408':
          description: Execution timed out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    JavaScriptRequest:
      type: object
      required:
        - code
      properties:
        code:
          type: string
          maxLength: 10240
          description: JavaScript source to run. Max 10 KB.
        timeout:
          type: integer
          default: 5000
          maximum: 10000
          description: Timeout in milliseconds (max 10000).
        args:
          type: array
          items:
            type: string
          description: Values exposed to the script as the `args` array.
    JavaScriptResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          type: object
          properties:
            result:
              description: The script's return value (any JSON type).
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        Your deployment's API key (MMK_API_KEY). Routes that accept OAuth2 also
        allow `Authorization: Bearer <token>`.

````