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

# Upload Document

> Upload a text document to your memory

## Overview

API endpoint for uploading text documents to your memory. This allows you to add longer form content directly to your AI's knowledge base.

## Authorization

<ParamField header="x-api-key" type="string" required>
  Your Personal AI API key
</ParamField>

## Headers

<ParamField header="Content-Type" type="string" required>
  Must be set to application/json
</ParamField>

### Body

<ParamField body="Text" type="string" required>
  Body of text to upload to the memory. This should be as clean as possible.

  ```json Example Request theme={null}
  "Text": "This is a long document that is consumed into the document view!"
  ```
</ParamField>

<ParamField body="Title" type="string" optional>
  Title of the uploaded document

  ```json Example Request theme={null}
  "Title": "New Document"
  ```
</ParamField>

<ParamField body="DomainName" type="string" required>
  The hyphenated text below the AI's name when clicked into a Persona.

  <img alt="DomainName" classname="block dark:hidden" src="https://mintcdn.com/personalai/kGsTZefXJjPC-_P1/images/domainname.png?fit=max&auto=format&n=kGsTZefXJjPC-_P1&q=85&s=36b7c320c44dba9f962cdb342de41f3a" width="1140" height="416" data-path="images/domainname.png" />

  ```json Example Request theme={null}
  "DomainName": "product-demo-jebzrhw"
  ```
</ParamField>

<ParamField body="Starttime" type="string" optional>
  ISO timestamp string indicating start time (UTC)

  ```json Example Request theme={null}
  "Starttime": "2024-10-09T10:00:00.000Z"
  ```
</ParamField>

<ParamField body="EndTime" type="string" optional>
  ISO timestamp string indicating end time (UTC)

  ```json Example Request theme={null}
  "Endtime": "2024-10-10T10:00:00.000Z"
  ```
</ParamField>

<ParamField body="Tags" type="string" optional>
  Comma delimited list of tags for context and reference

  ```json Example Request theme={null}
  "Tags": "documents,blog,draft"
  ```
</ParamField>

<ParamField body="is_stack" type="boolean" optional>
  Boolean to specify whether to add the document to memory. Defaults to true.

  ```json Example Request theme={null}
  "is_stack": true
  ```
</ParamField>

```json Example theme={null}
{
    "Text": "This is a long document that is consumed into the document view.",
    "Title": "Personal AI",
    "DomainName": "product-demo-jebzrhw",
    "Tags": "#doc1",
    "is_stack": false,
    "Starttime": "2023-07-09T10:00:00.000Z",
    "Endtime": "2023-07-09T10:00:00.000Z"
}
```

### Exmaple Responses

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

```json Example Success Response theme={null}
{
    "message": "doc accepted and processing"
}
```

```json Example Error Response theme={null}
{
    "detail": "AI document upload unauthorized."
}
```

### Example cURL

```bash cURL theme={null}
curl --location 'https://api.personal.ai/v1/upload-text' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <your-api-key>' \
--data '{
    "Text": "This is a long document that is consumed into the document view.",
    "Title": "New Document",
    "DomainName": "product-demo-jebzrhw",
    "Tags": "documents,blog,draft",
    "is_stack": true
}'
```

### Error Codes

| Code | Description                                                 |
| ---- | ----------------------------------------------------------- |
| 403  | Forbidden - Check that API key is invalid                   |
| 400  | Invalid Request - Missing required fields or invalid format |
