opendunes
Management
Copy page ▾

Sandbox files

GET /v1/containers/{id}/files lists the files the shell or bash helperHelperA tool run for you when a model reaches for it mid-answer: a web search, a page read, a sandbox. Named opendunes:‹name›.More on Helpers → left in a sandbox; two more routes read one file's details and its bytes.

Request

Send them with an API keyAPI keyThe key you create and send with every request that calls a model.More on API keys →. A sandbox's id is the name you gave it in the helper, or the container_id the helper's result carried; a sandbox of another account answers 404. The Helpers guide sets the shell and bash helpers to work.

RouteDoes
GET /v1/containers/{id}/fileslists the sandbox's files, in path order
GET /v1/containers/{id}/files/{file}answers one file's details
GET /v1/containers/{id}/files/{file}/contentanswers the file's bytes

List

GET /v1/containers/{id}/files takes the sandbox's id in the address, and its other fields after ?.

FieldNeededYou send
idyesthe sandbox's id
limitnohow many files one page holds, 1 to 100; absent, 100
afternothe last_id the previous page answered, for the next page

Souk Bot's shell helper wrote a sales report in the sandbox Yacine named souk-reports. The samples list its files; put your sandbox's id in place of that name.

import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
SANDBOX = "souk-reports"
ADDRESS = f"https://opendunes.com/v1/containers/{SANDBOX}/files"

request = urllib.request.Request(
    ADDRESS,
    headers={"Authorization": "Bearer " + API_KEY},
)
with urllib.request.urlopen(request) as response:
    page = json.load(response)

for file in page["data"]:
    print(file["id"], file["path"], file["bytes"])

One file, its bytes

GET /v1/containers/{id}/files/{file} and GET /v1/containers/{id}/files/{file}/content take the sandbox's id and the file's id in the address, and nothing else.

FieldNeededYou send
fileyesthe file's id, from the list: cfile_ and its path in base64url

Response

GET /v1/containers/{id}/files answers 200 OK with a page of files.

FieldHolds
objectlist
datathe files on this page, each the object below
first_idthe id of the first file on this page, or null
last_idwhat to send as after for the next page; it can name a place past this page's last file. null only when the page is empty and none follows
has_moretrue when another page follows

GET /v1/containers/{id}/files/{file} answers 200 OK with one file.

FieldHolds
idthe file's id
objectcontainer.file
container_idthe sandbox, under your name for it
pathwhere the file sits in the sandbox
bytesits size, in bytes
created_atwhen the file was last copied out of the sandbox, in Unix seconds
sourceassistant: the helper wrote it

GET /v1/containers/{id}/files/{file}/content answers the bytes themselves, in the file's own type, or application/octet-stream when it has none.

A page of one file, illustrative:

JSON
{
  "object": "list",
  "data": [
    {
      "id": "cfile_b3V0L3ZlbnRlcy5jc3Y",
      "object": "container.file",
      "container_id": "souk-reports",
      "path": "out/ventes.csv",
      "bytes": 2048,
      "created_at": 1790668800,
      "source": "assistant"
    }
  ],
  "first_id": "cfile_b3V0L3ZlbnRlcy5jc3Y",
  "last_id": "cfile_b3V0L3ZlbnRlcy5jc3Y",
  "has_more": false
}

What it cost

Free. Listing, reading and downloading a sandbox's files are never charged. The time the sandbox ran is charged on the request whose helper ran it.

Errors

error.code carries the status, and error.message says why.

StatusWhen
400limit is not a whole number from 1 to 100, or after is over 256 characters
401the key is missing, wrong, disabled or expired
403the key is kept to other addresses
404no sandbox of yours has that id, or it holds no file with that id
429too many reads at once; Retry-After says when to ask again
500an unexpected error; the message is generic
503the sandboxes cannot be read right now; ask again shortly
504the sandbox did not answer in time

Last modified on