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.
Step 2: List your organizations
Enterprise service users can list all organizations:Step 3: Create a session
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
Step 3: Download
Do not use an API key with theurl value. That URL needs a web app sign-in.
Use the download endpoint with the attachment_id and name values. The endpoint returns a 307 redirect to a short-lived URL, so follow redirects:
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
The
/playbooks endpoints are deprecated. Playbooks are moving to Skills. In an account that has moved, this request writes the playbook’s skill. An account created on or after October 24, 2026 with no playbooks gets 410 from these endpoints. See Playbooks are moving to Skills.Full Python example
Scheduling automated sessions
Create recurring sessions with an automation that has aschedule:recurring trigger. The trigger takes one rrule condition: an iCalendar RRULE evaluated in UTC (for example FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;BYHOUR=13;BYMINUTE=0 for weekdays at 9 AM Eastern during daylight time). Requires the ManageOrgAutomations permission.
Create a scheduled automation
DTSTART with COUNT=1, for example DTSTART:20260915T170000Z\nRRULE:FREQ=DAILY;COUNT=1. The automation fires once and then disables itself.
List, update, and delete
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
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

