Overview
The Davinci Programmatic API lets scripts, CI jobs, apps, reporting tools, and AI systems read and change Davinci projects, work with a project’s agent, and manage Task Cards and team planning. The public v2 endpoints are documented in the API Reference. The current public API sections are:- Projects — create, open, close, and delete projects, read their branches, packages, and personas, and manage attached files.
- Content — read the object tree and objects, add and delete objects, and export an object to a file.
- Branches — create and delete branches, commit, read uncommitted changes, and read an object’s commit history.
- Sessions — open a project session and talk to its agent: send prompts, read the conversation, and stop a run. See Agent.
- Chats — list, read, rename, and delete your API chats with a project’s agent, and move a session between them.
- Agent Models — the models and model options available to your account.
- Tools — invoke one of the agent’s tools directly, without the agent.
- Files — upload and download large files through a session.
- Usage — what your model usage cost, by account, project, or session.
- Tests — start an authored Test, read its status and evidence, and cancel it.
- Organizations, Teams, and Cards — organizations, team boards, workflow statuses, sprints, project Task Cards, and the cards assigned to you across projects.
Getting Started
Create a personal access token, then pass it as a bearer token in theAuthorization header:
Personal Access Tokens
Programmatic API access uses user-owned personal access tokens. Tokens identify the user who created them, inherit that user’s project permissions, can be scoped, and can be revoked from account settings. Each endpoint lists the scope it requires in the API Reference. See Personal Access Tokens for token creation, expiration, rate limit, and format details. Store tokens in environment variables or a secret manager. Do not commit tokens to source control, paste them into shared logs, or embed them in client-side code.Scopes
Scopes limit what a token can do. A token can never do more than the user who created it, and its scopes usually narrow that further.
The
projects, cards, and teams scopes are ladders: manage includes write, and write includes read. A new token gets projects:read unless you choose other scopes.
Sessions And The Agent
A session opens a project, keeps it loaded while the session lives, and is where the project’s agent runs. Creating a session also returns a short-lived grant and a data-plane URL for large file transfers; the grant works only for that session’s project, carries no more permission than the token that created it, and expires in minutes. Conversations with the agent are kept as chats that outlive the session. Chats started through the API also appear in the Davinci web app, where you can watch a session work and take a chat over. See Agent for models, personas, images, and chats.Invoking Tools Directly
When you already know the operation you want, a session can run one of the agent’s tools itself, with no model choosing it. The result is deterministic and incurs no LLM charges. The tools available are the ones the session’s project has open, and the token still needs the permissions the tool’s work requires. This requiresprojects:write.
422 with the tool’s own message.
Usage
The Usage endpoints report what your model usage cost, for your whole account, one project, or one session, optionally between two times and broken down bymodel, project, session, or day. They require the usage:read scope; the project and session reads also require projects:read.
asOf is when the newest counted usage was recorded. These endpoints report spending, not your balances and limits.
Branches
Project data endpoints that read model contents support abranch query parameter. If omitted, SDK calls default to main.
Use branch names when you need to inspect project data outside the main branch, such as a review branch or integration branch.
File Downloads
Most successful API responses return JSON envelopes. File downloads are different: successful download responses return raw file bytes with content headers such asContent-Type, Content-Disposition, and Content-Length.
Creating Objects
POST /api/v2/projects/{projectId}/objects adds objects to a project. Every object needs a parent: its own parent, or a parentId for the whole request. Top-level model content goes in the Model package, 00000000-0000-0000-0000-0000000model, which the SDKs name MODEL_PACKAGE_ID.
Objects are checked the same way the Davinci agent’s own writes are. The parent has to exist and be able to hold the object’s type, children have to exist, and relationship types have to be ones the project defines. If any object fails, nothing is written, and the 400 response lists what was wrong with each refused object under error.details.objects.
Exports
POST /api/v2/projects/{projectId}/objects/{objectId}/exports exports an object in a format its Export menu offers, such as a document as pdf or docx, and saves the file to the project. The response returns the file’s id, a contentUrl to download it from, and the page count for PDFs. The export runs on the server with the same exporters as the editor, so nobody needs the project open. See Exports.
Errors
JSON errors use a consistent envelope:MISSING_AUTH, INVALID_API_KEY, INSUFFICIENT_SCOPES, PROJECT_NOT_FOUND, OBJECT_NOT_FOUND, FILE_NOT_FOUND, RATE_LIMITED, PROJECT_NOT_READY, and SERVICE_UNAVAILABLE.
Rate Limits
Personal access tokens have per-key request limits. When a token exceeds its limit, the API returns429 RATE_LIMITED and includes a Retry-After header with the number of seconds to wait before retrying.