curl --location --request POST https://api.writer.com/v1/files \
--header "Authorization: Bearer <token>" \
--header "Accept: */*" \
--header "Content-Disposition: attachment; filename=descriptions.pdf" \
--header "Content-Length: size_in_bytes" \
--header "Content-Type: application/pdf" \
--data-binary "@descriptions.pdf"import os
from pathlib import Path
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
file = client.files.upload(
content=Path('/path/to/file/descriptions.pdf'),
content_disposition="attachment; filename=descriptions.pdf",
content_type="application/pdf"
)
print(file.id)import fs from 'fs';
import Writer from 'writer-sdk';
const client = new Writer({
apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted
});
async function main() {
const file = await client.files.upload({
content: fs.createReadStream('path/to/file/descriptions.pdf'),
'Content-Disposition': 'attachment; filename=descriptions.pdf',
'Content-Type': 'application/pdf',
});
console.log(file.id);
}
main();{
"id": "7c36a365-392f-43ba-840d-8f3103b42572",
"name": "example.pdf",
"created_at": "2024-07-10T14:30:00Z",
"graph_id": [],
"status": "in_progress"
}Upload file
Upload a new file to the system. Supports various file formats including PDF, DOC, DOCX, PPT, PPTX, JPG, PNG, EML, HTML, SRT, CSV, XLS, and XLSX.
File uploads do not accept team parameters. When you attach a file to a Knowledge Graph, the file inherits the team scope of that Knowledge Graph.
curl --location --request POST https://api.writer.com/v1/files \
--header "Authorization: Bearer <token>" \
--header "Accept: */*" \
--header "Content-Disposition: attachment; filename=descriptions.pdf" \
--header "Content-Length: size_in_bytes" \
--header "Content-Type: application/pdf" \
--data-binary "@descriptions.pdf"import os
from pathlib import Path
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
file = client.files.upload(
content=Path('/path/to/file/descriptions.pdf'),
content_disposition="attachment; filename=descriptions.pdf",
content_type="application/pdf"
)
print(file.id)import fs from 'fs';
import Writer from 'writer-sdk';
const client = new Writer({
apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted
});
async function main() {
const file = await client.files.upload({
content: fs.createReadStream('path/to/file/descriptions.pdf'),
'Content-Disposition': 'attachment; filename=descriptions.pdf',
'Content-Type': 'application/pdf',
});
console.log(file.id);
}
main();{
"id": "7c36a365-392f-43ba-840d-8f3103b42572",
"name": "example.pdf",
"created_at": "2024-07-10T14:30:00Z",
"graph_id": [],
"status": "in_progress"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.
Headers
The MIME type of the file being uploaded. Supports txt, doc, docx, ppt, pptx, jpg, png, eml, html, pdf, srt, csv, xls, xlsx, mp3, and mp4 file extensions.
Query Parameters
Body
The body is of type file.
Response
A list of Knowledge Graph IDs that the file is associated with.
If you provided a graphId during upload, the file is associated with that Knowledge Graph. However, the graph_ids field in the upload response is an empty list. The association will be visible in the graph_ids list when you retrieve the file using the file retrieval endpoint.
Was this page helpful?