Create or update a saved lens
const url = 'http://localhost:11044/api/v1/lenses';const options = { method: 'PUT', headers: {'X-Embabel-Api-Key': '<X-Embabel-Api-Key>', 'Content-Type': 'application/json'}, body: '{"name":"example","params":[{"default":"example","label":"example","name":"example","required":true,"type":"STRING"}],"persona":"example","schedule":"example","script":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”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.
Request Bodyrequired
Section titled “Request Bodyrequired”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
A lens to save for the caller; sent to PUT /lenses, which answers the saved lens’s id and name
object
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.
Parameters the lens accepts when it is opened, supplied then in the args map; empty for none
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
Value used when the opener supplies none; null when there is no default
Text a UI shows for the control. Defaults to name when absent
Key the value is passed under in the args map when the lens is opened
Whether opening the lens fails when neither the opener nor default gives a value. Defaults to false when absent
Advisory type that picks the UI control and drives light validation. Defaults to STRING when absent
Persona slug stored with the lens and returned with its definition; null for none
Cron expression stored with the lens; nothing schedules from it yet, so it has no effect
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
Responses
Section titled “Responses”Blank name or script
A refusal from the lens authoring surface. Carries only the reason
object
Why the request was refused, written to be shown. Names the lens or view where the refusal is about one
Example generated
{ "error": "example"}No authenticated principal
A refusal carrying only a human-readable reason.
object
What went wrong, in the terms the caller can act on.
Example generated
{ "error": "example"}username names someone other than the signed-in principal
A refusal carrying only a human-readable reason.
object
What went wrong, in the terms the caller can act on.
Example generated
{ "error": "example"}
