Importing cURL commands
Turn a cURL command into a draft request.
Overview
API documentation, browser developer tools and colleagues often share requests as cURL commands. Relay reads a command and creates a draft with its method, URL, query parameters, headers, body, authentication and settings, so you can send it, edit it and save it to a collection.
Relay reads the command as text and never runs it. It doesn't start a shell, read files the command names, connect to the network or expand shell variables.
Import a command
-
Choose File > Import > cURL Command…, or press Shift-Command-I. You can also click the Add button (+) at the bottom of the sidebar and choose Import > cURL Command….
If the clipboard holds a cURL command, Relay pastes it for you.
-
Paste or edit the command.
The Preview beside it shows the method and URL, how many headers and query parameters the request has, its body type and its authentication. If Relay changed or left out part of the command, the warnings appear under Imported with warnings. If it can't import the command, the Preview explains why.
-
Click Import.
The new draft opens in the request editor, in the window's workspace. To remove it again, choose Edit > Undo.
The command must start with curl or curl.exe. A leading $ prompt and lines continued with a backslash are fine.
Learn how options are imported
| Option | Imported as |
|---|---|
The URL, or --url | The request's URL. Its query string becomes query parameters. |
-X, --request | The method, including custom methods such as PURGE. |
-I, --head | The HEAD method. |
-H, --header | A header. |
-A, --user-agent | A User-Agent header. |
-e, --referer | A Referer header. |
-b, --cookie | A Cookie header, for cookies written inline as name=value. |
-d, --data, --data-ascii, --data-binary, --data-raw | The body. Several are joined with &. |
--data-urlencode | A form field. |
--json | A JSON body, plus Content-Type and Accept headers of application/json when the command doesn't set them. |
-F, --form, --form-string | A multipart form field. A ;type= suffix sets the field's content type. |
-G, --get | Query parameters made from the data options, sent with GET. |
--url-query | A query parameter. |
-u, --user | Basic Auth. With --digest, --ntlm or --aws-sigv4, Digest Auth, NTLM or AWS Signature. |
--oauth2-bearer | Bearer Token auth. |
-k, --insecure | Verify Certificates turned off. |
-m, --max-time | The request timeout. |
--max-redirs | Maximum Redirects. A value of 0 turns off Follow Redirects. |
--post301, --post302, --post303 | Follow Original Method turned on. |
--location-trusted | Keep Authorization Across Origins turned on. |
-L, --location | Nothing. Relay follows redirects unless the request's settings say otherwise. |
Settings such as the timeout and redirects go on the request's Settings tab. For details, see Configuring request settings.
Method
When the command has no -X option, Relay uses HEAD for -I, GET for -G, POST when the command sends data or form fields, and GET otherwise. Relay refuses a GET, HEAD or TRACE command that has a body; add -G to send the data in the query string instead.
Body
Relay chooses the body type from the command:
- JSON: The command uses
--json, or itsContent-Typeheader names JSON. A body with a GraphQLquerybecomes a GraphQL body. - Form URL-Encoded: Every data option is a
name=valuepair and the command sets noContent-Type, or setsapplication/x-www-form-urlencoded. - Multipart Form: The command uses
-F. - Text: Any other data, sent with the command's
Content-Type.
Authentication
With -u and --ntlm, a user name written as DOMAIN\user fills in the NTLM domain. With --aws-sigv4 "aws:amz:REGION:SERVICE", Relay reads the region and service from the option, or from an amazonaws.com host when the option leaves them out, and an x-amz-security-token header becomes the session token. When -u has no password, cURL would ask for one; Relay imports an empty password and warns you.
Understand what's left out
Relay imports the parts of a command that describe the request, and warns you about the rest:
- Options that control how cURL itself runs, such as
--compressed,-s,-v,-o,-w,--retry,--connect-timeout,--cacertand-c, are ignored. - Proxy options (
-x,--proxy,--preproxy,-U,--proxy-user,--noproxy) are left out. Relay's proxy is set in the Network pane of Relay > Settings. - Client certificate options (
-E,--cert,--key,--cert-type,--key-type,--pass) are left out. Add client certificates in the workspace's Certificates tab instead. --anyauthimports Basic Auth, and--negotiateauth is left out.- Shell variables such as
$TOKENstay in the request as written. Inside single quotes, a$is just a character, so there's no warning.
Relay can't import a command that:
- Reads from a file, such as
-d @body.json,-H @headers.txt,-F file=@photo.jpg,-Tor a cookie file. Paste the content inline, or for a file field, import without it and add the file in Relay. - Uses
--next,-K,--config,--resolve,--connect-to,--interface,--unix-socketor--request-target. - Has more than one URL, or mixes
--dataand--formoptions. - Contains pipes, redirections,
;,&, or command substitution: backticks or$(…)outside single quotes.
Import a WebSocket command
A command for a ws:// or wss:// URL becomes a WebSocket draft. Relay keeps its headers, query parameters, authentication and settings. A WebSocket opens with a GET handshake and has no body, so a method other than GET and any data options are dropped with a warning. Add the data as a saved message instead. For more, see Connecting to a WebSocket server.
Import from an AI agent
An AI agent connected to Relay's MCP server can create the same draft with the add_draft_from_curl tool. For a list of tools, see MCP Tools.
See Also
- Sending your first request: Create a draft, send it, read the response and save the request.
- Creating and managing requests: Keep requests as drafts or save them in collections, and rename, duplicate and open them in their own windows.
- Generating code from requests: Turn a request into code for curl, Python, JavaScript, Swift and other languages.
- Supported formats: The import formats, body types, auth types and limits Relay supports.