curl --location --request POST https://api.writer.com/v1/graphs/{graph_id}/file \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data-raw '{"file_id":"string"}'import os
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
file = client.graphs.add_file_to_graph(
graph_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
file_id="file_id",
)
print(file.id)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.graphs.addFileToGraph('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
file_id: 'file_id',
});
console.log(file.id);
}
main();{
"id": "7c36a365-392f-43ba-840d-8f3103b42572",
"created_at": "2024-07-10T15:16:10.684826Z",
"name": "example.pdf",
"graph_id": [
"50daa3d0-e7d9-44a4-be42-b53e2379ebf7"
]
}Add file to graph
Add a file to a Knowledge Graph. Team access is inherited from the Knowledge Graph; the file itself does not carry team parameters.
curl --location --request POST https://api.writer.com/v1/graphs/{graph_id}/file \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data-raw '{"file_id":"string"}'import os
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
file = client.graphs.add_file_to_graph(
graph_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
file_id="file_id",
)
print(file.id)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.graphs.addFileToGraph('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
file_id: 'file_id',
});
console.log(file.id);
}
main();{
"id": "7c36a365-392f-43ba-840d-8f3103b42572",
"created_at": "2024-07-10T15:16:10.684826Z",
"name": "example.pdf",
"graph_id": [
"50daa3d0-e7d9-44a4-be42-b53e2379ebf7"
]
}- With an org-scoped API key, control team scope from the request body: pass
team_idson create or update, or filter list with theteam_idsquery parameter. Omitteam_idson list to see only org-wide Knowledge Graphs. - With a team-scoped API key, every request is automatically restricted to the key’s team. Create assigns to that team; list and retrieve return only that team’s Knowledge Graphs; body
team_idsis not accepted.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.
Path Parameters
The unique identifier of the Knowledge Graph.
Body
The unique identifier of the file.
Response
A unique identifier of the file.
The timestamp when the file was uploaded.
The name of the file.
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.
The processing status of the file.
Was this page helpful?