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

# Write to a subprocess's stdin and/or close it

> Writes a chunk to the stdin of a live process inside the
running instance — `spid=1` targets the main process, `≥2` the
exec'd children.  Requires the process to have been started
with `stdin.close=false`; otherwise its pipe is already at EOF
and the call returns 409.

`close=true` (the default) signals EOF after writing `value`;
an empty `value` with `close=true` just closes the pipe.  A
client that serializes its own requests gets ordered writes;
concurrent requests to the same spid are safe but their order
is unspecified.

A 504 means the guest write timed out mid-call — the chunk may
or may not have been delivered (e.g. the process stopped
reading and the pipe is full), so blind retries can duplicate
data.




## OpenAPI

````yaml https://eu-north.nebius.computer/static/api.yaml post /operations/{operationId}/subprocesses/{spid}/stdin
openapi: 3.0.0
info:
  title: Contree API
  description: >
    Contree is a container management system combining virtual machine isolation
    with container operational efficiency. 

    Designed for security-sensitive workloads requiring hardware-enforced
    boundaries while maintaining

    container workflow compatibility.
  version: 1.0.0
servers:
  - url: '{baseUrl}/v1'
    description: |
      Nebius IAM-fronted endpoint (use `IAMBearerAuth` + `IAMProjectHeader`).
      Override `baseUrl` to point at a different deployment.
    variables:
      baseUrl:
        default: https://api.tokenfactory.nebius.com/sandboxes
        description: |
          Base URL of the contree service. Defaults to the public Nebius
          IAM-fronted endpoint; set to your self-hosted contree origin
          (e.g. `https://contree.example.com`) when running elsewhere.
security:
  - IAMBearerAuth: []
    IAMProjectHeader: []
tags:
  - name: images
    description: Operations related to container images
  - name: files
    description: Operations related to file uploads
  - name: instances
    description: Operations related to container instances
  - name: inspect
    description: Operations related to inspecting container images
  - name: operations
    description: Operations related to long-running operations
  - name: auth
    description: Authentication and token introspection
paths:
  /operations/{operationId}/subprocesses/{spid}/stdin:
    post:
      tags:
        - operation
      summary: Write to a subprocess's stdin and/or close it
      description: |
        Writes a chunk to the stdin of a live process inside the
        running instance — `spid=1` targets the main process, `≥2` the
        exec'd children.  Requires the process to have been started
        with `stdin.close=false`; otherwise its pipe is already at EOF
        and the call returns 409.

        `close=true` (the default) signals EOF after writing `value`;
        an empty `value` with `close=true` just closes the pipe.  A
        client that serializes its own requests gets ordered writes;
        concurrent requests to the same spid are safe but their order
        is unspecified.

        A 504 means the guest write timed out mid-call — the chunk may
        or may not have been delivered (e.g. the process stopped
        reading and the pipe is full), so blind retries can duplicate
        data.
      operationId: operationSubprocessStdin
      parameters:
        - name: operationId
          in: path
          required: true
          description: The ID of the operation
          schema:
            $ref: '#/components/schemas/UUIDSchema'
        - in: path
          name: spid
          required: true
          schema:
            type: integer
            minimum: 1
          description: Spawn id (1 = main process; ≥2 = exec'd children).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClosableStreamRepr'
      responses:
        '204':
          description: Chunk written (and/or stdin closed).
        '400':
          description: Invalid spid or request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: |
            Not Found — the operation does not exist, or the worker has
            no live process with that spid (never spawned or already
            exited).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: |
            Conflict — the operation is not a running instance, or the
            process's stdin is already closed (spawned without
            `close=false`, closed by an earlier request, or the process
            exited).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: |
            Gone — the instance finished; there is no live process to
            write to.
        '425':
          description: |
            Too Early — no worker holds the operation yet, or the
            control channel is not up.  Retry after `Retry-After`.
          headers:
            Retry-After:
              schema:
                type: integer
        '501':
          description: |
            Not Implemented — the instance runs a guest image that
            predates stdin streaming.
        '504':
          description: |
            Gateway Timeout — the guest write did not complete in time;
            the chunk may or may not have been written.  Not safe to
            retry blindly.
components:
  schemas:
    UUIDSchema:
      type: string
      format: uuid
      description: A UUID string
      example: 12345678-9abc-baba-deda-0123456789ab
    ClosableStreamRepr:
      type: object
      description: |
        Stdin payload.  Unlike output streams it is never truncated;
        instead it carries a `close` flag controlling the pipe's EOF.
      required:
        - value
      properties:
        value:
          type: string
          description: Content to write to stdin (may be empty for a close-only request)
          example: aGVsbG8K
        encoding:
          type: string
          enum:
            - ascii
            - base64
          description: Encoding of the content
          default: ascii
        close:
          type: boolean
          default: true
          description: |
            `true` (default) closes stdin (EOF) after writing `value` —
            the pre-existing one-shot behavior.  `false` keeps the pipe
            open so more data can be sent later via
            `POST /operations/{operationId}/subprocesses/{spid}/stdin`.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          oneOf:
            - type: string
            - type: object
            - type: array
              items:
                type: object
          description: Error message or structured validation errors
          example: Some error occurred, this is an example of error message
        status:
          type: integer
          description: HTTP status code
          example: 500
        traceback:
          type: array
          items:
            type: string
  responses:
    Unauthorized:
      description: |
        Unauthorized - Invalid or missing authentication credentials.
        Either the `Authorization` bearer token is missing or invalid, or
        the `Project` header is missing.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden - Token does not have sufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    IAMBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: IAM
      description: |
        IAM bearer token issued by the Nebius IAM service. Sent as
        `Authorization: Bearer <iam-token>`. Must be combined with the
        `Project` header (see `IAMProjectHeader`).

        This is the recommended authentication scheme for new clients.
    IAMProjectHeader:
      type: apiKey
      in: header
      name: Project
      description: |
        Nebius project ID associated with the IAM token. Required together
        with `IAMBearerAuth`. Identifies the project context the request is
        scoped to.

````