HTTP Requests
HTTP Methods
Section titled “HTTP Methods”By default, orb uses GET. Use -X or --request to specify a different method:
orb -X POST https://api.example.com/usersorb -X PUT https://api.example.com/users/1orb -X DELETE https://api.example.com/users/1orb -X PATCH https://api.example.com/users/1Request Headers
Section titled “Request Headers”Add custom headers with -H or --header:
orb https://api.example.com \ -H "Authorization: Bearer token123" \ -H "Accept: application/json" \ -H "X-Custom-Header: value"Default Headers
Section titled “Default Headers”Orb automatically sets these headers:
Host: Derived from the URLUser-Agent:orb/<version>Accept:*/*
Custom headers override defaults with the same name.
Request Body
Section titled “Request Body”URL-Encoded Data (-d)
Section titled “URL-Encoded Data (-d)”Use -d or --data to send URL-encoded form data:
orb https://api.example.com/login \ -X POST \ -d "username=alice&password=secret"This automatically sets Content-Type: application/x-www-form-urlencoded.
Send File Contents
Section titled “Send File Contents”Prefix with @ to read data from a file:
orb https://api.example.com/data \ -X POST \ -d @payload.txtJSON Data (--json)
Section titled “JSON Data (--json)”The --json flag is a convenient way to send JSON:
orb https://api.example.com/users \ -X POST \ --json '{"name": "Alice", "email": "alice@example.com"}'This automatically:
- Sets
Content-Type: application/json - Sends the data as the request body
Multipart Form Data (-F)
Section titled “Multipart Form Data (-F)”Use -F or --form for multipart form uploads:
# Upload a fileorb https://api.example.com/upload \ -X POST \ -F "file=@/path/to/image.png"
# Multiple fieldsorb https://api.example.com/upload \ -X POST \ -F "file=@/path/to/image.png" \ -F "title=My Image" \ -F "description=A beautiful sunset"Orb automatically:
- Detects the MIME type from the file extension
- Generates a multipart boundary
- Sets the appropriate
Content-Typeheader
Request Examples
Section titled “Request Examples”# Simple GETorb https://api.example.com/users
# With query parameters (part of URL)orb "https://api.example.com/users?page=2&limit=10"
# With custom headersorb https://api.example.com/users \ -H "Accept: application/json" \ -H "Authorization: Bearer token"# JSON bodyorb https://api.example.com/users \ -X POST \ --json '{"name": "Alice"}'
# Form dataorb https://api.example.com/login \ -X POST \ -d "username=alice&password=secret"
# File uploadorb https://api.example.com/upload \ -X POST \ -F "file=@document.pdf"# Full updateorb https://api.example.com/users/1 \ -X PUT \ --json '{"name": "Alice", "email": "new@example.com"}'
# Partial updateorb https://api.example.com/users/1 \ -X PATCH \ --json '{"email": "updated@example.com"}'# Simple deleteorb -X DELETE https://api.example.com/users/1
# With authorb -X DELETE https://api.example.com/users/1 \ -H "Authorization: Bearer token"Content-Type Behavior
Section titled “Content-Type Behavior”| Flag | Sets Content-Type |
|---|---|
-d | application/x-www-form-urlencoded |
--json | application/json |
-F | multipart/form-data; boundary=... |
You can override the automatic Content-Type with a custom header:
orb https://api.example.com \ -X POST \ -d '{"custom": "data"}' \ -H "Content-Type: application/json"