# Public Cloud › Compute › Instances › Console API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Public Cloud product's sections: https://developers.eu.ovhcloud.com/reference/public-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 2 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/console/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/public-cloud/compute/instances/console.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/public-cloud/compute/instances/console.json?format=openapi3

## Operations

- `GET /publicCloud/project/{projectId}/compute/instance/{instanceId}/consoleOutput` — Get console output
- `POST /publicCloud/project/{projectId}/compute/instance/{instanceId}/console` — Create a remote console

## Get console output

`GET /v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/consoleOutput`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/console/#getInstanceConsoleOutput

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:instance/getConsoleOutput`

### Get console output

Returns the serial console output (boot / system log) of the instance as text. Useful for diagnosing boot problems without opening an interactive console session. This is a read-only, synchronous call.

Use the optional `length` query parameter to retrieve only the last N lines (the tail) of the log. Omit it to return all available output.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `instanceId` | path | string (uuid) | yes | Instance ID |
| `length` | query | integer |  | Number of lines to retrieve from the end of the console log. When omitted, returns all available output. |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.instance.ConsoleOutput | successful operation |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `output` | string | read-only | Captured console log of the instance as a single text blob, typically the most recent lines of console output |

```json
{
  "output": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/consoleOutput" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/consoleOutput")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/consoleOutput");

print_r($result);
?>
```

## Create a remote console

`POST /v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/console`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/console/#createInstanceConsole

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:instance/createConsole`

### Create a remote console

Opens a remote console session to the instance and returns the connection details (a `url` and, depending on the protocol, an access `token`) for a client to connect. This is a synchronous call — no desired-state reconciliation — and the returned URL is short-lived, so request a fresh console when it expires.

### Protocol and type
Choose the console via the request body:
* `protocol` — the console transport, for example `VNC`, `SPICE`, `SERIAL`.
* `type` — the concrete console kind for that protocol, for example `NOVNC` for `VNC`, `SERIAL` for `SERIAL`.

The instance must be in a state that supports a console, otherwise the request is rejected with `ResourceInInvalidState`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `instanceId` | path | string (uuid) | yes | Instance ID |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.instance.RemoteConsoleRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `protocol` | publicCloud.instance.RemoteConsoleProtocolEnum | yes | Desired console protocol (see RemoteConsoleProtocolEnum: VNC, SPICE, SERIAL) — one of `SERIAL`, `SPICE`, `VNC` |
| `type` | publicCloud.instance.RemoteConsoleTypeEnum | yes | Desired console display type (see RemoteConsoleTypeEnum: NOVNC, XVPVNC, SPICE_HTML5, SERIAL). It must be consistent with the chosen protocol. — one of `NOVNC`, `SERIAL`, `SPICE_HTML5`, `XVPVNC` |

```json
{
  "protocol": "SERIAL",
  "type": "NOVNC"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.instance.RemoteConsole | successful operation |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `protocol` | publicCloud.instance.RemoteConsoleProtocolEnum | read-only | Protocol of the opened console session (see RemoteConsoleProtocolEnum: VNC, SPICE, SERIAL) — one of `SERIAL`, `SPICE`, `VNC` |
| `type` | publicCloud.instance.RemoteConsoleTypeEnum | read-only | Display type of the opened console session (see RemoteConsoleTypeEnum: NOVNC, XVPVNC, SPICE_HTML5, SERIAL) — one of `NOVNC`, `SERIAL`, `SPICE_HTML5`, `XVPVNC` |
| `url` | string | read-only | Connection URL. URL to connect to the remote console. It is short-lived and grants temporary access to the instance's console. |

```json
{
  "protocol": "SERIAL",
  "type": "NOVNC",
  "url": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/console" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.instance.RemoteConsoleRequest
result = client.post("/v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/console",
	protocol = None, # Desired console protocol (see RemoteConsoleProtocolEnum: VNC, SPICE, SERIAL) (type: publicCloud.instance.RemoteConsoleProtocolEnum)
	type = None, # Desired console display type (see RemoteConsoleTypeEnum: NOVNC, XVPVNC, SPICE_HTML5, SERIAL). It must be consistent with the chosen protocol. (type: publicCloud.instance.RemoteConsoleTypeEnum)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.instance.RemoteConsoleRequest
$result = $ovh->post("/v2/publicCloud/project/{projectId}/compute/instance/{instanceId}/console", array(
	protocol => null, // Desired console protocol (see RemoteConsoleProtocolEnum: VNC, SPICE, SERIAL) (type: publicCloud.instance.RemoteConsoleProtocolEnum)
	type => null, // Desired console display type (see RemoteConsoleTypeEnum: NOVNC, XVPVNC, SPICE_HTML5, SERIAL). It must be consistent with the chosen protocol. (type: publicCloud.instance.RemoteConsoleTypeEnum)
));

print_r($result);
?>
```
