Skip to main content

Working with Requests

Requests are the core of Mercury. Learn how to create, edit, and manage your HTTP requests using the simple JSON file format.

What is a Request?​

In Mercury, every request is a plain text .json file. This means:

  • Version control friendly (Git works perfectly)
  • Editable in any text editor
  • Portable across any system
  • No proprietary formats

Creating Requests​

From the UI​

  1. Right-click in the sidebar → New Request
  2. Or press ⌘+N (Mac) / Ctrl+N (Windows/Linux)
  3. Enter a name (e.g., get-users)

Mercury creates a .json file in your workspace.

From Your Editor​

Create any file with .json extension:

GET https://api.example.com/users

Mercury detects it automatically thanks to live file watching.

The .json File Format​

Every .json file follows this structure:

METHOD URL
Header-Name: Header-Value
Header-Name: Header-Value

Body content here

Example: Simple GET Request​

GET https://api.example.com/users

Example: POST with Headers and Body​

POST https://api.example.com/users
Content-Type: application/json
Authorization: Bearer {{token}}

{
"name": "John Doe",
"email": "john@example.com"
}

Request editor - Replace with: Screenshot showing a POST request with headers and JSON body

HTTP Methods​

Mercury supports all standard HTTP methods:

MethodDescriptionColor
GETRetrieve dataBlue
POSTCreate resourceGreen
PUTReplace resourceOrange
PATCHPartial updatePurple
DELETERemove resourceRed
HEADGet headers onlyCyan
OPTIONSGet allowed methodsBrown
CONNECTTunnel connectionTeal
TRACEDebug request pathGray

Click the method badge in the URL bar to change methods.

Adding Headers​

Headers go on lines between the URL and the body:

GET https://api.example.com/data
Accept: application/json
X-API-Version: 2
Cache-Control: no-cache

Common Headers​

HeaderPurpose
AuthorizationAuth credentials (Basic, Bearer)
Content-TypeBody format (application/json)
AcceptExpected response format
User-AgentClient identification

Request Body​

Add a blank line after headers, then your body content:

JSON Body​

POST https://api.example.com/users
Content-Type: application/json

{
"name": "Mercury",
"type": "API Client",
"features": ["fast", "minimal", "free"]
}

Form Data (URL-encoded)​

POST https://api.example.com/login
Content-Type: application/x-www-form-urlencoded

username=john&password=secret

Plain Text​

POST https://api.example.com/webhook
Content-Type: text/plain

This is a plain text message

Using Variables​

Reference environment variables with {{variable}} syntax:

GET {{BASE_URL}}/users/{{USER_ID}}
Authorization: Bearer {{API_TOKEN}}

Mercury shows indicators for each variable:

  • Green — Variable is defined in your .env file
  • Red — Variable is undefined (will be sent as literal text)

See Environment Variables for more details.

Query Parameters​

Mercury provides a dedicated Params tab for managing URL query parameters:

GET https://api.example.com/search?q=mercury&page=1&limit=10

Instead of editing the URL directly, use the Params tab to:

  • Add key-value pairs — Click in the empty row and type
  • Toggle parameters on/off — Checkbox enables/disables without deleting
  • See all parameters at a glance — Clean table view
  • Edit values easily — No more navigating the URL string

Two-Way Sync​

The Params table stays in sync with the URL bar:

  • Edit the URL → Params table updates automatically
  • Edit in Params tab → URL updates automatically
  • Paste a cURL command → Params are parsed and shown

Variables in Parameters​

Use {{variable}} syntax in parameter values:

KeyValue
api_key{{API_KEY}}
page1

Variable indicators show which variables are defined in your environment.

Toggle vs Delete

Use the checkbox to temporarily disable a parameter without losing it. This is useful for testing different API configurations.

Sending Requests​

Keyboard: Press ⌘+Enter (Mac) or Ctrl+Enter (Windows/Linux)

Mouse: Click the Send button in the URL bar

The button animates while the request is in progress.

Cancelling a Request​

Click the Stop button (which replaces Send) or press Esc to cancel a running request. The request is immediately stopped, and the UI is unblocked.

Sending request - Replace with: Screenshot showing animated send/stop button

Defaults​

Mercury uses sensible defaults so you can focus on your API, not configuration:

SettingDefaultBehavior
Timeout30 secondsRequests fail after 30s of no response
RedirectsFollowedHTTP redirects followed automatically (up to 10)
URL Validation

Mercury validates URLs before sending:

  • Empty URLs show an error
  • Unresolved {{variables}} show a warning

Request Actions​

Right-click on a request in the sidebar for actions:

ActionDescription
DuplicateCreate a copy of the request
RenameChange the filename
DeleteMove to trash
Copy as cURLCopy as cURL command