# Debug apps with Postman

> [**Postman**](https://www.postman.com/) is an application that lets you send HTTP requests to ShopBase API endpoints. It can be a useful tool for getting started with the ShopBase API or for debugging your apps.

## Get your ShopBase API credentials

To make authorized requests to the ShopBase API from Postman, you need to [generate private API credentials](https://developers.shopbase.com/build-an-app-tutorial/making-your-first-request/authentication/private-apps#generate-credentials-from-the-shopify-admin)

{% hint style="info" %}
The scopes you grant when generating your API credentials will give Postman the equivalent permissions. Proceed with caution when granting write access.
{% endhint %}

**Step 1:** To generate private API credentials, create a private app:

{% hint style="warning" %}
Consider skipping this part if you are already familiar with the content.
{% endhint %}

![](https://i.imgur.com/w7do5MP.gif)

**Step 2:** Send your API Credentials into Postman's New Tab :

1. Click `+` to create a new tab.&#x20;
2. Click **Authorization**.
3. From the **Type** drop-down menu, select **Basic auth**.   &#x20;
4. In the **Username** and **Password** fields, enter your store's private API key and password respectively.

![](https://i.imgur.com/0dDdZfD.gif)

{% hint style="danger" %}

#### CAUTION

Don't enter the shared secret in place of the API password
{% endhint %}

After you've authenticated your request, you need to specify the applicable HTTP method and API endpoint URL before you can send it. For example, you can use Postman to retrieve your store information:

1. From the request method drop-down menu, select **GET**.
2. Enter the store API endpoint, where `<store-names>` is the name of your store:

   ```
   https://{store-names}.onshopbase.com/admin/shop.json
   ```

![](https://i.imgur.com/jnjz3FA.png)

&#x20;   3.Click **Send.**

If the request was formatted correctly, then the store information is returned:

```
{
  "shop": {
    "id": 4159229,
    "name": "John's Apparel",
    "email": "johns-apparel@gmail.com",
    "domain": "johns-apparel.com",
    "created_at": "2014-03-27T17:52:33-04:00",
    "province": "Ontario",
    "country": "CA",
    "address1": "150 Elgin St.",
    "zip": "K2P1L4",
...
  }
}
```

### Add API credentials to an endpoint URL

Instead of entering your credentials in the **Authorization** section of Postman, you can paste a URL that includes your API key and password directly into the URL bar. The format of the URL is as follows, where `<store-name>` is the domain of your store:

```
https://apikey:password@<store-name>.onshopbase.com/admin/shop.json
```

When you click **Send**, the data is returned to Postman in the body of the response.

## Generate code snippet for API support

Whenever you need support with your API call, you can contact our support team and send us the CURL request using the below instruction.

{% hint style="warning" %}
Please create a new private app or generate a new private key once the support process is done to ensure the security of your app.
{% endhint %}

1. Create the API request with Postman (Step 2: **Send your API Credentials into Postman's New Tab** in **Get your ShopBase  API credentials**)
2. Select **Code** (**\</>**) button on the top right.
3. Select **cURL** (Code Generation Settings).   &#x20;
4. Use the copy button and send the code to ShopBase Support.

![](/files/-MWTSQcO2s6V6NUGClqR)

## Creating Postman collections

After you've successfully sent an API request with Postman, you can save it into a **collection**. Collections group together related API calls and are a great way to organize your work in Postman.

To save an API request to a collection:

1. In the tab for the API call you've just sent, click the arrow next to **Save**.
2. Click **Save As**, then enter a **Request name**. You can also enter an optional description for the request.
3. Click **Create collection**.
4. Enter a name for your collection, then click the checkmark.
5. Select the name of your collection.
6. Click **Save to (Name of your collection)**.

You can access your saved collections from the **Collections** tab in the sidebar.

{% hint style="info" %}

#### TIP

Looking for a quick start? You can find details about all supported APIs in the [Admin API reference](https://api-doc.shopbase.com/).&#x20;
{% endhint %}

## Adding calls to Postman collections

After you've created a collection, you can add calls to help organize your API calls. For this example, you'll add a call that posts a product to your store.

To create a call and add it to your collection:

1. Click `+` to open a new tab.
2. From the **Type** drop-down menu, select **Basic Auth**.
3. In the **Username** and **Password** fields, enter your store's private API key and password respectively.
4. From the API actions drop-down menu, select **POST**.
5. Enter the API endpoint for adding a product, where `<@store_url>` is the URL of your store:
6. Click **Body**.
7. Select **raw**, then in the drop-down menu, select **JSON (application/json)**.
8. In your browser, go to the [Product reference](https://api-doc.shopbase.com/#operation/create-a-product)
9. Scroll down to the **Create a new product** POST call and copy the JSON of the IPod Nano - White, 8GB product.
10. Paste the JSON in the **Body** of your Postman request.

![](https://i.imgur.com/gSDvHnj.png)

&#x20;  11\. Click **Send**. If the request is properly formatted, then the product response JSON will be returned to Postman.

{% hint style="info" %}

#### NOTE

Shopbase prevents HTTP Basic Auth POST requests that have cookies, which can cause POST calls to fail. If your POST call fails, then you should try [clearing your cookies](https://www.getpostman.com/docs/v6/postman/sending_api_requests/cookies).&#x20;

Also note that the request headers automatically update to include **Content-Type:application/json**:&#x20;
{% endhint %}

![](https://i.imgur.com/OtqbhUg.png)

![](https://i.imgur.com/NN1O9PZ.gif)

&#x20;  12\. After the call has sent successfully, click the arrow next to **Save**.\
&#x20;  13\. Select the name of your collection.   \
&#x20;  14\. Click **Save to (Name of your collection)**.

You can add as many API calls to a collection as you want. You can access your saved collections from the **Collections** tab in the sidebar.

![](/files/-MPab1b30QEdHH0lne64)

## Next steps

Browse the [Postman documentation](https://www.getpostman.com/docs/collections) to learn about collections and other features in more detail. You can also use Postman to help you [build a public ShopBase app](https://developers.shopbase.com/build-an-app-tutorial/making-your-first-request/authentication#public-apps).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.shopbase.com/test-and-debug-app/test-and-debug-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
