# `POST /v1/sessions/{sessionId}/inputs` — Send an input

Part of the [Bkper Managed Agent API](https://bkper.com/docs/api/managed-agent.md). Read its guide for authentication, conventions, and examples.

Same key and content returns the existing input; different content is 409.

## Operation contract

```json
{
  "operationId": "sendInput",
  "tags": [
    "Inputs"
  ],
  "summary": "Send an input",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "name": "sessionId",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "Idempotency-Key",
      "in": "header",
      "required": true,
      "schema": {
        "type": "string",
        "pattern": "^[A-Za-z0-9_-]{1,128}$"
      }
    }
  ],
  "description": "Same key and content returns the existing input; different content is 409.",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/SendInput"
        }
      }
    }
  },
  "responses": {
    "202": {
      "description": "Success",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Input"
          }
        }
      }
    },
    "400": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "401": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "403": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "404": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "409": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "410": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "411": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "413": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "503": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}
```

## Schemas

### SendInput

```json
{
  "type": "object",
  "properties": {
    "content": {
      "minItems": 1,
      "maxItems": 16,
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "text"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "text"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "file"
              },
              "fileId": {
                "type": "string",
                "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
                "description": "A file of the caller, from POST /v1/files or a publish."
              }
            },
            "required": [
              "type",
              "fileId"
            ],
            "additionalProperties": false
          }
        ]
      },
      "description": "Text parts (at most 16000 characters in total) and up to 10 file parts; some text or a file. Files unknown to the caller are 404 file_not_found; expired ones 410 file_gone."
    },
    "delivery": {
      "type": "string",
      "enum": [
        "prompt",
        "steer",
        "followUp"
      ]
    },
    "bookContext": {
      "description": "Advisory Book/query context, frozen with this input. Never identity or authorization.",
      "type": "object",
      "properties": {
        "bookId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,128}$"
        },
        "query": {
          "type": "string",
          "maxLength": 4000,
          "pattern": "^[^\\u0000-\\u001f]*$"
        }
      },
      "required": [
        "bookId",
        "query"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "content"
  ],
  "additionalProperties": false
}
```

### Input

```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "The Idempotency-Key."
    },
    "sessionId": {
      "type": "string"
    },
    "createdBy": {
      "type": "string"
    },
    "createdAt": {
      "type": "string",
      "pattern": "^\\d+$",
      "description": "Milliseconds since the epoch, as a string."
    },
    "delivery": {
      "type": "string",
      "description": "Delivery. Open: prompt | steer | followUp."
    },
    "status": {
      "type": "string",
      "description": "Input state. Open: queued | running | completed | withdrawn | failed."
    },
    "content": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": {},
        "description": "Typed part; text is { type: \"text\", text }. Open."
      }
    },
    "entryId": {
      "type": "string"
    },
    "answerEntryId": {
      "type": "string"
    },
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "code"
      ],
      "description": "Sanitized failure. Never contains provider, AI or credential text."
    },
    "bookContext": {
      "type": "object",
      "properties": {
        "bookId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,128}$"
        },
        "query": {
          "type": "string",
          "maxLength": 4000,
          "pattern": "^[^\\u0000-\\u001f]*$"
        }
      },
      "required": [
        "bookId",
        "query"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "id",
    "sessionId",
    "createdBy",
    "createdAt",
    "delivery",
    "status",
    "content"
  ]
}
```

### Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Stable code, e.g. not_found, idempotency_conflict, session_working, usage_limit_exceeded. Open."
        },
        "type": {
          "description": "Category, e.g. invalid_request_error, authentication_error, usage_limit_error. Open.",
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code"
      ]
    }
  },
  "required": [
    "error"
  ]
}
```

## Authentication

```json
{
  "bearerAuth": {
    "type": "http",
    "scheme": "bearer"
  }
}
```
