> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://devin.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://devin.ferndocs.com/_mcp/server.

# Archive Session

POST https://api.devin.ai/v3/organizations/{org_id}/sessions/{devin_id}/archive

Archive session and put it to sleep if currently running

Reference: https://devin.ferndocs.com/api-reference/v-3/archive-session

## Authentication

- `Authorization` header (bearer token, required) — Personal API Key (apk_user_*) or Service API Key (apk_*)

## Request

### Path parameters

- `devin_id` (string, required) — Devin session ID (prefix: devin-)
- `org_id` (string, required) — Organization ID (prefix: org-)

## 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

### 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
{}
```

**Response**

```json
{
  "acus_consumed": 12.5,
  "created_at": "2024-06-10T09:15:00Z",
  "org_id": "org-abc123def456",
  "pull_requests": [
    {
      "pr_state": "merged",
      "pr_url": "https://github.com/org/repo/pull/42"
    }
  ],
  "session_id": "devin-abc123def456",
  "status": "suspended",
  "tags": [
    "urgent",
    "frontend"
  ],
  "updated_at": "2024-06-10T10:00:00Z",
  "url": "https://app.devin.ai/sessions/devin-abc123def456",
  "category": "bug_fixing",
  "child_session_ids": [
    "devin-xyz789abc123"
  ],
  "is_archived": true,
  "origin": "webapp",
  "parent_session_id": "devin-uvw456ghi789",
  "playbook_id": "playbook-12345",
  "service_user_id": "svc-user-98765",
  "status_detail": "archived and put to sleep",
  "structured_output": {},
  "subcategory": "frontend_bug",
  "title": "Fix login button not responding",
  "user_id": "user-12345"
}
```

**SDK Code**

```python
import requests

url = "https://api.devin.ai/v3/organizations/org-abc123def456/sessions/devin-abc123def456/archive"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "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/devin-abc123def456/archive';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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/devin-abc123def456/archive"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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/devin-abc123def456/archive")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.devin.ai/v3/organizations/org-abc123def456/sessions/devin-abc123def456/archive")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.devin.ai/v3/organizations/org-abc123def456/sessions/devin-abc123def456/archive', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.devin.ai/v3/organizations/org-abc123def456/sessions/devin-abc123def456/archive");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] 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/devin-abc123def456/archive")! 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()
```