Requests

Adding headers

Send headers with a request and control which ones are included.

Overview

The Headers tab lists the headers you add to a request. Relay also adds some headers of its own when it sends: the ones your authentication needs, a Content-Type that matches the body, a User-Agent, and the cookies stored for the workspace. A header you add yourself takes the place of an authentication, Content-Type, Accept or User-Agent header that Relay would add with the same name.

Header names and values can contain variables, such as Bearer {{token}}. For more information, see Using variables.

Add a header

  1. In the request editor, click Headers, or press Command-4.
  2. Click Add Header.
  3. Enter the header's name and value.

As you type a name, Relay suggests common request headers, such as Accept, Authorization and Content-Type, leaving out the ones the request already has. For some headers, such as Accept, Content-Type and User-Agent, it also suggests common values. Press the Up Arrow and Down Arrow keys to move through the suggestions, and press Return to accept one.

The Headers tab shows how many headers are turned on. If two rows that are turned on have the same name, Relay sends the value of the lower one.

Turn a header off or remove it

Deselect the checkbox at the start of a row to keep the header in the request without sending it. Select the checkbox to send it again.

To delete a header, click the Remove button (–) at the end of its row. A row without a name isn't sent.

Understand the headers Relay adds

When you send a request, Relay adds these headers:

  • Authentication: The headers the request's auth produces, such as Authorization for a bearer token or an API key sent as a header. For more information, see Inheriting authentication.
  • Content-Type: A type that matches the body: application/json for JSON and GraphQL, application/x-www-form-urlencoded for Form URL-Encoded, and multipart/form-data with a boundary for Multipart Form. A Text body uses the content type you enter in the Body tab.
  • Accept: For a GraphQL body, application/graphql-response+json, application/json.
  • User-Agent: Relay, or the value you enter in the User Agent field in the Requests pane of Relay > Settings. To stop Relay adding it, turn off Use Default User Agent there.
  • Cookie: The workspace's stored cookies that match the URL. For more information, see Managing cookies.

To see the headers a request sends before you send it, click the method and URL in the bar at the bottom of the request editor. The Preview panel shows the request as raw HTTP. After you send it, the Headers tab of the response inspector shows the headers that actually went out.

See Also