Skip to main content
This page walks through common end-to-end workflows with the Devin API. Each flow includes the full sequence of API calls with code examples. For individual endpoint details, see the relevant API reference pages.

Setup

Set these environment variables before running any example:

Getting started: API key to first session

The most common workflow — authenticate, discover your account, and create your first session.

Step 1: Verify your credentials

Organization-scoped service users can skip to Step 3 — you already know your org ID from the Settings page.
Response:

Step 2: List your organizations

Enterprise service users can list all organizations:
Organization-scoped service users already know their org ID (it’s on the Settings > Service Users page where the key was created).

Step 3: Create a session

Response:

Step 4: Poll for events

Monitor the session by polling for messages:

Full Python example


Downloading session attachments

Retrieve files produced by a session (logs, screenshots, generated code, etc.).

Step 1: Get the session

Step 2: List attachments

Response:

Step 3: Download

Use the url from the attachment response to download the file directly.

Full Python example


Knowledge & playbook management

Manage the context and instructions that Devin uses across sessions.

Create a knowledge note

List knowledge notes

Update a knowledge note

Delete a knowledge note

Create a playbook

Full Python example


Scheduling automated sessions

Create recurring sessions that run on a schedule.

Create a schedule

This creates a schedule that runs every weekday at 9 AM Eastern.

List schedules

Update a schedule

Delete a schedule

Full Python example


Hand off a task from anywhere

Because the Sessions API creates a cloud Devin session from a single request, any tool, script, or coding agent can “hand off” work to Devin — bundling the current repo, branch, and uncommitted changes into the prompt so the cloud session picks up where you left off.

Create a session with repo context

The cloud session clones the repo, applies the context from your prompt, and runs in its own VM with a shell, browser, and full repo access. Track it by polling for messages or in the Devin web app.
git diff HEAD can include uncommitted secrets — API keys, tokens, or .env edits — and the prompt is uploaded to the cloud session. Review your diff and commit, stash, or remove sensitive changes before handing off.
Don’t want to build this yourself? The open-source Devin Handoff plugin wraps exactly this flow — auto-detecting repo, branch, and diff — so you can hand off from the Devin CLI, Claude Code, Codex, Cursor, or a plain shell script. See Hand off to Devin.

Error handling

All examples above should include error handling in production. Here’s a reusable pattern:

Support

Need Help?

For questions about the API or to report issues, email support@cognition.ai