Skip to main content
POST
/
v1
/
knowledge-bases
/
sources
Add a knowledge base source — file, URL, or inline text (auto-creates the KB)
curl --request POST \
  --url https://api-tokyo.oneinbox.ai/v1/knowledge-bases/sources \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form type=url \
  --form source=https://docs.yourproduct.com/faq \
  --form 2.file='@example-file'
import requests

url = "https://api-tokyo.oneinbox.ai/v1/knowledge-bases/sources"

files = { "2.file": ("example-file", open("example-file", "rb")) }
payload = {
"type": "url",
"source": "https://docs.yourproduct.com/faq"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.text)
const form = new FormData();
form.append('type', 'url');
form.append('source', 'https://docs.yourproduct.com/faq');
form.append('2.file', '{
"fileName": "example-file"
}');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

fetch('https://api-tokyo.oneinbox.ai/v1/knowledge-bases/sources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
package main

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

func main() {

url := "https://api-tokyo.oneinbox.ai/v1/knowledge-bases/sources"

payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\nurl\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"source\"\r\n\r\nhttps://docs.yourproduct.com/faq\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"2.file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")

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

req.Header.Add("Authorization", "Bearer <token>")

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

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

fmt.Println(string(body))

}
{
  "source": {
    "source_id": "<string>",
    "kb_id": "<string>",
    "type": "<string>",
    "source": "<string>",
    "chunk_count": 123,
    "status": "<string>",
    "error_message": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "file_name": "<string>",
    "mime_type": "<string>",
    "file_size": 123,
    "token_count": 0
  },
  "job": {
    "job_id": "<string>",
    "kb_id": "<string>",
    "type": "<string>",
    "status": "<string>",
    "error_message": "<string>",
    "payload": {},
    "started_at": "2023-11-07T05:31:56Z",
    "completed_at": "2023-11-07T05:31:56Z",
    "created_at": "2023-11-07T05:31:56Z",
    "source_id": "<string>"
  },
  "message": "Source accepted. Ingestion is running in the background. Poll GET /v1/knowledge-bases/{kb_id}/jobs/{job_id} for status."
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}

Authorizations

Authorization
string
header
required

Your API key sent as a Bearer credential — Authorization: Bearer <api_key>, where <api_key> starts with oi_sk_ (create one via POST /v1/api-keys). Although the field is labelled 'token', paste your API key here. A dashboard JWT is also accepted on this header for the same endpoints.

Body

multipart/form-data
type
enum<string>
required
Available options:
url
Example:

"url"

source
string
required

Publicly accessible URL to crawl. OneInbox reads all linked pages automatically.

Example:

"https://docs.yourproduct.com/faq"

Response

Successful Response

201 response for POST /sources — returns the source and a job_id to poll.

source
KBSourceResponse · object
required
job
KBJobResponse · object
required
message
string
default:Source accepted. Ingestion is running in the background. Poll GET /v1/knowledge-bases/{kb_id}/jobs/{job_id} for status.