Make your first call

To make a PayPal REST request, follow the three steps below.

Note: You can run the examples listed here directly as-is. However, when creating your own application, be sure to update the OAuth keys in your code with those assigned to your own PayPal app.

Create a PayPal app

Log in to the Developer portal with your PayPal account and navigate to the My REST apps page. Click Create App to begin the application-creation process.

PayPal automatically provides Sandbox OAuth keys (a client_id and secret) for each application you create. See Manage your applications for details on creating and managing your PayPal applications.

To quickly see how the OAuth keys work, the example below uses a dummy set of keys that you can use to make your first test call.

Get an access token

Make a /token call using your application's OAuth keys (a client_id and secret) for the basic authentication values (like this: -u {clientId:secret}). In the request body, set grant_type to client_credentials. PayPal generates and returns a new access token.

Take a test run with the APIs using the OAuth tokens shown here. But remember to replace the keys with the ones assigned to your PayPal app when you start coding for real.

Tip: If you're using Windows, we recommend you make cURL calls using a Bash shell. If you're not using cURL calls, set the content-type to application/x-www-form-urlencoded for this request.

Example access token request

curl -v \
  -H "Accept: application/json" \
  -H "Accept-Language: en_US" \
  -u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" \
  -d "grant_type=client_credentials"

Sample response:

  "scope": "**",
  "access_token": "{accessToken}",
  "token_type": "Bearer",
  "app_id": "APP-6XR95014SS315863X",
  "expires_in": 28800

Note: The access token is valid for the number of seconds specified in the expires_in response value. You must have a valid access token to make API requests—request a new token when the current one expires.

Make an API call

Once you have a valid access token, you're ready to make API requests. Below is call to create a PayPal account payment. The simple request uses only the required input fields.

The access token is an OAuth bearer token, and is included in the header of your requests with the following syntax: Authorization: Bearer {accessToken}. See how PayPal uses OAuth 2.0 for details on authentication.

Important: You must supply a valid access token to complete this request (generate a valid token using the example call above).

Example PayPal payment request

curl -v \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-d '{

If the call is successful, PayPal returns a confirmation of the transaction with the state set to created. You can also confirm the creation of the PayPal transaction on your test dashboard.

Be aware that you must complete two additional steps finalize and capture the PayPal payment. Accept a PayPal payment contains all the details needed to complete the PayPal payment flow. You can also learn how to make payments using our interactive tool.

Learn more