curl --request POST \
--url https://davinci-app.com/api/v1/file/upload/{ownerId}/{userId}/{projectId}/{connectionId}/{parentId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'import os
from davinci_sdk import DavinciClient
with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
session = client.sessions.create(project_id)
with open("housing.step", "rb") as handle:
result = session.upload(handle, filename="housing.step", parent_id=root_id)
print(result.file_id)
import { readFile } from 'node:fs/promises';
import { DavinciClient } from '@celedon/davinci-sdk';
const client = new DavinciClient({
apiKey: process.env.DAVINCI_API_KEY!,
});
const session = await client.sessions.create(projectId);
const result = await session.upload({
file: await readFile('housing.step'),
filename: 'housing.step',
parentId: rootId,
});
console.log(result.fileId);
const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://davinci-app.com/api/v1/file/upload/{ownerId}/{userId}/{projectId}/{connectionId}/{parentId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"object": {}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}Upload a file to a project
Sends a file to the machine holding your project and attaches it under
parentId in the parts tree.
Send this to dataPlane.url, not to the control-plane host, with
Authorization: Bearer {dataPlane.token}. Supply the session’s own
dataPlane.connectionId as connectionId; the upload is applied through the
session’s live connection, so any other value is rejected.
Bodies up to 2 GB are accepted and streamed rather than buffered.
curl --request POST \
--url https://davinci-app.com/api/v1/file/upload/{ownerId}/{userId}/{projectId}/{connectionId}/{parentId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file='@example-file'import os
from davinci_sdk import DavinciClient
with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
session = client.sessions.create(project_id)
with open("housing.step", "rb") as handle:
result = session.upload(handle, filename="housing.step", parent_id=root_id)
print(result.file_id)
import { readFile } from 'node:fs/promises';
import { DavinciClient } from '@celedon/davinci-sdk';
const client = new DavinciClient({
apiKey: process.env.DAVINCI_API_KEY!,
});
const session = await client.sessions.create(projectId);
const result = await session.upload({
file: await readFile('housing.step'),
filename: 'housing.step',
parentId: rootId,
});
console.log(result.fileId);
const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://davinci-app.com/api/v1/file/upload/{ownerId}/{userId}/{projectId}/{connectionId}/{parentId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"object": {}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}Authorizations
A session's data-plane grant, from dataPlane.token. Valid only on the
data-plane host, only for the one project its session opened, and only for
minutes.
A grant is not an API key and the two are not interchangeable: presenting a grant to a control-plane operation is rejected, and an API key is not accepted on the data plane. The separation is deliberate — a grant is meant to be cheap to lose, so it reaches one project, does no more than the key that minted it, and is revoked when its session closes.
Path Parameters
Id of the account or organization that owns the project, from the project's
ownerId.
1Acting user id. Ignored for authorization — the acting identity comes from the grant, so this cannot be used to act as someone else.
1Project id, compound as {projectId}--{branchName}. Must be the project the
session opened.
1The session's dataPlane.connectionId, which is headless-{sessionId}. Send
what the session gave you and this is the only value you will ever need.
What the server actually requires is the headless- prefix, and the
difference matters in one place: a Code object addresses the data plane with
headless-exec-{executionId}, because an execution holds a grant rather than
a session. The prefix is what makes the upload be applied through a client, so
the reference joins the parts tree instead of the bytes landing in storage
with nothing pointing at them. An id naming no live connection is served by an
ephemeral one.
^headless-Id of the parts-tree object the file is attached under.
1Body
Response
The file was stored and attached.
The objects the upload created, keyed by id.
One file does not always mean one object. A STEP assembly becomes a tree, a PDF becomes a document plus a page image per page, and a source file becomes a code object — so the answer is a map rather than a single record. A plain file that needs no conversion yields exactly one entry.
Hide child attributes
Hide child attributes
One object in the parts tree. Fields beyond these vary by type, so treat
this as the shape you can rely on rather than the whole record.
Hide child attributes
Hide child attributes
What the file became: reference for a stored file, geometry or
assembly for imported CAD, code for an imported source file.
Id of the object this was attached under.
Extension of the stored blob, including the leading dot. Present on
objects that own a file. Concatenated with id this gives the
fileName that downloads it.
x >= 0