> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://devin.ferndocs.com/api-reference/v-3/create-session/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://devin.ferndocs.com/_mcp/server. # Create Session POST https://api.devin.ai/v3/organizations/{org_id}/sessions Content-Type: application/json Create a new session Reference: https://devin.ferndocs.com/api-reference/v-3/create-session ## Authentication - `Authorization` header (bearer token, required) — Personal API Key (apk_user_*) or Service API Key (apk_*) ## Request ### Path parameters - `org_id` (string, required) — Organization ID (prefix: org-) ### Query parameters - `devin_id` (string, optional, nullable) ### Body (application/json) This endpoint expects a SessionCreateRequest. - `prompt` (string, required) — The initial prompt or instructions for the Devin session. - `attachment_urls` (list of string, optional, nullable) — Presigned URLs of files to attach to the session at creation. - `bypass_approval` (boolean, optional, nullable) — When true, skip safe-mode approval prompts for this session. - `child_playbook_id` (string, optional, nullable) — Playbook ID to run in child sessions spawned by this session. - `create_as_user_id` (string, optional, nullable) — Create the session on behalf of another user (requires enterprise admin). - `devin_mode` (enum, optional, nullable) — Override the Devin agent mode for the session. 'normal' is the default agent mode (fast and good at long-horizon planning). 'fast' is ~2x faster, 4x more expensive, same intelligence. Fast mode is subject to the same feature flag and enterprise agent preview restrictions as the web app. - Allowed values: `normal`, `fast` - `knowledge_ids` (list of string, optional, nullable) — IDs of knowledge notes to inject into the session context. - `max_acu_limit` (integer, optional, nullable) — Maximum ACU (AI Compute Unit) budget for this session. - `platform` (string, optional, nullable) — Override the VM platform for the session (e.g. 'windows'). When omitted (or set to 'inherit'), a session created by a parent Devin inherits the parent's platform; otherwise the organization default is used. Pass 'default' to force the organization default regardless of parent. Any other value must match a platform configured for your organization (case-insensitive); unrecognized values are rejected with a 400 whose error body lists the available platform labels for the org. - `playbook_id` (string, optional, nullable) — ID of a playbook to run when the session starts (prefix playbook-). - `repos` (list of string, optional, nullable) — Repository URLs to clone into the session environment. - `secret_ids` (list of string, optional, nullable) — IDs of organization secrets to inject into the session. - `session_links` (list of string, optional, nullable) — URLs to share with the session for reference. - `session_secrets` (list of SessionSecretInput, optional, nullable) — Inline secrets (key-value pairs) to inject for this session only. - `structured_output_required` (boolean, optional, nullable) — When true (default), the agent MUST call provide_structured_output with is_final=true before its turn ends. When false, the tool is available but not required — it is not guaranteed to be called in a given turn. - `structured_output_schema` (map from string to any, optional, nullable) — JSON Schema (Draft 7) for validating structured output. Max 64KB. Must be self-contained (no external $ref). - `tags` (list of string, optional, nullable) — Tags to apply to the session for filtering and organization. - `title` (string, optional, nullable) — Optional human-readable title for the session. ## Response ### 200 Successful Response - `acus_consumed` (double, required) — Total ACUs consumed by this session so far. - `created_at` (integer, required) — Unix timestamp (seconds) when the session was created. - `org_id` (string, required) — Organization that owns this session (prefix org-). - `pull_requests` (list of SessionPullRequest, required) — Pull requests created by this session. - `session_id` (string, required) — Unique session identifier (prefix devin-). - `status` (enum, required) — Current lifecycle status: running, suspended, stopped, or blocked. - Allowed values: `new`, `claimed`, `running`, `exit`, `error`, `suspended`, `resuming` - `tags` (list of string, required) — Tags applied to this session. - `updated_at` (integer, required) — Unix timestamp (seconds) of the last session update. - `url` (string, required) — URL to view the session in the Devin web app. - `category` (enum, optional, nullable) — The session's assigned use-case category, if categorisation has run. Only populated on get/list endpoints. - Allowed values: `bug_fixing`, `ci_cd_and_devops`, `code_quality_and_security`, `code_review_and_analysis`, `data_and_automation`, `documentation_and_content`, `feature_development`, `migrations_and_upgrades`, `other`, `refactoring_and_optimization`, `research_and_exploration`, `unit_test_generation` - `child_session_ids` (list of string, optional, nullable) — Devin IDs of child sessions spawned by this session. - `is_archived` (boolean, optional, default: false) — Whether the session has been archived. - `origin` (enum, optional, nullable) — The origin from which the session was created. - Allowed values: `webapp`, `slack`, `teams`, `api`, `linear`, `jira`, `automation`, `cli`, `desktop`, `other` - `parent_session_id` (string, optional, nullable) — Devin ID of the parent session, if this is a child session. - `playbook_id` (string, optional, nullable) — Playbook running in this session, if any. - `service_user_id` (string, optional, nullable) — Service user ID if the session was created via API key. - `status_detail` (enum, optional, nullable) — Additional detail about the session's current status. When status is 'running': 'working' (actively working), 'waiting_for_user' (needs user input), 'waiting_for_approval' (awaiting action approval in safe mode), or 'finished' (task complete). When status is 'suspended': the reason for suspension such as 'inactivity', 'user_request', 'usage_limit_exceeded', 'out_of_credits', 'out_of_quota', 'no_quota_allocation', 'payment_declined', 'org_usage_limit_exceeded', 'total_session_limit_exceeded', or 'error'. Only populated on get/list endpoints. - Allowed values: `working`, `waiting_for_user`, `waiting_for_approval`, `finished`, `inactivity`, `user_request`, `usage_limit_exceeded`, `out_of_credits`, `out_of_quota`, `no_quota_allocation`, `payment_declined`, `org_usage_limit_exceeded`, `total_session_limit_exceeded`, `error` - `structured_output` (map from string to any, optional, nullable) — Validated structured output from the session. Only populated on get/list endpoints. - `subcategory` (string, optional, nullable) — The session's assigned subcategory display name. 'Other' when a category is set but no subcategory was assigned or resolved. Only populated on get/list endpoints. - `title` (string, optional, nullable) — Human-readable session title. - `user_id` (string, optional, nullable) — ID of the user who created or owns the session. ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### SessionSecretInput Input model for a session secret provided via API. - `key` (string, required) - `value` (string, required) - `sensitive` (boolean, optional, default: true) ### SessionPullRequest - `pr_state` (string, required, nullable) - `pr_url` (string, required) ### ValidationError - `loc` (list of ValidationErrorLocItems, required) - `msg` (string, required) - `type` (string, required) ### ValidationErrorLocItems ## Examples **Request** ```json { "prompt": "Analyze the recent error logs and suggest fixes for the failing API endpoints." } ``` **Response** ```json { "acus_consumed": 12.5, "created_at": 1686806400, "org_id": "org-abc123def456", "pull_requests": [ { "pr_state": "open", "pr_url": "https://github.com/org/repo/pull/42" } ], "session_id": "sess-456def789ghi", "status": "new", "tags": [ "urgent", "backend" ], "updated_at": 1686810000, "url": "https://app.devin.ai/sessions/sess-456def789ghi", "category": "bug_fixing", "child_session_ids": [ "sess-789xyz456abc" ], "is_archived": false, "origin": "webapp", "parent_session_id": "sess-123abc456def", "playbook_id": "playbook-00123", "service_user_id": "svc-user-987654", "status_detail": "working", "structured_output": {}, "subcategory": "api_errors", "title": "API Endpoint Failure Analysis", "user_id": "user-123456" } ``` **SDK Code** ```python import requests url = "https://api.devin.ai/v3/organizations/org-abc123def456/sessions" payload = { "prompt": "Analyze the recent error logs and suggest fixes for the failing API endpoints." } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.devin.ai/v3/organizations/org-abc123def456/sessions'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"prompt":"Analyze the recent error logs and suggest fixes for the failing API endpoints."}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.devin.ai/v3/organizations/org-abc123def456/sessions" payload := strings.NewReader("{\n \"prompt\": \"Analyze the recent error logs and suggest fixes for the failing API endpoints.\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.devin.ai/v3/organizations/org-abc123def456/sessions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"prompt\": \"Analyze the recent error logs and suggest fixes for the failing API endpoints.\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.devin.ai/v3/organizations/org-abc123def456/sessions") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"prompt\": \"Analyze the recent error logs and suggest fixes for the failing API endpoints.\"\n}") .asString(); ``` ```php request('POST', 'https://api.devin.ai/v3/organizations/org-abc123def456/sessions', [ 'body' => '{ "prompt": "Analyze the recent error logs and suggest fixes for the failing API endpoints." }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.devin.ai/v3/organizations/org-abc123def456/sessions"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"prompt\": \"Analyze the recent error logs and suggest fixes for the failing API endpoints.\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["prompt": "Analyze the recent error logs and suggest fixes for the failing API endpoints."] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.devin.ai/v3/organizations/org-abc123def456/sessions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```