HTTP Mode
Build, test, and manage API requests with t-req's HTTP mode.
t-req includes a built-in HTTP client for building, testing, and managing API requests. Toggle between the AI assistant and HTTP mode with a single keybind.
Accessing HTTP Mode
Press ctrl+m to toggle between Agent mode (AI assistant) and HTTP mode (API client).
When you enter HTTP mode, you’ll see:
- URL bar at the top for entering request URLs
- Request panel (left) with tabs for params, headers, body, auth, docs, and scripts
- Response panel (right) showing response body, headers, and status
- Footer displaying workspace name and active environment
Making Requests
URL and Method
Enter your request URL in the URL bar at the top. The URL supports environment variable substitution using {{VARIABLE_NAME}} syntax.
Select the HTTP method using ctrl+shift+m or click the method dropdown:
- GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Query Parameters
Use the Params tab to add query parameters as key-value pairs. Parameters are automatically synced with the URL - editing either updates the other.
| Column | Description |
|---|---|
| Key | Parameter name |
| Value | Parameter value (supports {{variables}}) |
| Enabled | Toggle to include/exclude parameter |
Headers
Use the Headers tab to add custom HTTP headers. Common headers like Content-Type are set automatically based on body type.
Request Body
Use the Body tab to set the request body. Select from:
JSON
{ "name": "{{USER_NAME}}", "email": "user@example.com"}Form (URL-encoded)
Key-value pairs sent as application/x-www-form-urlencoded.
Raw Plain text content with any content type.
Documentation
Use the Docs tab to add markdown documentation to your request. This is useful for describing what the request does, expected responses, or usage notes.
- Press
Enterto start editing - Press
Escto exit editing mode - Use
<leader>eto open in external editor
Scripts
Use the Scripts tab to add pre/post hooks and tests. See Scripts for details.
Sending Requests
Press ctrl+shift+return to send the request. If the request has tests, you’ll be prompted to choose:
- Send - Execute request without tests
- Send with Tests - Execute request and run tests
Authentication
Configure request authentication in the Auth tab.
Bearer Token
Adds Authorization: Bearer <token> header.
Type: Bearer TokenToken: {{API_TOKEN}}Basic Auth
Adds Authorization: Basic <base64> header with encoded credentials.
Type: Basic AuthUsername: {{USERNAME}}Password: {{PASSWORD}}API Key
Adds a custom header with your API key.
Type: API KeyHeader Name: X-API-KeyValue: {{API_KEY}}Response Viewer
The response panel displays:
- Status - HTTP status code and text (e.g.,
200 OK) - Time - Request duration in milliseconds
- Body - Response body with syntax highlighting for JSON
- Headers - Response headers
Toggle the response panel visibility with ctrl+\.
History
t-req automatically tracks request history. Access previous requests through the command palette (ctrl+p) and search for “history”.
Configure history retention in your treq.json:
{ "requests": { "history_retention": "forever" }}Options: "forever", "30days", "7days", "session"
See Requests Configuration for more options.
Cookies
Auto-Capture
By default, cookies from responses are automatically captured and stored in a cookie jar. They’re sent with subsequent requests to matching domains.
Cookie Settings
Configure per-request cookie behavior:
- Auto Capture - Capture cookies from response
- Send Cookies - Send cookies from jar with request
Manual Cookies
Add manual cookies that are sent with the request regardless of the cookie jar.
Cookie Manager
Access the cookie manager through the command palette to view, edit, or delete stored cookies.
Keybinds
| Keybind | Action |
|---|---|
ctrl+m | Toggle between Agent/HTTP mode |
ctrl+shift+return | Send request |
ctrl+n | New collection or request |
ctrl+s | Save request |
ctrl+l | Focus URL bar |
ctrl+\ | Toggle response panel |
ctrl+shift+e | Manage environments |
ctrl+shift+m | Select HTTP method |
<leader>t | Collection tree view |
ctrl+p | Command palette |
Related
- Collections - Organize requests into collections
- Environments - Manage variables across environments
- Scripts - Add hooks and tests to requests
- Requests Configuration - Configure timeout, SSL, cookies