---
title: Manually generating key pairs
url: amazon-pay-api-v2/manually-generating-key-pairs.html
---

<div markdown="span" class="alert alert-success" role="alert"><i class="fa fa-info-circle"></i> <b>Tip:</b> You can also generate public/private key pairs using Amazon Pay Integration Central. See [get set up for integration](../amazon-pay-checkout/get-set-up-for-integration.html) for more information.</div>

<script>
  function keySpecifics(){
    const keyQuery = "?environmentSpecificKeys=";
    const currentSetting = window.location.search?.split("?environmentSpecificKeys=")[1] ?? 'false';
    const newSetting = currentSetting === 'false' ? 'true' : 'false';
    window.location = window.location.origin + window.location.pathname + keyQuery + newSetting // +  window.location.hash (not included as it feels weird to jump down)
  }
</script>
<div style="display:none" class="environmentSpecificKeys">
  <div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> If your publicKeyId <b>_does not_</b> have an environment prefix (does not begin with 'SANDBOX' or 'LIVE') follow <a href='#' onclick='keySpecifics()' rel='noopener noreferrer'>these instructions</a> instead.</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
  <div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> If your publicKeyId has an environment prefix (for example: SANDBOX-AFVX7ULWSGBZ5535PCUQOY7B) follow <a href='#' onclick='keySpecifics()' rel='noopener noreferrer'>these instructions</a> instead.</div>
</div>


* TOC
{:toc}
{::options toc_levels="3" /}

***

### Generating key pair

Amazon Pay uses asymmetric encryption to secure communication. You will need a public/private key pair and a corresponding Public Key ID (a unique Amazon Pay identifier for the key pair) to access Amazon Pay. You can manually generate a public/private key pair using these instructions:

<ul role="tablist" class="nav nav-tabs">
    <li class="nav-item"><a class="active nav-link noExtIcon" href="#linux_mac" data-toggle="tab">Linux / Mac</a></li>
    <li class="nav-item"><a class="nav-link noExtIcon" href="#windows_ten" data-toggle="tab">Windows 10</a></li>
    <li class="nav-item"><a class="nav-link noExtIcon" href="#windows_bash" data-toggle="tab">Windows (Git Bash)</a></li>
</ul>
<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="linux_mac">
        Open Command Prompt or Terminal and use these commands to generate a public and private key pair:
        <pre><code>
openssl genpkey -out privateKey.pem -algorithm RSA -pkeyopt rsa_keygen_bits:2048
openssl rsa -in privateKey.pem -pubout > publicKey.pub
        </code></pre>
    </div>
    <div role="tabpanel" class="tab-pane" id="windows_ten">
        Open a Windows command prompt or PowerShell and use these commands to generate a public and private key pair:
        <pre>
          <code>
ssh-keygen -t rsa -b 2048 -m PKCS8 -f privateKey.pem
ssh-keygen -f privateKey.pem -e -m PKCS8 > publicKey.pub
          </code>
        </pre>
    </div>
    <div role="tabpanel" class="tab-pane" id="windows_bash">
        You must install a shell program to generate the keys. Download <a href="https://gitforwindows.org/">Git Bash</a> (or an equivilant emulation software) and use these commands to generate a public and private key pair:
        <pre>
          <code>
openssl genpkey -out privateKey.pem -algorithm RSA -pkeyopt rsa_keygen_bits:2048
openssl rsa -in privateKey.pem -pubout > publicKey.pub
          </code>
        </pre>
    </div>
</div>

Once you have generated a key pair, you can exchange the public key for a Public Key ID using Amazon Pay Integration Central: <a href="https://sellercentral.amazon.com/gp/pyop/seller/integrationcentral/" target="_blank" rel="noopener noreferrer">US</a>, <a href="https://sellercentral-europe.amazon.com/gp/pyop/seller/integrationcentral/" target="_blank" rel="noopener noreferrer">EU</a>, <a href="https://sellercentral-japan.amazon.com/gp/pyop/seller/integrationcentral/" target="_blank" rel="noopener noreferrer">JP</a>.


### Exchanging public key for Public Key ID


<div style="display:none" class="environmentSpecificKeys">
<div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> Amazon Pay requires separate credentials for different enviroments. Use the Marketplace switcher drop-down menu to generate a key pair with access to either Sandbox or Live environment.</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
<div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> Amazon Pay does not require separate credentials for different environments. You can use the same Public Key ID and key pair for both Live and Sandbox.</div>
</div>

Follow these instructions to exchange the public key you generated in the previous step for a Public Key ID:

1. Navigate to Amazon Pay Integration Central: <a href="https://sellercentral.amazon.com/gp/pyop/seller/integrationcentral/" target="_blank" rel="noopener noreferrer">US</a>, <a href="https://sellercentral-europe.amazon.com/gp/pyop/seller/integrationcentral/" target="_blank" rel="noopener noreferrer">EU</a>, <a href="https://sellercentral-japan.amazon.com/gp/pyop/seller/integrationcentral/" target="_blank" rel="noopener noreferrer">JP</a>.
2. Identify as a “Self-developed” integration
    1. Select “Self-developed” option from the drop-down menu
    2. Use the default “One-time Payments, Single Authorization” payment type setting
    <img style="width: 60%" src="https://m.media-amazon.com/images/G/01/EPSDocumentation/AmazonPay/Integration/IntegrationCentral-OneTimeSingleAuth._CB1198675309_.png" />
    3. Click on the “Get instructions” button
3. Create a public/private key pair
    1. Navigate to the “API keys” section
    2. Click on the “Create keys” button
    3. Select option "Use an existing public key to create API credentials"
    4. Name your API keys. Use a descriptive name, the name will be used to differentiate between multiple keys when you need to manage them in Integration Central. When naming the keys, you should consider who is using it and what they’re using it for
    5. Click “Create keys” to create your Public Key ID







