Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getpostchi.com/llms.txt

Use this file to discover all available pages before exploring further.

Add a body to a request by placing @body on its own line. Everything after @body is sent as the request body.
POST https://api.example.com/resource
Content-Type: application/json
@body
{
  "key": "value"
}
Postchi determines how to encode the body from the Content-Type header when present, or by inspecting the body text when it isn’t.

JSON body

Postchi treats the body as JSON when:
  • Content-Type: application/json is set, or
  • the body starts with { or [
POST https://api.example.com/users
Content-Type: application/json
@body
{
  "name": "<username>",
  "role": "admin"
}
Variables inside JSON bodies must be written as quoted string values. Postchi replaces "<username>" with the resolved value and keeps the surrounding quotes so the JSON stays valid.

Form body (URL-encoded)

Postchi treats the body as URL-encoded form data when:
  • Content-Type: application/x-www-form-urlencoded is set, or
  • the body uses key=value pairs
POST https://api.example.com/login
Content-Type: application/x-www-form-urlencoded
@body
username=<username>
password=<password>
Each line is a separate form field. Variables work as values here too.

Multipart form body (file uploads)

Use Content-Type: multipart/form-data together with readFile() to attach binary files:
POST https://api.example.com/upload
Content-Type: multipart/form-data
@body
file=readFile(/path/to/document.pdf)
name=<doc_name>
readFile(path) reads the file from disk and attaches it as a binary form part. If you don’t set Content-Type explicitly, Postchi automatically switches to multipart/form-data when it encounters a readFile() call in the body.
readFile() is only valid inside a form body. To inline a text file as the entire body, use readText() instead.

Plain text and other content types

Any Content-Type that isn’t JSON or form-encoded is sent as a plain text body:
POST https://api.example.com/events
Content-Type: text/plain
@body
This is a plain text body.

Loading the body from a file

For large bodies, keep the content in a separate file and use readText(path) to load it at run time:
POST https://api.example.com/batch
Content-Type: application/json
@body
readText(/path/to/large-payload.json)

Variables in bodies

Variables (<variable_name>) work in all body types:
POST https://api.example.com/orders
Content-Type: application/json
@body
{
  "user_id": "<user_id>",
  "product": "<product_id>"
}
Values are substituted from the active environment when the request runs. If a variable is missing, Postchi shows an error before sending.