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
Use theurl 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 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

