Skip to content
gurl save

gurl save

Store an HTTP request under a name so you can run it later with gurl run <name>. URL, headers, body and auth params may contain {{placeholders}} that are filled at send time.

Synopsis

gurl save <name> <url> [flags]
gurl save <name> --curl "<curl command>"
gurl save --name <name> --curl "<curl command>"

To parse a curl command from stdin, use gurl detect.

The collection passed with --collection must already exist. In an interactive terminal gurl offers to create it; with --no-input (or --json/--agent) it fails and names the command to run: collection "x" does not exist; create it first with 'gurl collection create x'.

Flags

FlagShortDefaultDescription
--collection-cnoneAssign to a collection
--folder-FnoneAssign to a folder (e.g., api/v2/users)
--tag-tnoneAdd a tag (repeatable)
--format-fautoOutput format preference: auto, json, table
--descriptionnoneHuman-readable description
--namenoneName for the request (used with --curl)
--curlnoneFull curl command as a string
--request-XGETHTTP method
--header-HnoneHTTP header 'Key: Value' (repeatable)
--data, --body-dnoneRequest body
--extractnoneExtraction rule VAR=METHOD:EXPR (repeatable). METHOD: jsonpath, header, regex, jq
--pre-script--prenonePre-request script
--post-script--postnonePost-response script
--authnoneAuth type: basic, bearer, apikey, oauth1, oauth2, awsv4, digest, ntlm, none
--auth-paramnoneAuth parameter KEY=VALUE (repeatable)

Aliases

  • s

Examples

Save a JSON POST with placeholders

gurl save "create-order" '{{BASE_URL}}/orders' \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {{API_KEY}}" \
  -d '{"customer_id":"{{customerId}}","amount":"{{amount:num}}"}'

The quoted typed placeholder "{{amount:num}}" keeps the stored body valid JSON and sends a number. See Variables and placeholders.

Save from a curl command

gurl save "me" --curl "curl -H 'Accept: application/json' https://api.example.com/me"

Save auth and an extraction rule

gurl save "login" '{{BASE_URL}}/auth/login' \
  -X POST \
  --collection payments-api \
  --auth basic --auth-param username='{{USER}}' --auth-param password='{{PASSWORD}}' \
  --extract token=jsonpath:'$.token'

Use gurl auth info <type> to see every parameter a handler accepts, and gurl extract to test a rule against a sample response first.

Related commands