Skip to main content
POST
/
documents
JavaScript
import Tractorbeam from 'tractorbeam';

const client = new Tractorbeam({
  apiToken: process.env['TRACTORBEAM_API_TOKEN'], // This is the default and can be omitted
});

async function main() {
  const document = await client.documents.create({ name: 'my_document.txt' });

  console.log(document.id);
}

main();
{
  "id": "doc_2yYISEvrO9LrLAOJjnw27",
  "name": "my_document.txt",
  "owner": "org_2nlswGH0pZ1V1OlHYAUwQG6TVBx",
  "file_type": "text/plain",
  "file_bytes": 1234,
  "created_at": "2024-01-01T00:00:00.000Z"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string
required

The name of the document

Example:

"my_document.txt"

text
string | null

The text content of the document

Example:

"Hello world"

file
integer<int32>[] | null

The file content of the document

Required range: x >= 0

Response

201 - application/json

Document created successfully

id
string
required

The ID of the document

Example:

"doc_2yYISEvrO9LrLAOJjnw27"

name
string
required

The name of the document

Maximum string length: 255
Example:

"my_document.txt"

owner
string
required

The owner of the document

Example:

"org_2nlswGH0pZ1V1OlHYAUwQG6TVBx"

file_type
string
required

The file type of the document

Example:

"text/plain"

file_bytes
integer<int64>
required

The size of the document in bytes

Example:

1234

created_at
string
required

The date and time when the document was created in RFC 3339 format

Example:

"2024-01-01T00:00:00.000Z"