### Dockerfile installation example Source: https://github.com/coder/coder/blob/main/docs/admin/templates/extending-templates/jetbrains-preinstall.md Automates the installation of a JetBrains IDE backend during the Docker image build process. ```dockerfile FROM codercom/example-base:ubuntu # JetBrains IDE installation (configurable) ARG IDE_CODE=IU ARG IDE_VERSION=2025.1 # Fetch and install IDE dynamically RUN mkdir -p ~/JetBrains \ && IDE_URL=$(curl -s "https://data.services.jetbrains.com/products/releases?code=${IDE_CODE}&majorVersion=${IDE_VERSION}&latest=true" | jq -r ".${IDE_CODE}[0].downloads.linux.link") \ && IDE_NAME=$(curl -s "https://data.services.jetbrains.com/products/releases?code=${IDE_CODE}&majorVersion=${IDE_VERSION}&latest=true" | jq -r ".${IDE_CODE}[0].name") \ && echo "Installing ${IDE_NAME}..." \ && wget -q ${IDE_URL} -P /tmp \ && tar -xzf /tmp/$(basename ${IDE_URL}) -C ~/JetBrains \ && rm -f /tmp/$(basename ${IDE_URL}) \ && echo "${IDE_NAME} installed successfully" ``` -------------------------------- ### Schedule Workspace Start Example Source: https://github.com/coder/coder/blob/main/docs/reference/cli/schedule_start.md Example command to set a workspace to start at 9:30 AM on weekdays in the Europe/Dublin timezone. ```console $ coder schedule start my-workspace 9:30AM Mon-Fri Europe/Dublin ``` -------------------------------- ### Common CLI Operations Source: https://github.com/coder/coder/blob/main/docs/reference/cli/index.md Examples for starting the server and initializing templates. ```console $ coder server ``` ```console $ coder templates init ``` -------------------------------- ### Install code-server via startup script Source: https://github.com/coder/coder/blob/main/docs/admin/templates/extending-templates/web-ides.md Install and start code-server within the workspace agent startup script. ```tf resource "coder_agent" "main" { arch = "amd64" os = "linux" startup_script = </tmp/vscode-web.log 2>&1 & EOF } ``` -------------------------------- ### Get workspace timings response example Source: https://github.com/coder/coder/blob/main/docs/reference/api/workspaces.md Example JSON response containing detailed timing metrics for agents and provisioners. ```json { "agent_connection_timings": [ { "ended_at": "2019-08-24T14:15:22Z", "stage": "init", "started_at": "2019-08-24T14:15:22Z", "workspace_agent_id": "string", "workspace_agent_name": "string" } ], "agent_script_timings": [ { "display_name": "string", "ended_at": "2019-08-24T14:15:22Z", "exit_code": 0, "stage": "init", "started_at": "2019-08-24T14:15:22Z", "status": "string", "workspace_agent_id": "string", "workspace_agent_name": "string" } ], "provisioner_timings": [ { "action": "string", "ended_at": "2019-08-24T14:15:22Z", "job_id": "453bd7d7-5355-4d6d-a38e-d9e7eb218c3f", "resource": "string", "source": "string", "stage": "init", "started_at": "2019-08-24T14:15:22Z" } ] } ``` -------------------------------- ### Push New Template Version with Coder CLI Source: https://github.com/coder/coder/blob/main/docs/admin/templates/managing-templates/change-management.md This example demonstrates how to install the Coder CLI, set necessary environment variables for authentication and template details, and then push a new template version to Coder. Ensure CODER_URL and CODER_SESSION_TOKEN are set correctly. ```bash # Install the Coder CLI curl -L https://coder.com/install.sh | sh # curl -L https://coder.com/install.sh | sh -s -- --version=0.x # To create API tokens, use `coder tokens create`. # If no `--lifetime` flag is passed during creation, the default token lifetime # will be 30 days. # These variables are consumed by Coder export CODER_URL=https://coder.example.com export CODER_SESSION_TOKEN=***** # Template details export CODER_TEMPLATE_NAME=kubernetes export CODER_TEMPLATE_DIR=.coder/templates/kubernetes export CODER_TEMPLATE_VERSION=$(git rev-parse --short HEAD) # Push the new template version to Coder coder templates push --yes $CODER_TEMPLATE_NAME \ --directory $CODER_TEMPLATE_DIR \ --name=$CODER_TEMPLATE_VERSION # Version name is optional ``` -------------------------------- ### Install tools with mise Source: https://github.com/coder/coder/blob/main/docs/get-started/customize-your-template/install-command-line-tools.md Uses mise to install prebuilt binaries into a persistent home directory on workspace startup. ```tf resource "coder_script" "install_tools" { agent_id = coder_agent.main.id display_name = "Install Tools" icon = "/icon/terminal.svg" run_on_start = true script = <<-EOT #!/usr/bin/env bash set -e # Install mise on first start. It lives in /home/coder, so later starts reuse it. if [ ! -x "$HOME/.local/bin/mise" ]; then curl -fsSL https://mise.run | sh fi export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH" # Install the tools for everyone who uses the template, tracking the latest release. mise use -g ripgrep@latest bat@latest # Load mise in new interactive shells so the tools are on PATH. if ! grep -qs 'mise activate' "$HOME/.bashrc"; then echo 'eval "$(mise activate bash)"' >> "$HOME/.bashrc" fi EOT } ``` -------------------------------- ### Implement conditional startup script logic Source: https://github.com/coder/coder/blob/main/docs/tutorials/faqs.md Use the parameter value in a shell script to conditionally install and start the application. ```sh # install and start code-server, VS Code in a browser if [ ${data.coder_parameter.code_server.value} = true ]; then echo "🧑🏼‍💻 Downloading and installing the latest code-server IDE..." curl -fsSL https://code-server.dev/install.sh | sh code-server --auth none --port 13337 >/dev/null 2>&1 & fi ``` -------------------------------- ### Activate user example Source: https://github.com/coder/coder/blob/main/docs/reference/cli/users_activate.md An example of activating a specific user by username. ```console coder users activate example_user ``` -------------------------------- ### Resolve workspace autostart response example Source: https://github.com/coder/coder/blob/main/docs/reference/api/workspaces.md Example JSON response indicating the autostart parameter mismatch status. ```json { "parameter_mismatch": true } ``` -------------------------------- ### Inline Personalization Script Source: https://github.com/coder/coder/blob/main/docs/user-guides/workspace-dotfiles.md Example of a ~/personalize script that installs custom tools upon workspace startup. ```sh #!/bin/bash sudo apt update # Install some of my favorite tools every time my workspace boots sudo apt install -y neovim fish cargo ``` -------------------------------- ### Run External Provisioner with curl Source: https://github.com/coder/coder/blob/main/docs/admin/provisioners/index.md Use this snippet to install the Coder CLI and start an external provisioner on a VM. Ensure CODER_URL and CODER_SESSION_TOKEN are set. ```sh curl -L https://coder.com/install.sh | sh export CODER_URL=https://coder.example.com export CODER_SESSION_TOKEN=your_token coder provisioner start ``` -------------------------------- ### Install mise Source: https://github.com/coder/coder/blob/main/docs/get-started/customize-your-template/install-command-line-tools.md Downloads and runs the mise installation script. ```sh curl -fsSL https://mise.run | sh ``` -------------------------------- ### Install Ruby in Startup Script Source: https://github.com/coder/coder/blob/main/docs/get-started/customize-your-template/add-a-language.md Add this logic to install-languages.sh.tftpl to conditionally install Ruby based on user selection. ```sh if echo "$LANGUAGES" | grep -q "ruby"; then if command -v ruby >/dev/null 2>&1; then echo "Ruby: $(ruby --version | head -1)" else echo "Installing Ruby toolchain..." apt_update sudo apt-get install -y -qq ruby-full echo "Installed Ruby: $(ruby --version | head -1)" fi fi ``` -------------------------------- ### Display OIDC claims examples Source: https://github.com/coder/coder/blob/main/docs/reference/cli/users_oidc-claims.md Examples showing how to display claims in default and JSON formats. ```console $ coder users oidc-claims ``` ```console $ coder users oidc-claims -o json ``` -------------------------------- ### Install dotfiles without prompts Source: https://github.com/coder/coder/blob/main/docs/reference/cli/dotfiles.md Use the --yes flag to bypass confirmation prompts during the installation process. ```console $ coder dotfiles --yes git@github.com:example/dotfiles.git ``` -------------------------------- ### 200 OK response example Source: https://github.com/coder/coder/blob/main/docs/reference/api/templates.md Example JSON response returned when the template version is successfully retrieved. ```json [ { "archived": true, "created_at": "2019-08-24T14:15:22Z", "created_by": { "avatar_url": "http://example.com", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "username": "string" }, "has_external_agent": true, "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "job": { "available_workers": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ], "canceled_at": "2019-08-24T14:15:22Z", "completed_at": "2019-08-24T14:15:22Z", "created_at": "2019-08-24T14:15:22Z", "error": "string", "error_code": "REQUIRED_TEMPLATE_VARIABLES", "file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "initiator_id": "06588898-9a84-4b35-ba8f-f9cbd64946f3", "input": { "error": "string", "template_version_id": "0ba39c92-1f1b-4c32-aa3e-9925d7713eb1", "workspace_build_id": "badaf2eb-96c5-4050-9f1d-db2d39ca5478" }, "logs_overflowed": true, "metadata": { "template_display_name": "string", "template_icon": "string", "template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc", "template_name": "string", "template_version_name": "string", "workspace_build_transition": "start", "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9", "workspace_name": "string" }, "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "queue_position": 0, "queue_size": 0, "started_at": "2019-08-24T14:15:22Z", "status": "pending", "tags": { "property1": "string", "property2": "string" }, "type": "template_version_import", "worker_id": "ae5fa6f7-c55b-40c1-b40a-b36ac467652b", "worker_name": "string" }, "matched_provisioners": { "available": 0, "count": 0, "most_recently_seen": "2019-08-24T14:15:22Z" }, "message": "string", "name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "readme": "string", "template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc", "updated_at": "2019-08-24T14:15:22Z", "warnings": [ "UNSUPPORTED_WORKSPACES" ] } ] ``` -------------------------------- ### Install Languages Script Source: https://github.com/coder/coder/blob/main/docs/get-started/customize-your-template/authenticate-to-github.md Executes a language installation script on the agent, ensuring it runs on workspace start. ```hcl resource "coder_script" "install_languages" { count = length(local.languages) > 0 ? 1 : 0 agent_id = coder_agent.main.id display_name = "Install Languages" icon = "/icon/code.svg" run_on_start = true start_blocks_login = true script = templatefile("${path.module}/install-languages.sh.tftpl", { LANGUAGES = join(",", local.languages) }) } ``` -------------------------------- ### Informative startup script example Source: https://github.com/coder/coder/blob/main/docs/admin/templates/troubleshooting.md A template for a startup script that provides manual logging of command execution and exit statuses to aid in debugging. ```sh echo "Running startup script..." echo "Run: long-running-command" /path/to/long-running-command status=$? echo "Done: long-running-command, exit status: ${status}" if [ $status -ne 0 ]; then echo "Startup script failed, exiting..." exit $status fi ``` -------------------------------- ### Get chat auto archive days response example Source: https://github.com/coder/coder/blob/main/docs/reference/api/chats.md Example JSON response containing the auto-archive configuration. ```json { "auto_archive_days": 0 } ``` -------------------------------- ### Configure startup script and image for extensions Source: https://github.com/coder/coder/blob/main/docs/user-guides/workspace-access/vscode.md Use the startup script to install extensions and define the container image in the template. ```tf resource "coder_agent" "main" { ... startup_script = "code-server --install-extension /vsix/GitHub.copilot.vsix" } ``` ```tf resource "kubernetes_deployment" "main" { spec { template { spec { container { name = "dev" image = "registry.internal/image-name:tag" } } } } } ``` -------------------------------- ### Install latest stable Coder release Source: https://github.com/coder/coder/blob/main/docs/install/releases/index.md Use this command to download and execute the installation script with the stable flag. ```sh curl -fsSL https://coder.com/install.sh | sh -s -- --stable ``` -------------------------------- ### Install Netcat Source: https://github.com/coder/coder/blob/main/dogfood/coder/guide.md Installs the netcat utility, which may be required for certain Coder development setups. Skip if using the 'coder' template. ```bash sudo apt update sudo apt install -y netcat ``` -------------------------------- ### Pull starter template Source: https://github.com/coder/coder/blob/main/docs/admin/templates/creating-templates.md Download a starter template to the local machine. ```sh coder templates init ``` -------------------------------- ### Start a provisioner daemon Source: https://github.com/coder/coder/blob/main/docs/reference/cli/provisioner_start.md Execute the provisioner daemon using the CLI. ```console coder provisioner start [flags] ``` -------------------------------- ### Get deployment DAUs response Source: https://github.com/coder/coder/blob/main/docs/reference/api/insights.md Example JSON response for the DAUs endpoint. ```json { "entries": [ { "amount": 0, "date": "string" } ], "tz_hour_offset": 0 } ``` -------------------------------- ### GET /api/v2/templates/examples Source: https://github.com/coder/coder/blob/main/docs/reference/api/templates.md Retrieves a list of available template examples. This operation requires authentication. ```APIDOC ## GET /api/v2/templates/examples ### Description Retrieves a list of template examples available in the system. ### Method GET ### Endpoint /api/v2/templates/examples ### Response #### Success Response (200) - **[array item]** (array) - List of template examples - **description** (string) - Description of the template example - **icon** (string) - Icon associated with the template - **id** (string) - Unique identifier (UUID) of the template example - **markdown** (string) - Markdown content describing the template - **name** (string) - Name of the template example - **tags** (array) - List of tags associated with the template - **url** (string) - URL for the template example #### Response Example [ { "description": "string", "icon": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "markdown": "string", "name": "string", "tags": ["string"], "url": "string" } ] ``` -------------------------------- ### GET /api/v2/organizations/{organization}/templates/examples Source: https://github.com/coder/coder/blob/main/docs/reference/api/templates.md Retrieves a list of template examples for the specified organization. ```APIDOC ## GET /api/v2/organizations/{organization}/templates/examples ### Description Retrieves a list of template examples for the specified organization. ### Method GET ### Endpoint /api/v2/organizations/{organization}/templates/examples ### Parameters #### Path Parameters - **organization** (string(uuid)) - Required - Organization ID ### Response #### Success Response (200) - **description** (string) - Description - **icon** (string) - Icon - **id** (string(uuid)) - Template example ID - **markdown** (string) - Markdown content - **name** (string) - Name - **tags** (array) - Tags - **url** (string) - URL #### Response Example [ { "description": "string", "icon": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "markdown": "string", "name": "string", "tags": [ "string" ], "url": "string" } ] ``` -------------------------------- ### Start the application Source: https://github.com/coder/coder/blob/main/docs/admin/monitoring/notifications/slack.md Run the Node.js application. ```sh node app.js ``` -------------------------------- ### Configure Docker on Linux Source: https://github.com/coder/coder/blob/main/docs/get-started/index.md Commands to install, start, and configure Docker permissions for Coder on Linux. ```sh curl -sSL https://get.docker.com | sh ``` ```sh sudo systemctl start docker ``` ```sh sudo usermod -aG docker $USER newgrp docker ``` ```console $ groups docker sudo users ``` -------------------------------- ### Get workspace builds request Source: https://github.com/coder/coder/blob/main/docs/reference/api/builds.md Example curl request to retrieve builds for a specific workspace. ```sh # Example request using curl curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/builds \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY' ``` -------------------------------- ### Start development environment Source: https://github.com/coder/coder/blob/main/docs/about/contributing/CONTRIBUTING.md Launches the backend API server and the Node.js frontend development server with hot reloading. ```sh ./scripts/develop.sh ``` -------------------------------- ### Get workspace agent request Source: https://github.com/coder/coder/blob/main/docs/reference/api/agents.md Example curl request to retrieve a workspace agent by ID. ```sh curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent} \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY' ``` -------------------------------- ### Start Provisioner with Global PSK Source: https://github.com/coder/coder/blob/main/docs/admin/provisioners/index.md Starts a provisioner using a global pre-shared key. This method is not recommended for security reasons. ```sh coder provisioner start --psk ``` -------------------------------- ### Get provisioner job response Source: https://github.com/coder/coder/blob/main/docs/reference/api/organizations.md Example JSON response for a successful provisioner job retrieval. ```json { "available_workers": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ], "canceled_at": "2019-08-24T14:15:22Z", "completed_at": "2019-08-24T14:15:22Z", "created_at": "2019-08-24T14:15:22Z", "error": "string", "error_code": "REQUIRED_TEMPLATE_VARIABLES", "file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "initiator_id": "06588898-9a84-4b35-ba8f-f9cbd64946f3", "input": { "error": "string", "template_version_id": "0ba39c92-1f1b-4c32-aa3e-9925d7713eb1", "workspace_build_id": "badaf2eb-96c5-4050-9f1d-db2d39ca5478" }, "logs_overflowed": true, "metadata": { "template_display_name": "string", "template_icon": "string", "template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc", "template_name": "string", "template_version_name": "string", "workspace_build_transition": "start", "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9", "workspace_name": "string" }, "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "queue_position": 0, "queue_size": 0, "started_at": "2019-08-24T14:15:22Z", "status": "pending", "tags": { "property1": "string", "property2": "string" }, "type": "template_version_import", "worker_id": "ae5fa6f7-c55b-40c1-b40a-b36ac467652b", "worker_name": "string" } ``` -------------------------------- ### Start Provisioner with User Token and Tags Source: https://github.com/coder/coder/blob/main/docs/admin/provisioners/index.md Start a provisioner using your user token, specifying tags to filter which jobs the provisioner will handle. This requires a matching template on your deployment. ```sh coder login https:// coder provisioner start \ --tag environment=kubernetes ``` -------------------------------- ### Get provisioner daemons response Source: https://github.com/coder/coder/blob/main/docs/reference/api/provisioning.md Example JSON response returned by the provisioner daemons endpoint. ```json [ { "api_version": "string", "created_at": "2019-08-24T14:15:22Z", "current_job": { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "status": "pending", "template_display_name": "string", "template_icon": "string", "template_name": "string" }, "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "key_id": "1e779c8a-6786-4c89-b7c3-a6666f5fd6b5", "key_name": "string", "last_seen_at": "2019-08-24T14:15:22Z", "name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "previous_job": { "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "status": "pending", "template_display_name": "string", "template_icon": "string", "template_name": "string" }, "provisioners": [ "string" ], "status": "offline", "tags": { "property1": "string", "property2": "string" }, "version": "string" } ] ``` -------------------------------- ### Initialize and Push Coder Template Source: https://github.com/coder/coder/blob/main/examples/templates/README.md Clone the Coder repository to create a template from an example. Navigate to the example directory and push the template using the Coder CLI. ```bash git clone https://github.com/coder/coder cd examples/templates/aws-linux coder templates push ``` -------------------------------- ### Install and enable Apache modules Source: https://github.com/coder/coder/blob/main/docs/tutorials/reverse-proxy-apache.md Commands to install the Apache web server and enable the necessary modules for proxying and SSL. ```sh sudo apt install apache2 ``` ```sh sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod ssl sudo a2enmod rewrite ``` -------------------------------- ### Enable site and restart Apache Source: https://github.com/coder/coder/blob/main/docs/tutorials/reverse-proxy-apache.md Activate the new configuration and apply changes. ```sh sudo a2ensite coder.conf ``` ```sh sudo systemctl restart apache2 ``` -------------------------------- ### Configure Docker on macOS Source: https://github.com/coder/coder/blob/main/docs/get-started/index.md Commands to install Colima, start the daemon, and configure the DOCKER_HOST environment variable. ```sh brew install colima docker ``` ```sh colima start ``` ```sh docker ps ``` ```sh export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock" ``` -------------------------------- ### Install Gateway backend Source: https://github.com/coder/coder/blob/main/docs/admin/templates/extending-templates/jetbrains-preinstall.md Downloads the specified IDE backend to the ~/JetBrains directory. ```sh mkdir ~/JetBrains ./jetbrains-clients-downloader-linux-x86_64-*/bin/jetbrains-clients-downloader --products-filter --build-filter --platforms-filter linux-x64 --download-backends ~/JetBrains ``` ```sh ./jetbrains-clients-downloader-linux-x86_64-*/bin/jetbrains-clients-downloader --products-filter IU --build-filter 243.26053.27 --platforms-filter linux-x64 --download-backends ~/JetBrains tar -xzvf ~/JetBrains/backends/IU/*.tar.gz -C ~/JetBrains/backends/IU rm -rf ~/JetBrains/backends/IU/*.tar.gz ``` -------------------------------- ### Group list response structure Source: https://github.com/coder/coder/blob/main/docs/reference/api/enterprise.md Example JSON response body returned by the GET /api/v2/groups endpoint. ```json [ { "avatar_url": "http://example.com", "display_name": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "members": [ { "avatar_url": "http://example.com", "created_at": "2019-08-24T14:15:22Z", "email": "user@example.com", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "is_service_account": true, "last_seen_at": "2019-08-24T14:15:22Z", "login_type": "", "name": "string", "status": "active", "theme_preference": "string", "updated_at": "2019-08-24T14:15:22Z", "username": "string" } ], "name": "string", "organization_display_name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "organization_name": "string", "quota_allowance": 0, "source": "user", "total_member_count": 0 } ] ``` -------------------------------- ### Get templates by organization response Source: https://github.com/coder/coder/blob/main/docs/reference/api/templates.md Example JSON response body for a successful 200 status code. ```json [ { "active_user_count": 0, "active_version_id": "eae64611-bd53-4a80-bb77-df1e432c0fbc", "activity_bump_ms": 0, "agents_allowed": true, "allow_user_autostart": true, "allow_user_autostop": true, "allow_user_cancel_workspace_jobs": true, "allow_workspace_renames": true, "autostart_requirement": { "days_of_week": [ "monday" ] }, "autostop_requirement": { "days_of_week": [ "monday" ], "weeks": 0 }, "build_time_stats": { "property1": { "p50": 123, "p95": 146 }, "property2": { "p50": 123, "p95": 146 } }, "cors_behavior": "simple", "created_at": "2019-08-24T14:15:22Z", "created_by_id": "9377d689-01fb-4abf-8450-3368d2c1924f", "created_by_name": "string", "default_ttl_ms": 0, "deleted": true, "deprecated": true, "deprecation_message": "string", "description": "string", "disable_module_cache": true, "display_name": "string", "failure_ttl_ms": 0, "icon": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "max_port_share_level": "owner", "name": "string", "organization_display_name": "string", "organization_icon": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "organization_name": "string", "provisioner": "terraform", "require_active_version": true, "time_til_autostop_notify_ms": 0, "time_til_dormant_autodelete_ms": 0, "time_til_dormant_ms": 0, "updated_at": "2019-08-24T14:15:22Z", "use_classic_parameter_flow": true } ] ``` -------------------------------- ### Get workspace builds response Source: https://github.com/coder/coder/blob/main/docs/reference/api/builds.md Example JSON response body for a successful workspace builds retrieval. ```json [ { "build_number": 0, "created_at": "2019-08-24T14:15:22Z", "daily_cost": 0, "deadline": "2019-08-24T14:15:22Z", "has_ai_task": true, "has_external_agent": true, "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "initiator_id": "06588898-9a84-4b35-ba8f-f9cbd64946f3", "initiator_name": "string", "job": { "available_workers": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ], "canceled_at": "2019-08-24T14:15:22Z", "completed_at": "2019-08-24T14:15:22Z", "created_at": "2019-08-24T14:15:22Z", "error": "string", "error_code": "REQUIRED_TEMPLATE_VARIABLES", "file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "initiator_id": "06588898-9a84-4b35-ba8f-f9cbd64946f3", "input": { "error": "string", "template_version_id": "0ba39c92-1f1b-4c32-aa3e-9925d7713eb1", "workspace_build_id": "badaf2eb-96c5-4050-9f1d-db2d39ca5478" }, "logs_overflowed": true, "metadata": { "template_display_name": "string", "template_icon": "string", "template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc", "template_name": "string", "template_version_name": "string", "workspace_build_transition": "start", "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9", "workspace_name": "string" }, "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "queue_position": 0, "queue_size": 0, "started_at": "2019-08-24T14:15:22Z", "status": "pending", "tags": { "property1": "string", "property2": "string" }, "type": "template_version_import", "worker_id": "ae5fa6f7-c55b-40c1-b40a-b36ac467652b", "worker_name": "string" }, "matched_provisioners": { "available": 0, "count": 0, "most_recently_seen": "2019-08-24T14:15:22Z" }, "max_deadline": "2019-08-24T14:15:22Z", "reason": "initiator", "resources": [ { "agents": [ { "api_version": "string", "apps": [ { "command": "string", "display_name": "string", "external": true, "group": "string", "health": "disabled", "healthcheck": { "interval": 0, "threshold": 0, "url": "string" }, "hidden": true, "icon": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "open_in": "slim-window", "sharing_level": "owner", "slug": "string", "statuses": [ { "agent_id": "2b1e3b65-2c04-4fa2-a2d7-467901e98978", "app_id": "affd1d10-9538-4fc8-9e0b-4594a28c1335", "created_at": "2019-08-24T14:15:22Z", "icon": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "message": "string", "needs_user_attention": true, "state": "working", "uri": "string", "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9" } ], "subdomain": true, "subdomain_name": "string", "tooltip": "string", "url": "string" } ], "architecture": "string", "connection_timeout_seconds": 0, "created_at": "2019-08-24T14:15:22Z", "directory": "string", "disconnected_at": "2019-08-24T14:15:22Z", "display_apps": [ "vscode" ], "environment_variables": { "property1": "string", "property2": "string" }, "expanded_directory": "string", "first_connected_at": "2019-08-24T14:15:22Z", "health": { ``` -------------------------------- ### Stop and Start Azure VM for Persistent Workspaces Source: https://github.com/coder/coder/blob/main/examples/templates/azure-windows/README.md These resources manage the stopping (deallocating) and starting of an Azure VM based on workspace transitions. Ensure the 'az' CLI is installed in the Coder Provisioner's PATH. ```hcl # Stop the VM resource "null_resource" "stop_vm" { count = data.coder_workspace.me.transition == "stop" ? 1 : 0 depends_on = [azurerm_windows_virtual_machine.main] provisioner "local-exec" { # Use deallocate so the VM is not charged command = "az vm deallocate --ids ${azurerm_windows_virtual_machine.main.id}" } } # Start the VM resource "null_resource" "start" { count = data.coder_workspace.me.transition == "start" ? 1 : 0 depends_on = [azurerm_windows_virtual_machine.main] provisioner "local-exec" { command = "az vm start --ids ${azurerm_windows_virtual_machine.main.id}" } } ``` -------------------------------- ### Make Setup Script Executable Source: https://github.com/coder/coder/blob/main/docs/user-guides/workspace-dotfiles.md Commands to ensure a dotfiles setup script has the necessary execution permissions before pushing to the repository. ```sh cd chmod +x git commit -m "Make executable" git push ``` -------------------------------- ### Get logs by template version request Source: https://github.com/coder/coder/blob/main/docs/reference/api/templates.md Example curl request to retrieve logs for a specific template version. ```sh curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/logs \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY' ``` -------------------------------- ### System Utility Output Examples Source: https://github.com/coder/coder/blob/main/docs/admin/templates/extending-templates/agent-metadata.md Example outputs from common Linux utilities used for gathering system metrics. ```txt %Cpu(s): 65.8 us, 4.4 sy, 0.0 ni, 29.3 id, 0.3 wa, 0.0 hi, 0.2 si, 0.0 st MiB Mem : 16009.0 total, 493.7 free, 4624.8 used, 10890.5 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 11021.3 avail Mem ``` ```txt procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 19580 4781680 12133692 217646944 0 2 4 32 1 0 1 1 98 0 0 ``` ```txt --total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system-- usr sys idl wai stl| read writ| recv send| in out | int csw 1 1 98 0 0|3422k 25M| 0 0 | 153k 904k| 123k 174k ``` -------------------------------- ### Get template insights response Source: https://github.com/coder/coder/blob/main/docs/reference/api/insights.md Example JSON response containing interval reports and detailed usage metrics. ```json { "interval_reports": [ { "active_users": 14, "end_time": "2019-08-24T14:15:22Z", "interval": "week", "start_time": "2019-08-24T14:15:22Z", "template_ids": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ] } ], "report": { "active_users": 22, "apps_usage": [ { "display_name": "Visual Studio Code", "icon": "string", "seconds": 80500, "slug": "vscode", "template_ids": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ], "times_used": 2, "type": "builtin" } ], "end_time": "2019-08-24T14:15:22Z", "parameters_usage": [ { "description": "string", "display_name": "string", "name": "string", "options": [ { "description": "string", "icon": "string", "name": "string", "value": "string" } ], "template_ids": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ], "type": "string", "values": [ { "count": 0, "value": "string" } ] } ], "start_time": "2019-08-24T14:15:22Z", "template_ids": [ "497f6eca-6276-4993-bfeb-53cbbbba6f08" ] } } ``` -------------------------------- ### Start Coder Server for Production Source: https://github.com/coder/coder/blob/main/README.md Launch the server with specific PostgreSQL and access URL configurations for production environments. ```shell coder server --postgres-url --access-url ``` -------------------------------- ### Login and Start Provisioner with User Token Source: https://github.com/coder/coder/blob/main/docs/admin/provisioners/index.md Authenticate with your Coder deployment using `coder login` and then start a provisioner using your user account. This is useful for automation. ```sh coder login https:// coder provisioner start ``` -------------------------------- ### GET /api/v2/templatebuilder/modules Source: https://github.com/coder/coder/blob/main/docs/reference/api/templatebuilder.md Retrieves a list of available template builder modules, optionally filtered by a base template example ID. ```APIDOC ## GET /api/v2/templatebuilder/modules ### Description Retrieves a list of available template builder modules. You can optionally filter the results by providing a base template example ID for OS-compatibility. ### Method GET ### Endpoint /api/v2/templatebuilder/modules ### Parameters #### Query Parameters - **base** (string) - Optional - Base template example ID for OS-compatibility filtering ### Request Example curl -X GET http://coder-server:8080/api/v2/templatebuilder/modules -H 'Accept: application/json' -H 'Coder-Session-Token: API_KEY' ### Response #### Success Response (200) - **modules** (array) - A list of template builder modules. #### Response Example { "modules": [ { "category": "string", "compatible_os": ["string"], "conflicts_with": ["string"], "description": "string", "display_name": "string", "icon": "string", "id": "string", "variables": [ { "default": [0], "description": "string", "name": "string", "required": true, "sensitive": true, "type": "string" } ], "version": "string" } ] } ``` -------------------------------- ### Start the Coder Server Source: https://github.com/coder/coder/blob/main/docs/install/cli.md Launch the Coder server process. ```sh coder server ``` -------------------------------- ### Get user AI budget override response Source: https://github.com/coder/coder/blob/main/docs/reference/api/enterprise.md Example JSON response for a successful retrieval of user AI budget override. ```json { "created_at": "2019-08-24T14:15:22Z", "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f", "spend_limit_micros": 0, "updated_at": "2019-08-24T14:15:22Z", "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5" } ```