Skip to main content

Introduction

The OpenCode Portal HTTP API provides programmatic access to manage OpenCode instances, sessions, and project operations. The API is organized around REST principles with predictable resource-oriented URLs.

Base URL

All API requests are made to:
The default portal port is typically 3000, but this may vary depending on your configuration.

Authentication

The OpenCode Portal API currently does not require authentication for local instances. All endpoints are accessible without API keys or tokens.
This API is designed for local development environments. If you expose the Portal to a network, ensure proper security measures are in place.

Port Parameter

Many endpoints include a :port parameter in the URL path. This refers to the OpenCode instance port number, not the Portal port. Each OpenCode instance runs on its own port (typically starting at 3100).

Request Format

The API accepts JSON-encoded request bodies for POST requests. Include the following header:

Response Format

All responses are returned as JSON with the following structure: Success Response (200-299)
Error Response (400-599)

Error Codes

The API uses standard HTTP status codes:

Common Errors

Invalid Port

Returned when the :port parameter is missing or not a valid number.

Session ID Required

Returned when a session ID is required but not provided.

Message Text Required

Returned when sending a prompt without message text.

Example Request

API Endpoints

The API is organized into the following resource groups:
  • Sessions - Manage chat sessions
  • Git - Git operations
  • Files - File search and operations
  • Instances - OpenCode instance management