> ## Documentation Index
> Fetch the complete documentation index at: https://docs.requestly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authorization

> Learn how to set up and use various API Authorization methods in Requestly, including API Key, Bearer Token, and Basic Auth, for secure API interactions.

Requestly allows you to send authorization data along with your API requests. Authorization data confirms that the sender has permission to access the API.

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/pnZ8toyzjAM" />

<Info>
  Authorization details can be configured in the Authorization tab at either the **collection level** or the **request level**. When authentication is set at the collection level, it applies to all APIs within that collection unless a specific request defines its own authorization settings or selects **NO-AUTH.** Requestly automatically inserts the appropriate authorization information into the necessary sections of the request based on the chosen authentication type.
</Info>

## Steps to Add Authorization

<Steps>
  <Step title="Open a Request or Collection">
    Click on any request or collection to begin setting up authorization.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/bff6af01-a980-412b-8b68-26c775ce6e55.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=6df153e3834e8a5618d2418a25c8afa0" align="center" fullwidth="false" width="2400" height="1380" data-path="images/authorization/bff6af01-a980-412b-8b68-26c775ce6e55.png" />
  </Step>

  <Step title="Access the Authorization Tab">
    1. Go to the **Authorization** tab.
    2. Choose the appropriate authorization type from the dropdown menu.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/d2323c4f-282b-4d5e-b1dc-31649edd9702.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=6b7fe1c9a99fb15fed8924a443c3cc43" align="center" fullwidth="false" width="2400" height="1380" data-path="images/authorization/d2323c4f-282b-4d5e-b1dc-31649edd9702.png" />
  </Step>

  <Step title="Enter Authorization Details">
    Each authorization type has specific fields that must be filled. Below are the details for each type:

    #### No Auth

    Requestly won’t send authorization details with a request unless you specify an auth type. If your request doesn’t require authorization, select "No Auth" from the Auth Type dropdown list.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/f222a398-7997-4621-adf5-59b9594c039f.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=6021fa113fa1a60e8e988eaa8b531668" align="center" fullwidth="false" width="2400" height="1276" data-path="images/authorization/f222a398-7997-4621-adf5-59b9594c039f.png" />

    #### Inherit Auth from Parent

    Requestly uses the auth applied at the parent level. The inherited properties are populated when the request is sent. This works for API requests and sub-collections.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/1ec7caab-8612-4bf0-a794-97c4c7d832c5.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=aac3aa396a80bf85fd024ead0bbf07c8" align="center" fullwidth="false" width="2400" height="1276" data-path="images/authorization/1ec7caab-8612-4bf0-a794-97c4c7d832c5.png" />

    #### API Key

    Requestly allows you to send key-value pairs along with the request data. These can be added to either Headers or Query Params. Select "API Key" from the Auth Type list, then enter your key name and value. Choose "Header" or "Query Params" from the "Add to" dropdown list for their inclusion. Variable storage enhances security.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/1d01ebb8-282e-478d-87fd-01a1646cdd40.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=1c24bdf0675b73e8e46b2469f267f7ed" align="center" fullwidth="false" width="2400" height="1378" data-path="images/authorization/1d01ebb8-282e-478d-87fd-01a1646cdd40.png" />

    #### Bearer Tokens

    Bearer tokens enable requests to authenticate using an access key such as a JSON Web Token (JWT). Tokens are included in the request header. Select "Bearer Token" from the Auth Type dropdown and enter the token value. For additional security, store the token in a variable and reference it by name.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/de9fed66-ee47-4d40-927b-d4214c162432.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=c288ad0acdae084a5cbf79f5493710d9" align="center" fullwidth="false" width="2400" height="1378" data-path="images/authorization/de9fed66-ee47-4d40-927b-d4214c162432.png" />

    Requestly appends the token value to the text "Bearer" in the required format in the Authorization header.

    #### Basic Auth

    Basic authentication involves sending a verified username and password with your request. Select "Basic Auth" from the Auth Type dropdown. Enter your API username and password in the respective fields. For extra security, store these in variables.

    <img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/2238bb19-24e6-454e-9271-2f947349705b.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=5576780a7e76b85f4d3285f05f9bae91" align="center" fullwidth="false" width="2400" height="1378" data-path="images/authorization/2238bb19-24e6-454e-9271-2f947349705b.png" />

    In the request headers, the Authorization header passes the API a Base64 encoded string representing the username and password, appended to the text "Basic."
  </Step>

  <Step title="Test the Request">
    Click "Send" to ensure that the authorization data is sent along with the API request.
  </Step>
</Steps>

## Variable Support and Export

Requestly supports the use of variables in Authorization Values, allowing flexibility and reuse across multiple requests or collections. Variables can store sensitive data securely and simplify updates when values change. For instance, you can define API tokens or credentials as variables and reference them in authorization fields.

<img src="https://mintcdn.com/requestly/qIWXalHJdphCbP8R/images/authorization/e5ffe9af-749f-4b37-9dd9-61ea5caae1e0.png?fit=max&auto=format&n=qIWXalHJdphCbP8R&q=85&s=211d749f8b5df74004996c7bfbde81ee" align="center" fullwidth="false" width="2400" height="1378" data-path="images/authorization/e5ffe9af-749f-4b37-9dd9-61ea5caae1e0.png" />

While authorization data can be exported alongside requests or collections, note that variable values themselves are not exported. This ensures the security of sensitive data and prevents accidental sharing of confidential information. Users need to define variable values locally when importing shared requests or collections.

## What's Next?

<CardGroup cols={3}>
  <Card title="Environment Variables" icon="globe" href="/api-client/environments-and-variables">
    Store and manage auth tokens securely with variables
  </Card>

  <Card title="Request Headers" icon="list" href="/api-client/send-api-request/create-requests/request-headers">
    Learn how authorization headers are added to requests
  </Card>

  <Card title="API Collections" icon="folder" href="/api-client/api-collections">
    Apply authorization to multiple requests at once
  </Card>
</CardGroup>
