Try a function of a library before publishing it
const url = 'https://api.sloose.com/orgs/org_9f3c/libraries/try';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"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"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The org id the session was issued for. A token for one org can never read another.
Example
org_9f3cThe org id the session was issued for. A token for one org can never read another.
Request Bodyrequired
Section titled “Request Bodyrequired”object
object
object
object
object
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.
The function to call, as its manifest names it.
The arguments, as JSON values, in order.
Responses
Section titled “Responses”What the call answered, or the error it threw.
object
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.
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}No bearer, or one that is expired, revoked or no longer resolves to a member.
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}The bearer’s role is too low, or it was issued for a different org.
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}The library does not compile or load, or the function is not one its manifest declares.
object
Example
{ "code": "LIBRARY_DOES_NOT_LOAD"}The sandbox did not answer (code: SANDBOX_UNAVAILABLE).
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}