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

# Execute command in pod

> Runs a command in a pod container and returns stdout, stderr, and exit code. Non-interactive (no TTY, no stdin). Timeout: 30 seconds.



## OpenAPI

````yaml /openapi.json post /v1/clusters/{id}/exec
openapi: 3.1.0
info:
  title: CNAP API
  version: 1.0.0
  description: >-
    Public API for managing CNAP workspaces, clusters, templates, products, and
    deployments.


    Authenticate with a Personal Access Token via the `Authorization: Bearer
    cnap_pat_...` header.


    Workspace-scoped endpoints require the `X-Workspace-Id` header.
servers:
  - url: https://api.cnap.tech
    description: Production
security: []
paths:
  /v1/clusters/{id}/exec:
    post:
      tags:
        - Clusters
      summary: Execute command in pod
      description: >-
        Runs a command in a pod container and returns stdout, stderr, and exit
        code. Non-interactive (no TTY, no stdin). Timeout: 30 seconds.
      parameters:
        - schema:
            type: string
            description: Cluster ID
          required: true
          description: Cluster ID
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                namespace:
                  type: string
                  minLength: 1
                  maxLength: 253
                  example: default
                  description: Kubernetes namespace
                pod:
                  type: string
                  minLength: 1
                  maxLength: 253
                  example: postgres-0
                  description: Pod name
                container:
                  type: string
                  minLength: 1
                  maxLength: 253
                  example: postgresql
                  description: Container name within the pod
                command:
                  type: array
                  items:
                    type: string
                  minItems: 1
                  example:
                    - cat
                    - /etc/hostname
                  description: Command and arguments
              required:
                - namespace
                - pod
                - container
                - command
      responses:
        '200':
          description: Command result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecResult'
        '400':
          description: Cluster not running or invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Cluster not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Command timed out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Execution error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - BearerAuth: []
components:
  schemas:
    ExecResult:
      type: object
      properties:
        stdout:
          type: string
          description: Standard output
        stderr:
          type: string
          description: Standard error
        exit_code:
          type: integer
          description: Exit code (0 = success)
      required:
        - stdout
        - stderr
        - exit_code
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: not_found
            message:
              type: string
              example: Resource not found
            param:
              type: string
              description: The request field that caused the error
              example: name
            suggestion:
              type: string
              example: Run `cnap clusters list` to see available clusters
            details: {}
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at
        https://cnap.tech/account/tokens

````