Skip to content

Create or update a saved lens

PUT
/api/v1/lenses
curl --request PUT \
--url http://localhost:11044/api/v1/lenses \
--header 'Content-Type: application/json' \
--header 'X-Embabel-Api-Key: <X-Embabel-Api-Key>' \
--data '{ "name": "example", "params": [ { "default": "example", "label": "example", "name": "example", "required": true, "type": "STRING" } ], "persona": "example", "schedule": "example", "script": "example" }'
username
string

Optional, and never needed: the call always acts as the signed-in principal. Naming the principal changes nothing; naming anyone else is refused with 403.

Saves a CypherScript lens for the caller. name and script are required and must be non-blank (400 otherwise); the lens id is the slug of name (lowercased, runs of other characters turned to -), so saving under an existing name replaces that lens. params declares the parameters callers may supply as args; persona and schedule are stored with the definition

Media typeapplication/json

A lens to save for the caller; sent to PUT /lenses, which answers the saved lens’s id and name

object
name
required

Display name, required and non-blank. The lens id is derived from it (lowercased, each run of other characters turned into -), so saving under a name with the same id replaces that lens.

string
params
required

Parameters the lens accepts when it is opened, supplied then in the args map; empty for none

Array<object>

A parameter a lens declares: the declaration only, so a UI can render a control for it. The value itself is passed in the args map when the lens is opened, keyed by name

object
default

Value used when the opener supplies none; null when there is no default

label
required

Text a UI shows for the control. Defaults to name when absent

string
name
required

Key the value is passed under in the args map when the lens is opened

string
required
required

Whether opening the lens fails when neither the opener nor default gives a value. Defaults to false when absent

boolean
type
required

Advisory type that picks the UI control and drives light validation. Defaults to STRING when absent

string
Allowed values: STRING INT DATE DURATION BOOLEAN
persona

Persona slug stored with the lens and returned with its definition; null for none

string
schedule

Cron expression stored with the lens; nothing schedules from it yet, so it has no effect

string
script
required

CypherScript program, required and non-blank: code-mode JavaScript that queries through gateway.kg.query and other gateway calls and declares its focus with gateway.lens.focus

string

Blank name or script

Media typeapplication/json

A refusal from the lens authoring surface. Carries only the reason

object
error
required

Why the request was refused, written to be shown. Names the lens or view where the refusal is about one

string

Example generated

{
"error": "example"
}

No authenticated principal

Media typeapplication/json

A refusal carrying only a human-readable reason.

object
error
required

What went wrong, in the terms the caller can act on.

string

Example generated

{
"error": "example"
}

username names someone other than the signed-in principal

Media typeapplication/json

A refusal carrying only a human-readable reason.

object
error
required

What went wrong, in the terms the caller can act on.

string

Example generated

{
"error": "example"
}