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 org id the session was issued for. A token for one org can never read another.

string
Example
org_9f3c

The org id the session was issued for. A token for one org 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 is expired, revoked or no longer resolves to a member.

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, or it was issued for a different org.

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).

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"
}

Report a problem with this page