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

# Record an agent-opened run surface

POST https://api.islo.dev/factories/{factory_id}/line-runs/{run_id}/surfaces
Content-Type: application/json

Reference: https://docs.islo.dev/api-reference/factories/post-scoped-factory-line-run-surface

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `factory_id` (string, required)
- `run_id` (string, required)

### Body (application/json)

This endpoint expects a SurfaceOpened.

- `label` (string, required)
- `sandbox` (CanvasSandboxRef, required)
- `stage_name` (string, required)
- `target` (SurfaceOpenedTarget, required)

## Response

### 200

Successful Response

- `created_at` (datetime, required)
- `event_type` ("surface_opened", required)
- `id` (string, required)
- `payload` (SurfaceOpened, required)
- `sequence` (integer, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### CanvasSandboxRef

- `name` (string, required)
- `region` (string, required)

### SurfaceOpenedTarget

- `kind`: `terminal` (TerminalSurfaceTarget)
  - `session` (string, required)
- `kind`: `web` (WebSurfaceTarget)
  - `port` (integer, required)
  - `share_id` (string, required)
  - `url` (string, required)

### SurfaceOpened

- `label` (string, required)
- `sandbox` (CanvasSandboxRef, required)
- `stage_name` (string, required)
- `target` (SurfaceOpenedTarget, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "label": "string",
  "sandbox": {
    "name": "string",
    "region": "string"
  },
  "stage_name": "string",
  "target": {
    "port": 1,
    "share_id": "string",
    "url": "string"
  }
}
```

**Response**

```json
{
  "created_at": "2024-01-15T09:30:00Z",
  "event_type": "string",
  "id": "string",
  "payload": {
    "label": "string",
    "sandbox": {
      "name": "string",
      "region": "string"
    },
    "stage_name": "string",
    "target": {
      "kind": "web",
      "port": 1,
      "share_id": "string",
      "url": "string"
    }
  },
  "sequence": 1
}
```

**SDK Code**

```python
import requests

url = "https://api.islo.dev/factories/factory_id/line-runs/run_id/surfaces"

payload = {
    "label": "string",
    "sandbox": {
        "name": "string",
        "region": "string"
    },
    "stage_name": "string",
    "target": {
        "port": 1,
        "share_id": "string",
        "url": "string"
    }
}
headers = {
    "X-Islo-Api-Version": "X-Islo-Api-Version",
    "Authorization": "Bearer <api_key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.islo.dev/factories/factory_id/line-runs/run_id/surfaces';
const options = {
  method: 'POST',
  headers: {
    'X-Islo-Api-Version': 'X-Islo-Api-Version',
    Authorization: 'Bearer <api_key>',
    'Content-Type': 'application/json'
  },
  body: '{"label":"string","sandbox":{"name":"string","region":"string"},"stage_name":"string","target":{"port":1,"share_id":"string","url":"string"}}'
};

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.islo.dev/factories/factory_id/line-runs/run_id/surfaces"

	payload := strings.NewReader("{\n  \"label\": \"string\",\n  \"sandbox\": {\n    \"name\": \"string\",\n    \"region\": \"string\"\n  },\n  \"stage_name\": \"string\",\n  \"target\": {\n    \"port\": 1,\n    \"share_id\": \"string\",\n    \"url\": \"string\"\n  }\n}")

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

	req.Header.Add("X-Islo-Api-Version", "X-Islo-Api-Version")
	req.Header.Add("Authorization", "Bearer <api_key>")
	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.islo.dev/factories/factory_id/line-runs/run_id/surfaces")

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

request = Net::HTTP::Post.new(url)
request["X-Islo-Api-Version"] = 'X-Islo-Api-Version'
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"label\": \"string\",\n  \"sandbox\": {\n    \"name\": \"string\",\n    \"region\": \"string\"\n  },\n  \"stage_name\": \"string\",\n  \"target\": {\n    \"port\": 1,\n    \"share_id\": \"string\",\n    \"url\": \"string\"\n  }\n}"

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.islo.dev/factories/factory_id/line-runs/run_id/surfaces")
  .header("X-Islo-Api-Version", "X-Islo-Api-Version")
  .header("Authorization", "Bearer <api_key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"label\": \"string\",\n  \"sandbox\": {\n    \"name\": \"string\",\n    \"region\": \"string\"\n  },\n  \"stage_name\": \"string\",\n  \"target\": {\n    \"port\": 1,\n    \"share_id\": \"string\",\n    \"url\": \"string\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.islo.dev/factories/factory_id/line-runs/run_id/surfaces', [
  'body' => '{
  "label": "string",
  "sandbox": {
    "name": "string",
    "region": "string"
  },
  "stage_name": "string",
  "target": {
    "port": 1,
    "share_id": "string",
    "url": "string"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <api_key>',
    'Content-Type' => 'application/json',
    'X-Islo-Api-Version' => 'X-Islo-Api-Version',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.islo.dev/factories/factory_id/line-runs/run_id/surfaces");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Islo-Api-Version", "X-Islo-Api-Version");
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"label\": \"string\",\n  \"sandbox\": {\n    \"name\": \"string\",\n    \"region\": \"string\"\n  },\n  \"stage_name\": \"string\",\n  \"target\": {\n    \"port\": 1,\n    \"share_id\": \"string\",\n    \"url\": \"string\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Islo-Api-Version": "X-Islo-Api-Version",
  "Authorization": "Bearer <api_key>",
  "Content-Type": "application/json"
]
let parameters = [
  "label": "string",
  "sandbox": [
    "name": "string",
    "region": "string"
  ],
  "stage_name": "string",
  "target": [
    "port": 1,
    "share_id": "string",
    "url": "string"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.islo.dev/factories/factory_id/line-runs/run_id/surfaces")! 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()
```