# Scripts API The Scripts API provides a persistent store for reusable scripts. Scripts are named and versioned within a mind, and can be fetched as plain text — perfect for `curl | bash` patterns. ## Endpoints ### POST /script Store or update a script. ```bash curl -X POST https://synapse.schaefer.zone/script \ -H "Authorization: Bearer YOUR_MIND_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "deploy-synapse", "content": "#!/bin/bash\nset -euo pipefail\ngit pull\nnpm ci\nnpm run build\ndocker compose up -d", "description": "Deploy Synapse to production", "language": "bash" }' ``` ### GET /script/:name Fetch script content as `text/plain`. Perfect for piping to bash. ```bash curl -H "Authorization: Bearer YOUR_MIND_KEY" \ https://synapse.schaefer.zone/script/deploy-synapse | bash ``` ### GET /script/:name/info Get script metadata without the content. ```bash curl -H "Authorization: Bearer YOUR_MIND_KEY" \ https://synapse.schaefer.zone/script/deploy-synapse/info ``` Response: ```json { "name": "deploy-synapse", "description": "Deploy Synapse to production", "language": "bash", "size_bytes": 142, "created_at": "2026-06-27T...", "updated_at": "2026-06-27T..." } ``` ### GET /scripts List all scripts in the current mind. ```bash curl -H "Authorization: Bearer YOUR_MIND_KEY" \ https://synapse.schaefer.zone/scripts ``` ### DELETE /script/:name Delete a script. ```bash curl -X DELETE -H "Authorization: Bearer YOUR_MIND_KEY" \ https://synapse.schaefer.zone/script/deploy-synapse ``` ## Common Use Cases ### Deployment scripts Store standard deployment procedures so the LLM can run them without re-deriving the steps each time: ```bash # LLM stores this once curl -X POST .../script -d '{ "name": "deploy-vps1", "content": "#!/bin/bash\nssh vps1 \"cd /opt/synapse && git pull && docker compose up -d --build\"", "language": "bash" }' # Later sessions just run it curl -H "Authorization: ..." .../script/deploy-vps1 | bash ``` ### Troubleshooting snippets Store diagnostic commands for common issues: ```bash curl -X POST .../script -d '{ "name": "check-docker", "content": "#!/bin/bash\ndocker ps\ndocker stats --no-stream\ndocker system df", "description": "Quick Docker health check", "language": "bash" }' ``` ### Configuration generators Store scripts that generate configs: ```bash curl -X POST .../script -d '{ "name": "gen-nginx-conf", "content": "#!/usr/bin/env python3\nimport sys\n# ... generate nginx config from template ...", "language": "python" }' ``` ## Next Steps - [Variables API](/docs/api/variables) - [Cron & Scheduler](/docs/api/cron)