Skip to content

Try a function of a library before publishing it

POST
/orgs/{org}/libraries/try
curl --request POST \
--url https://api.sloose.com/orgs/org_9f3c/libraries/try \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "manifest": { "namespace": "example", "version": "example", "scope": "global", "description": "example", "functions": [ { "name": "example", "description": "example", "params": [ { "name": "example", "type": "example", "optional": true, "description": "example" } ], "returns": "example", "examples": [ { "call": "example", "result": "example" } ], "tags": [ "example" ] } ] }, "source": "example", "function": "example", "args": [ "example" ] }'

Compiles the library as sent — published or not — and calls one of its functions with the arguments given, in the sandbox formulas run in: no network, no storage. Nothing is written, no credits are spent, and it is open on every plan. The answer is the value as a formula would see it, at most 2000 characters (truncated says when it was cut), or the error it threw.

org
required

The organisation id the session was issued for. A token for one organisation can never read another.

string
Example
org_9f3c

The organisation id the session was issued for. A token for one organisation can never read another.

Media typeapplication/json
object
manifest
required
object
namespace
required
string
/^[a-z][a-z0-9_]*$/
version
required
string
/^\d+\.\d+\.\d+$/
scope
required
string
Allowed values: global org
description
string
functions
required
Array<object>
object
name
required
string
/^[A-Za-z_$][\w$]*$/
description
required
string
params
required
Array<object>
object
name
required
string
type
required
string
optional
boolean
description
string
returns
required
string
examples
Array<object>
object
call
required
string
result
string
tags
Array<string>
source
required

The library’s module, as the SDK writes it: import { defineLibrary } from '@sloose/sdk/library'; import manifest from '../manifest.json'; export default defineLibrary({ manifest, functions: { … } }); — those two imports and nothing else, one default export, JavaScript (the SDK strips TypeScript before it sends). At most 256 KB.

string
>= 1 characters <= 262144 characters
function
required

The function to call, as its manifest names it.

string
>= 1 characters <= 200 characters
args
required

The arguments, as JSON values, in order.

Array
<= 10 items

What the call answered, or the error it threw.

Media typeapplication/json
object
value
required
string | null
truncated
required
boolean
error
required
string | null
Examplegenerated
{
"value": "example",
"truncated": true,
"error": "example"
}

The request — its body or its query — did not match the schema. issues carries the Zod issue list.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

No bearer, or one that no longer resolves: a session that is unknown or expired (code: AUTH_REQUIRED), or an API token that was revoked or expired (TOKEN_REVOKED, TOKEN_EXPIRED), whose organisation is gone (ORG_NOT_FOUND) or whose member or user row is (MEMBERSHIP_GONE).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

The bearer’s role is too low (code: ROLE_REQUIRED), or it was issued for a different organisation; the organisation has been closed (code: ORG_CLOSED, either kind of bearer); the person is banned (code: BANNED, a session); or it is a session that is signed in but in no organisation (code: NO_ORG): one that never joined one, or whose person was taken out of the one it was in, or left it. Signing in again changes nothing for NO_ORG; choosing or making an organisation does.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

The library does not compile or load, or the function is not one its manifest declares.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed values: LIBRARY_DOES_NOT_LOAD UNKNOWN_FUNCTION
key
additional properties
Example
{
"code": "LIBRARY_DOES_NOT_LOAD"
}

The sandbox did not answer (code: SANDBOX_UNAVAILABLE). Or the restore switch is on (code: MAINTENANCE): every route but /health and /robots.txt is refused before anything is read, with Retry-After (the operator’s ADMIN_TOKEN alone is let through to POST /staff/people/{id}/delete, and to nothing else).

Media typeapplication/json
One of:

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Example
{
"code": "MAINTENANCE"
}
Retry-After
integer

Seconds until asking again is worth it (300 while the switch is on).

Report a problem with this page

sloose.com