curl --request POST \
--url https://davinci-app.com/api/v2/projects/{projectId}/objects/{objectId}/exports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"format": "<string>"
}
'import os
from davinci_sdk import DavinciClient
with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
exported = client.content.export_object(project_id, document_id, format="pdf")
print(exported.file.id, exported.page_count)
pdf = client.projects.download_file(project_id, exported.file.id)
import { DavinciClient } from '@celedon/davinci-sdk';
const client = new DavinciClient({
apiKey: process.env.DAVINCI_API_KEY!,
});
const exported = await client.content.exportObject(projectId, documentId, { format: 'pdf' });
console.log(exported.file.id, exported.pageCount);
const pdf = await client.projects.downloadFile(projectId, exported.file.id);
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({format: '<string>'})
};
fetch('https://davinci-app.com/api/v2/projects/{projectId}/objects/{objectId}/exports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"objectId": "<string>",
"format": "<string>",
"file": {
"id": "<string>",
"name": "<string>",
"mimeType": "<string>",
"size": 1,
"contentUrl": "<string>"
},
"pageCount": 2
}{
"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": {}
}
}{
"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": {}
}
}Export an object to a file
Exports an object in one of the formats the editor’s Export menu offers for
it, and saves the file to the project as a reference: a document as pdf
or docx, slides as pptx or pdf, a table as xlsx, a figure as png
or svg. The file is the one the Export menu produces, with the same
styles, page size, and headers and footers.
Download the bytes from file.contentUrl. PDF exports report pageCount,
so a caller can check that a document fits.
The export runs on the server, in the same exporters the editor uses, whether or not anyone has the project open. The saved file is uncommitted until the branch is committed.
curl --request POST \
--url https://davinci-app.com/api/v2/projects/{projectId}/objects/{objectId}/exports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"format": "<string>"
}
'import os
from davinci_sdk import DavinciClient
with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
exported = client.content.export_object(project_id, document_id, format="pdf")
print(exported.file.id, exported.page_count)
pdf = client.projects.download_file(project_id, exported.file.id)
import { DavinciClient } from '@celedon/davinci-sdk';
const client = new DavinciClient({
apiKey: process.env.DAVINCI_API_KEY!,
});
const exported = await client.content.exportObject(projectId, documentId, { format: 'pdf' });
console.log(exported.file.id, exported.pageCount);
const pdf = await client.projects.downloadFile(projectId, exported.file.id);
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({format: '<string>'})
};
fetch('https://davinci-app.com/api/v2/projects/{projectId}/objects/{objectId}/exports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"objectId": "<string>",
"format": "<string>",
"file": {
"id": "<string>",
"name": "<string>",
"mimeType": "<string>",
"size": 1,
"contentUrl": "<string>"
},
"pageCount": 2
}{
"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": {}
}
}{
"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
Personal access token. The scopes granted at issuance determine both which
operations the key may call and the ceiling on the resource permissions it
can exercise. Each scope family is a ladder: projects:manage implies
projects:write and projects:read; cards:manage implies cards:write
and cards:read; and teams:manage implies teams:write and teams:read.
These are named API capability bundles, not blanket domain roles:
manage exposes only the permissions enumerated for that scope and never
bypasses the acting user's current role-based access.
Path Parameters
Project id. May be compound in the form {projectId}--{branchName}.
1Id of an object in the project.
1Query Parameters
Body
A format the Export menu offers for the object, such as pdf, docx,
pptx, xlsx, png, svg, or html. Case-insensitive. Print PDF,
which ends in the browser's print dialog, is not offered.
1View to export, for objects with more than one (for example table or
tree). Defaults to the view the object opens in.
Resolution for raster content in PDF exports. Defaults to 300.
72 <= x <= 600Package to save the file in, such as the Library,
00000000-0000-0000-0000-00000library. Defaults to the exported
object's parent.
Response
The object was exported and the file saved to the project.
The format exported, lower-case.
Number of pages, for PDF exports; null for other formats.
x >= 1