Skip to content

9Login API: scripts#

Read, save and delete the scripts of the account's script library. Scripts are written with macro functions.

GET /v1/scripts#

The script library of the account, without the code. Answers from the library as this computer has it, sorted by title. With refresh true a failed fetch still answers, with refreshed false and refreshError saying why. profiles counts the profiles on this computer that use each script. Times are Unix milliseconds.

MCP tool: list_scripts. Access: read only.

Field Type Required Description
search string no Only scripts whose title contains this, case-insensitive.
refresh boolean no Fetch the account's library first, to see scripts saved on another device. Do not poll with it: the server limits how often an account reads its library, for this app too. Default false.
Request
curl -H "Authorization: Bearer YOUR_API_KEY" "http://127.0.0.1:37286/v1/scripts?search=warm&refresh=true"
Response
{
  "ok": true,
  "data": {
    "total": 1,
    "refreshed": true,
    "refreshError": null,
    "items": [
      {
        "id": "0A1B2C3D4E5F6G7H",
        "title": "Warm up",
        "bytes": 86,
        "version": 3,
        "hash": "807586a559d4f898e49ff4bebf90cf0ddb34e699",
        "createdAt": 1760000000000,
        "updatedAt": 1760003600000,
        "profiles": 2
      }
    ]
  }
}

GET /v1/scripts/{id}#

One script with its code, and the profiles that use it. profiles lists the ids of the profiles on this computer that use the script. Times are Unix milliseconds.

MCP tool: get_script. Access: read only.

Field Type Required Description
refresh boolean no Fetch the account's library first, to see scripts saved on another device. Do not poll with it: the server limits how often an account reads its library, for this app too. Default false.
Request
curl -H "Authorization: Bearer YOUR_API_KEY" "http://127.0.0.1:37286/v1/scripts/0A1B2C3D4E5F6G7H"
Response
{
  "ok": true,
  "data": {
    "id": "0A1B2C3D4E5F6G7H",
    "title": "Warm up",
    "body": "await Navigate(\"https://example.com\");\nawait WaitForLoading();\nawait Delay(800, 1600);",
    "bytes": 86,
    "version": 3,
    "hash": "807586a559d4f898e49ff4bebf90cf0ddb34e699",
    "createdAt": 1760000000000,
    "updatedAt": 1760003600000,
    "profiles": [
      "a1b2c3",
      "d4e5f6"
    ]
  }
}

POST /v1/scripts/save#

Create a script or change one, as Save in the script library does. Leave out id to create a script; the answer carries its new id. To change a script, pass its id with title, body or both: a field left out keeps its value. Only scripts this computer knows can be changed; list with refresh true to fetch ones saved on another device. When the script was changed elsewhere since baseVersion the answer is conflict, with the account's version in details.server: get it again and retry, or pass overwrite true. When it was deleted elsewhere the answer is notFound with details.deletedElsewhere true: save again without id to keep it as a new script.

MCP tool: save_script. Access: needs "Allow changes", needs the sub-user permission "manageScript", needs a plan with scripts.

Field Type Required Description
id string no Script id: 16 characters, digits and capital letters except I, L, O, U. Leave out to create a script. With baseVersion 0 it creates the script under this id, so a retry after a lost answer does not make a second copy.
baseVersion integer no The version this change starts from, as list, get or save returned it. 0 creates. Left out on a change, the version on this computer is used. Min 0, max 4294967295.
title string no Required to create. At most 200 characters; spaces at both ends are dropped and control characters are refused.
body string no The macro code, at most 512 KB as UTF-8. Empty when left out on create.
overwrite boolean no On a conflict, save over the account's version anyway (Keep mine in the app). A script deleted elsewhere is not brought back this way. Default false.
Request
curl -X POST "http://127.0.0.1:37286/v1/scripts/save" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Warm up",
  "body": "await Navigate(\"https://example.com\");\nawait WaitForLoading();\nawait Delay(800, 1600);"
}'
Response
{
  "ok": true,
  "data": {
    "id": "0A1B2C3D4E5F6G7H",
    "title": "Warm up",
    "bytes": 86,
    "version": 1,
    "hash": "807586a559d4f898e49ff4bebf90cf0ddb34e699",
    "createdAt": 1760000000000,
    "updatedAt": 1760000000000,
    "created": true,
    "overwrote": false
  }
}

POST /v1/scripts/delete#

Delete scripts from the account, then from the profiles that use them. Needs "Allow deleting" on the API & MCP screen. There is no undo, and a change saved on another device a moment ago goes too. An id this computer does not know is listed in failed as notFound; list with refresh true first to see scripts saved on another device. Profiles on this computer that use a deleted script are saved without it: profiles.updated lists them, profiles.failed the ones that could not be saved.

MCP tool: delete_scripts. Access: needs "Allow deleting", needs the sub-user permission "manageScript".

Field Type Required Description
ids string[] yes Script ids, at most 200.
Request
curl -X POST "http://127.0.0.1:37286/v1/scripts/delete" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": [
    "0A1B2C3D4E5F6G7H"
  ]
}'
Response
{
  "ok": true,
  "data": {
    "deleted": [
      "0A1B2C3D4E5F6G7H"
    ],
    "failed": [],
    "profiles": {
      "updated": [
        "a1b2c3",
        "d4e5f6"
      ],
      "failed": [],
      "error": null
    }
  }
}