Button Manager API

The Button Manager API enables you to programmatically create, manage, edit, and delete PayPal Payments Standard buttons. Alternatively, you can create payment buttons with all the same features using the Create a PayPal button page.


Use the Button Manager API to create and manage buttons when you are creating more than just a few PayPal Payments Standard buttons or when you manage buttons for others. For example, you should use the Button Manager API if you provide a shopping cart for merchants.

The Button Manager API enables you to manage PayPal Payments Standard buttons programmatically in the same way that you can manage them from the My Saved Buttons page on paypal.com.

Note: The My Saved Buttons page can be accessed by clicking Tools at the top of the page, then selecting the PayPal Buttons item on the Tools page. If you do not see Tools at the top of the page, Click Merchant Services and then select Create payment buttons for your website under the Features you can use right now heading.

You can use this API to create the following PayPal Payments Standard and Website Payments Pro Hosted Solution buttons:

  • Buy Now
  • Add to Cart and View Cart
  • Donate
  • Subscribe and Unsubscribe
  • Pay Now (Website Payments Pro Hosted Solution only)
  • Installment Plan
  • Automatic Billing

Generated button code

When you create a button, PayPal responds by generating code that you can paste into your web page or document.

The generated HTML code includes:

  • HTML code for including the button in web pages
  • URL link code for adding buttons to email and documents that support links

Note: Not all merchants in every country can use all the buttons that can be created. For example, German merchants cannot use Subscribe buttons even though they can be created through the API. If you can create the button for the specified country using the Create PayPal payment button page on www.paypal.com, your merchant will be able to use the button.

The following example shows the PayPal code for displaying a hosted Add to Cart button to sell a wireless mouse:

<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="19218">
<tr><td><input type="hidden" name="on0" value="Color">Color</td></tr><tr><td><select name="os0">
<option value="Red">Red $10.00
<option value="Blue">Blue $8.00
<option value="Green">Green $12.00
</select> </td></tr>
<tr><td><input type="hidden" name="on1" value="Size">Size</td></tr><tr><td><select name="os1">
<option value="Small">Small
<option value="Large">Large
</select> </td></tr>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_addtocart_120x26.png" alt="Add to Cart" name="submit">
<img alt="" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">

This sample code creates an Add to Cart button with drop-down menus for Color and Size options.

The PayPal-generated code for a link would be as follows:


For a link, PayPal does not generate code for options.

Button hosting

The Button Manager API can create the following types of buttons:

  • Hosted buttons: These buttons are hosted by PayPal. The parameters associated with this type of button are secure. Hosted buttons provide the greatest flexibility because you can instruct PayPal to change them dynamically, and PayPal maintains information about their state, such as the inventory level associated with the button.

    Note: You cannot use hosted buttons with Website Payments Hosted Solution; you should use token buttons instead.

  • Encrypted buttons: These buttons are not hosted by PayPal. The parameters associated with this type of button are encrypted. Encrypted buttons are similar to hosted buttons with regard to secure operation; however, you must update the web pages that use an encrypted button each time the button or its associated information changes, because that information is not hosted by PayPal. You should use an encrypted button only if a hosted button cannot be used.

  • Clear text buttons: These buttons are not hosted by PayPal. The parameters associated with this type of button are not encrypted. Clear text buttons are not hosted and are not encrypted. They can be used dynamically because you can change the value of a parameter "on the fly." However, if you use them, recognize the risk that sensitive information can be altered or stolen.

  • Token buttons: These buttons are not hosted by PayPal. They are only used with the Website Payments Pro Hosted Solutions product and the parameters associated with this type of button are secure. Token buttons are dynamic and initiate the Website Payments Pro Hosted Solution checkout flow. They have a lifetime of approximately 2 hours if not used.

Hosted button manipulation

When you create a hosted button, the response includes an ID that allows you to manipulate the button using the Button Manager API. Do not confuse a hosted button with a button used as part of Website Payments Pro Hosted Solution, which is a product that supports token, encrypted, and cleartext buttons.

With hosted buttons, you can:

  • Get a list of all hosted buttons, which allows you to identify buttons for further programmatic manipulation.
  • Get details about a hosted button, which allows you to identify the parameters and values associated with a button.
  • Update a hosted button, which allows you to change individual parameters, such as price, in a hosted button.
  • Manage hosted button status; currently, you can only delete a button.
  • Get and set inventory information associated with the button.

Inventory management using hosted buttons

You can get or set the inventory level for the item associated with a hosted button. You can also track inventory on options within an item, such as color or size.

If you enable inventory management for a button, PayPal tracks inventory for you and also lets your buyer know if the item is sold out. You can specify inventory tracking on an item-by-item basis, and also by option, such as color or size, within the item.

An e-mail alerts you if inventory falls below the threshold you specify. If an item is sold out, you can specify whether or not to accept a payment anyway. Optionally, you can specify a URL where your buyer's browser is redirected if the item is sold out.

You can also enable profit and loss tracking for an item or option associated with a button. If you enable this feature, you must provide the cost of the item or option. PayPal then calculates your gross profit, which is the selling price of the item less the specified cost.

Inventory management for digital downloads

If you use hosted buttons, you can choose to specify a list of download keys, which are keys that you define and are associated with the item being sold. These keys are useful when you want to sell digital goods with a key to enable access.

To use this feature, you set the inventory for the button to include one or more download keys, up to a maximum of 1,000 keys. These keys are then available when you get the inventory for a button.

For example, when a customer orders software or music, you could obtain an unused key from the list of download keys and email it to your customer so they can download the item. You are responsible for choosing the appropriate key from the list and how it is used. PayPal only stores the inventory of keys and does not track how a specific key is used, although PayPal does provide options for making this process simpler.

When you specify the inventory for a button, you can specify the usage of download keys:

  • Whether the keys you specify should be appended to the current list of keys or whether the list of keys should be replaced, which allows you to replenish the list of keys or replace the list entirely.
  • Whether the list of keys are to be reused or not.

If you do not reuse keys, PayPal will also notify you when the item is "sold out," meaning that there are no more keys available.

Specifying download keys with NVP

The following example shows how you might create several keys using the BMSetButtonInventory API operation:


These keys are appended to existing keys for the item and should not be reused.

Button Manager API summary

You can integrate with the Button Manager API using either name-value pairs (NVP) or SOAP. For detailed information on the following Button Manager API operations and their fields, see the NVP/SOAP API reference.

API Operation Description
BMCreateButton Create button code
BMUpdateButton Update a hosted button
BMManageButtonStatus Delete a button
BMGetButtonDetails Obtain information about the parameters associated with a button
BMButtonSearch Obtain a list of all buttons
BMGetInventory Obtain the inventory levels associated with a button
BMSetInventory Specify the inventory levels associated with a button

Website Payments Pro Hosted Solution links are URLs you create with the Button Manager API to initiate the Website Payments Pro Hosted Solution checkout flow.

Note: Although you can use the Button Manager API to create buttons that initiate the Website Payments Pro Hosted Solution checkout flow, do not confuse a button for Website Payments Pro Hosted Solution with hosted buttons that you also create with the Button Manager API.

You create the Website Payments Pro Hosted Solution checkout link dynamically when your buyer attempts to check out. For example, when your buyer clicks your check out button, you call the BMCreateButton API operation to create the link and then redirect the buyer's browser to PayPal using the link. The buyer then pays on the PayPal Website Payments Pro Hosted Solution page. After making the payment, PayPal returns the buyer to the page you specified when you created the link.

HTML variables control the presentation of the Website Payments Pro Hosted Solution pages, the information contained on the pages, and pages to which your customer can be returned to when leaving Website Payments Pro Hosted Solution pages. For an example of setting up HTML variables, see Checkout flow with Website Payments Pro Hosted Solution. For more information about Website Payments Pro Hosted Solution and the HTML variables that you can use, see the [Website Payments Pro Hosted Solution Guide](/docs/classic/paypal-payments-pro/integration-guide/#features.

Grant third-party permission for APIs

If you allow a shopping cart or another party to create buttons on your behalf, you must grant the party permission to execute Button Manager API operations for you.

Perform the following steps to grant third-party permissions:

  1. Log in to your PayPal business account at www.paypal.com

  2. Click the profile icon ( Profile menu ) at the top right side of the page. From the Business Profile menu, select Profile and Settings.

    Note: If you do not see the profile icon at the top right, select Profile which appears in the top menu when the My Account tab is selected.

  3. From the left menu, click My selling tools.

  4. In the Selling online section, click the Update link for the API access item.

  5. Click Grant API Permission.

  6. Click Configure a custom API authorization.

  7. Enter your Partner API username, as specified by your shopping cart or third party.

  8. Check each Button Manager API for which you want to provide access.

  9. Click Submit.

Examples >>