Skip to main content
GET
/
preview
/
v2
/
instances
/
{id}
/
logs
Get instance logs
curl --request GET \
  --url https://api.sfcompute.com/preview/v2/instances/{id}/logs \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.sfcompute.com/preview/v2/instances/{id}/logs"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.sfcompute.com/preview/v2/instances/{id}/logs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sfcompute.com/preview/v2/instances/{id}/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.sfcompute.com/preview/v2/instances/{id}/logs"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.sfcompute.com/preview/v2/instances/{id}/logs")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.sfcompute.com/preview/v2/instances/{id}/logs")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "object": "list",
  "data": [
    {
      "timestamp_realtime": 1738972800,
      "timestamp_monotonic_secs": 123,
      "timestamp_monotonic_nanos": 1,
      "seqnum": 1,
      "data": "SGVsbG8gV29ybGQK"
    }
  ]
}
{
"error": {
"type": "authentication_error",
"message": "<string>"
}
}
{
"error": {
"type": "forbidden",
"message": "<string>"
}
}
{
"error": {
"type": "not_found",
"message": "<string>"
}
}
{
"error": {
"type": "unprocessable_entity",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}
{
"error": {
"type": "api_error",
"message": "<string>"
}
}

Authorizations

Authorization
string
header
required

Create an API token using sf tokens create or at https://sfcompute.com/account/api-keys.

Path Parameters

id
string
required

A resource path like 'sfc:instance:acme:prod:my-instance' or an ID. Resource paths are human-readable but not stable - they change when resources are renamed or moved. IDs are stable and permanent.

Pattern: (inst_[0-9a-zA-Z_-]{1,21}|vm_[0-9a-zA-Z_-]{1,21})|(sfc:instance:[a-zA-Z0-9._-]+(:[a-zA-Z0-9._-]+){2,2})
Example:

"inst_k3R-nX9vLm7Qp2Yw5Jd8F"

Query Parameters

seqnum_before
integer<u-int64>

Return logs with seqnum less than or equal to this value.

Required range: x >= 0
seqnum_after
integer<u-int64>

Return logs with seqnum greater than or equal to this value.

Required range: x >= 0
realtime_timestamp_before
integer<int64>

Due to clock synchronization, some earlier log messages may have a realtime timestamp after this value. Unix timestamp.

Example:

1738972800

realtime_timestamp_after
integer<int64>

Due to clock synchronization, some later log messages may have a realtime timestamp before this value. Unix timestamp.

Example:

1738972800

sort_by
enum<string>
Available options:
seqnum,
-seqnum
limit
integer<u-int64>
default:100
Required range: 1 <= x <= 2500

Response

Log chunks.

object
string
default:list
required
read-only
Allowed value: "list"
data
object[]
required