# How to call Mastercard APIs using the Official Mastercard Postman Collections
source: https://developer.mastercard.com/easy-savings-specials/documentation/tutorials-and-guides/example-tutorial/index.md

## Overview {#overview}

Postman is an API platform for building and using APIs. It can be used to write functional tests, integration tests, regression tests, and more. This tutorial shows you how to use Postman collections hosted in the Mastercard workspace on [Postman](https://www.postman.com/mastercard/workspace/mastercard-developers/overview).

## Prerequisites {#prerequisites}

* Sign up for a new account or log in to your existing postman account.
* Sign in to [Mastercard Developers](https://developer.mastercard.com/account/log-in). Create a project for the service that you want to make a call to. To create a project, refer to [Mastercard Developers Guide](https://developer.mastercard.com/platform/documentation/getting-started-with-mastercard-apis/quick-start-guide/).

### You will learn how to: {#you-will-learn-how-to}

* Set up the Postman Environment for Mastercard APIs
* Configure Authentication for Mastercard APIs
* Configure Payload Encryption for Mastercard APIs
* Invoke a Mastercard API from Postman

### Step 1 - Set up the Postman Collection {#step-1---set-up-the-postman-collection}

Setting up a Postman collection for Mastercard's APIs can be done in two different ways.

1. Forking one of the collections hosted in the official Mastercard Postman workspace.
2. Importing one of Mastercard's API specifications into your local workspace.

You can choose either of these two methods:

### Forking Mastercard's Collections {#forking-mastercards-collections}

* Navigate to the Postman Collection page in the documentation section of the Mastercard API that you are interested in. Click **Run in Postman**. It takes you to the API in the Mastercard Postman workspace.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture1.png)

* Click **...** adjacent to the API's collection and select **Create a Fork**.
* Add a label to your fork and the workspace in which you want to create the fork. Click **Fork Collection**.
* This forks the Mastercard API to your personal Postman workspace.

### Importing an API specification {#importing-an-api-specification}

* Download the Open API specification (.YAML) file. Here we are using the spec for Locations from [Mastercard Developers](https://developer.mastercard.com/easy-savings-specials/documentation/api-reference/).

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture2.png)

* In your Postman application, select **Import**.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/postman_06.png)

* From **File** , click **Upload Files** option.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/postman07.png)

* **Import** your .YAML file. Postman automatically creates a collection from this file.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/postman08.png)

### Step 2 - Configure the Postman environment {#step-2---configure-the-postman-environment}

Once the collection is imported into your Postman workspace, you need to set up the Postman Environment.

* Go to the Environments tab of the Mastercard Developer Postman workspace.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture3.png)

* If the API uses:
  * Mastercard encryption: Search for ***Mastercard API Sandbox Environment with Encryption***.
  * JWE encryption: Search for ***Mastercard API Sandbox Environment with JWE Encryption***.
  * No encryption: Search for ***Mastercard API Sandbox Environment***.
* Click **...** adjacent to the API's environment and select **Create a Fork**.
* Add a label to your fork and the workspace in which you want to create the fork. Click **Fork Environment**.
* This forks the ***Mastercard API Sandbox Environment*** to your personal Postman workspace.

### Step 3 - Setting up the base URL {#step-3---setting-up-the-base-url}

* Select the forked environment from the dropdown.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture4.png)

* Set the `baseUrl` with the Sandbox URL value from your API specification in the ***Current value*** field.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture55.png)

## Enabling authentication {#enabling-authentication}

Mastercard supports OAuth 1.0a authentication mechanisms.

## OAuth 1.0a {#oauth-10a}

### OAuth 1.0a instructions {#oauth-10a-instructions}

If you imported an open api specification in Step 1 instead of forking from the Mastercard workspace, then do the following.

* Click your collection, navigate to the Authorization tab and configure the values as shown and save the changes.

* Java

```java
Type = OAuth 1.0
Add auth data to = Request Headers
Signature Method = RSA-SHA256
Consumer Key = {{consumerKey}}
Private Key = {{privateKey}}
In the Advanced section, check "Include body hash"
```

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture10.png)

### Extract the private RSA key {#extract-the-private-rsa-key}

Run the given command to extract the private RSA key from the `.p12` certificate that you downloaded as part of creating the project in Mastercard Developers.
* Java

```java
openssl pkcs12 -in 'mykey.p12' | openssl rsa -out myrsa.key
```

* When prompted, use the password or passphrase values of your `.p12` file (use the password from the project creation page).

### Configure your Postman environment {#configure-your-postman-environment}

* Set the `baseUrl` with the Sandbox URL value from your API specification in the ***Current value*** field.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture13.png)

* Set the `consumerKey` copied from your project dashboard in the ***Current value*** field.
* Run `pbcopy < myrsa.key `from a terminal and paste the content into the `privateKey` in the ***Current value*** field.

## Invoke a Mastercard API from Postman {#invoke-a-mastercard-api-from-postman}

Choose any of the requests and click **Send**. You should get a successful response.

![](https://static.developer.mastercard.com/content/easy-savings-specials/uploads/Picture15.png)

## Congratulations {#congratulations}

#### You have completed this tutorial and have successfully made a call to a Mastercard API using Postman. {#you-have-completed-this-tutorial-and-have-successfully-made-a-call-to-a-mastercard-api-using-postman}

Explore the full range of [Mastercard APIs](https://developer.mastercard.com/products) to help your business transact with digital payments.

#### Need help? {#need-help}

Get in touch with our [support team](https://developer.mastercard.com/support/).
