Skip to main content
POST
/
v1
/
namespace
/
{namespaceId}
/
uploads
TypeScript
import { Agentset } from "agentset";
import fs from 'fs';

const agentset = new Agentset({ apiKey: 'agentset_xxx' });
const ns = agentset.namespace('ns_xxx');

const result = await ns.uploads.upload({
  file: fs.createReadStream("./example.md"),
  contentType: "text/markdown",
});
console.log("Uploaded successfully: ", result.key);

// OR get the pre-signed URL manually
const file = fs.readFileSync("./example.md");
const result = await ns.uploads.create({
  fileName: "example.md",
  fileSize: file.length,
  contentType: "text/markdown",
});

await fetch(result.url, {
  method: "PUT",
  body: file,
  headers: {
    "Content-Type": "text/markdown",
  },
});
console.log("Uploaded successfully: ", result.key);
{
  "success": true,
  "data": {
    "url": "<string>",
    "key": "<string>"
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.agentset.ai/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Default authentication mechanism

Path Parameters

namespaceId
string
required

The id of the namespace (prefixed with ns_)

Example:

"ns_123"

Body

application/json
fileName
string
required

File name

Minimum string length: 1
Example:

"document.pdf"

contentType
string
required

Content type

Example:

"application/pdf"

fileSize
number
required

File size in bytes

Required range: 1 <= x <= 209715200
Example:

1024

Response

Presigned URL generated successfully

success
boolean
required
data
Upload Result · object
required