Skip to content

Variables

Variables let you store reusable values and interpolate them into requests using {{name}} syntax.

Setting Variables

Use the set command to store a value.

reqsh
1
reqsh> set token eyJhbGciOiJIUzI1NiJ9
2
reqsh> set base_url https://api.example.com
3
reqsh> set user_id 42

Using Variables

Reference variables anywhere in your request using double curly braces.

reqsh
1
reqsh> GET /users/{{user_id}}
2
.....> Authorization: Bearer {{token}}
3
.....> ::send

Variables work in:

  • Paths: GET /users/{{user_id}}
  • Headers: Authorization: Bearer {{token}}
  • Bodies: {"id": "{{user_id}}"}
  • Query params: param: page={{page}}

Listing Variables

View all stored variables in the current session.

reqsh
1
reqsh> vars
2
token = eyJhbGciOiJIUzI1NiJ9
3
base_url = https://api.example.com
4
user_id = 42

Removing Variables

Remove a variable when it's no longer needed.

reqsh
1
reqsh> unset token

Example Workflow

reqsh
1
reqsh> set token eyJhbGciOiJIUzI1NiJ9
2
reqsh> set api https://api.example.com
3
reqsh> GET {{api}}/users/{{token}}
4
.....> ::send
5
HTTP/1.1200 OK 142ms
6
content-type: application/json
7
 
8
{ ... }