Skip to content

Create or replace a helper library

PUT
/orgs/{org}/libraries/{namespace}
curl --request PUT \
--url https://api.sloose.com/orgs/org_9f3c/libraries/acme \
--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" }'

The manifest is validated against the helper manifest contract, and its namespace must match the path. Only org-scoped libraries can be written here — a global library belongs to the product, not to an org.

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.

namespace
required

The library namespace, as it appears in expressions.

string
Example
acme

The library namespace, as it appears in expressions.

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 ESM source, at most 256 KB.

string
>= 1 characters <= 262144 characters

The stored library.

Media typeapplication/json
object
library
required
object
namespace
required
string
version
required
string
scope
required
string
Allowed values: global org
manifest
required
object
key
additional properties
source

Only when asked for with ?source=1.

string
updatedAt
required
string
Example
{
"library": {
"scope": "global"
}
}

The request body 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 manifest’s namespace does not match the path, or it declares global scope.

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