> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.privategpt.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server.

# Ingest Content

POST /v1/artifacts/ingest
Content-Type: application/json

Unified endpoint to ingest files, text, URIs, or already processed content

Reference: https://docs.privategpt.dev/api-reference/artifacts/ingest-content-v-1-artifacts-ingest-post

## Request

### Body (application/json)

This endpoint expects an IngestBody.

- `artifact` (string, required) — Unique identifier for the text being ingested within the collection
- `input` (IngestBodyInput, required) — Raw input data to be processed and ingested into the system. Can be a file (base64), URI, or plain text
- `collection` (string, optional, default: pgpt_collection) — Collection name to group related documents for better organization and filtering
- `metadata` (map from string to any, optional, nullable) — Optional metadata dictionary containing additional document information. If provided, must include 'file_name' with a valid file extension

## Response

### 200

Content successfully ingested and processed

- `data` (list of IngestedDoc, required) — List of ingested documents with their metadata and processing information
- `object` ("list", optional, default: list) — Response object type, always 'list' for ingestion responses
- `model` ("private-gpt", optional, default: private-gpt) — Model identifier, always 'private-gpt'

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

## Types

### IngestBodyInput

Raw input data to be processed and ingested into the system. Can be a file (base64), URI, or plain text

- `type`: `file` (FileArtifact)
  - `value` (string, required) — Base64 encoded file content
- `type`: `text` (TextArtifact)
  - `value` (string, required) — Plain text content
- `type`: `uri` (UriArtifact)
  - `value` (string, required) — URI to download from

### IngestedDoc

Represents a document that has been ingested into the system.

- `artifact` (string, required) — Unique identifier for the ingested document artifact.
- `object` ("ingest.document", optional, default: ingest.document) — Type of the object, indicating this is an ingested document.
- `doc_metadata` (map from string to any, optional, nullable) — Metadata associated with the ingested document, such as title, author, and other

## Examples

**Request**

```json
{
  "artifact": "company_profile",
  "input": {
    "type": "text",
    "value": "Our company was founded in 2020..."
  },
  "collection": "corporate_docs",
  "metadata": {
    "author": "Marketing Team",
    "file_name": "company_profile.txt"
  }
}
```

**Response**

```json
{
  "data": [
    {
      "artifact": "company_profile",
      "object": "ingest.document",
      "doc_metadata": {
        "author": "Marketing Team",
        "file_name": "company_profile.txt"
      }
    }
  ],
  "object": "list",
  "model": "private-gpt"
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/artifacts/ingest"

payload = {
    "artifact": "company_profile",
    "input": {
        "type": "text",
        "value": "Our company was founded in 2020..."
    },
    "collection": "corporate_docs",
    "metadata": {
        "author": "Marketing Team",
        "file_name": "company_profile.txt"
    }
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/artifacts/ingest';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"artifact":"company_profile","input":{"type":"text","value":"Our company was founded in 2020..."},"collection":"corporate_docs","metadata":{"author":"Marketing Team","file_name":"company_profile.txt"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/artifacts/ingest"

	payload := strings.NewReader("{\n  \"artifact\": \"company_profile\",\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"Our company was founded in 2020...\"\n  },\n  \"collection\": \"corporate_docs\",\n  \"metadata\": {\n    \"author\": \"Marketing Team\",\n    \"file_name\": \"company_profile.txt\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/artifacts/ingest")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"artifact\": \"company_profile\",\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"Our company was founded in 2020...\"\n  },\n  \"collection\": \"corporate_docs\",\n  \"metadata\": {\n    \"author\": \"Marketing Team\",\n    \"file_name\": \"company_profile.txt\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/artifacts/ingest")
  .header("Content-Type", "application/json")
  .body("{\n  \"artifact\": \"company_profile\",\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"Our company was founded in 2020...\"\n  },\n  \"collection\": \"corporate_docs\",\n  \"metadata\": {\n    \"author\": \"Marketing Team\",\n    \"file_name\": \"company_profile.txt\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/artifacts/ingest', [
  'body' => '{
  "artifact": "company_profile",
  "input": {
    "type": "text",
    "value": "Our company was founded in 2020..."
  },
  "collection": "corporate_docs",
  "metadata": {
    "author": "Marketing Team",
    "file_name": "company_profile.txt"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/artifacts/ingest");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"artifact\": \"company_profile\",\n  \"input\": {\n    \"type\": \"text\",\n    \"value\": \"Our company was founded in 2020...\"\n  },\n  \"collection\": \"corporate_docs\",\n  \"metadata\": {\n    \"author\": \"Marketing Team\",\n    \"file_name\": \"company_profile.txt\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "artifact": "company_profile",
  "input": [
    "type": "text",
    "value": "Our company was founded in 2020..."
  ],
  "collection": "corporate_docs",
  "metadata": [
    "author": "Marketing Team",
    "file_name": "company_profile.txt"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/artifacts/ingest")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```