Postchi lets you attach JavaScript scripts to your requests and run standalone scripts on demand. Scripts run in a sandboxed async function — you don’t needDocumentation Index
Fetch the complete documentation index at: https://docs.getpostchi.com/llms.txt
Use this file to discover all available pages before exploring further.
import statements or TypeScript. Postchi injects the context you need directly.
There are three types of scripts:
Before scripts
Run before a request is sent. Mutate the request’s method, URL, headers, or body.
After scripts
Run after a response is received. Extract values into environment variables or secrets.
Actions
Standalone scripts you run on demand. Execute requests, set variables, and chain workflows.
Script types
| Type | File name | When it runs |
|---|---|---|
| Before script | <request-name>.before.js | Before the request is sent |
| Folder before script | before.js (in any folder) | Before every request in that folder and subfolders |
| After script | <request-name>.after.js | After the response is received |
| Folder after script | after.js (in any folder) | After every request in that folder and subfolders |
| Action | <name>.action.js (in actions/) | On demand, from the actions panel |
Execution order
When you send a request, Postchi runs scripts in this order:Folder before script
If a
before.js exists in an ancestor folder, it runs first and can modify the request.Request before script
If a
<request-name>.before.js exists next to the request file, it runs next with the (already-modified) request.Both the folder-level and request-level after scripts share the same mutation state — all
setEnvironmentVariable and setSecret calls from both scripts are applied together.How scripts run
Scripts are plain JavaScript wrapped in an async function. Postchi injects variables into the function scope, so you can use them directly without declaring them:await anywhere since they run inside an async context.