> For a complete page index of the Captain API documentation, fetch https://docs.captain.dev/llms.txt?excludeSpec=true # Change Environment PATCH https://api.captain.dev/v2/collections/{collection_name}/environment Content-Type: application/json Move a collection between environments without reindexing. Reference: https://docs.captain.dev/reference/collections/environment ## Request ### Path parameters - `collection_name` (string, required) ### Body (application/json) This endpoint expects a ChangeEnvironmentRequest. - `new_environment` (enum, required) - Allowed values: `development`, `staging`, `production` ## Response ### 200 Successful Response - `collection_name` (string, required) - `files_moved` (integer, required) - `message` (string, required) - `new_environment` (string, required) - `previous_environment` (string, required) - `success` (boolean, required) ## Examples **Request** ```json { "new_environment": "production" } ``` **Response** ```json { "collection_name": "my_documents", "files_moved": 142, "message": "Collection 'my_documents' moved from development to production", "new_environment": "production", "previous_environment": "development", "success": true } ``` **SDK Code** ```python Python REST import requests import json BASE_URL = "https://api.captain.dev" API_KEY = "your_api_key" COLLECTION_NAME = "my_documents" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } response = requests.patch( f"{BASE_URL}/v2/collections/{COLLECTION_NAME}/environment", headers=headers, json={"new_environment": "production"}, timeout=30.0 ) if response.status_code == 200: data = response.json() print(f"Moved from {data['previous_environment']} to {data['new_environment']}") print(f"Files preserved: {data['files_moved']}") else: print(f"Error: {response.status_code}") print(response.text) ``` ```typescript TypeScript REST const BASE_URL = "https://api.captain.dev"; const API_KEY = "your_api_key"; const COLLECTION_NAME = "my_documents"; const response = await fetch( `${BASE_URL}/v2/collections/${COLLECTION_NAME}/environment`, { method: "PATCH", headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ new_environment: "production" }) } ); if (response.ok) { const data = await response.json(); console.log(`Moved from ${data.previous_environment} to ${data.new_environment}`); } else { console.error(`Error: ${response.status}`); } ``` > Captain is a fully managed API for deterministic file search over unstructured data. Connect cloud storage (S3, GCS, Azure, R2), index files, and query retrieved chunks with metadata.