This quickstart shows you how to call the Commerce API.

Step 1: Set up

Create an account and API key at Getting Started.

Step 2: Authenticate API Requests

Use the X-CC-Api-Key header to authenticate requests with your API key.

Example:

curl https://api.commerce.coinbase.com/checkouts \
-H "X-CC-Api-Key: YOUR_API_KEY"

401 errors

If authentication fails, a JSON object with an error message is returned with HTTP status 401.

Step 3: Create a Charge

To start accepting payments, create a charge. You can navigate to the charge by pasting the hosted_url into your browser

Example:

curl -X POST https://api.commerce.coinbase.com/charges/ \
-H "Content-Type: application/json" \
-H "X-CC-Api-Key: YOUR_API_KEY" \
-d '{
      "name": "The Human Fund",
      "description": "Money For People",
      "pricing_type": "fixed_price",
      "local_price": {
        "amount": "1.00",
        "currency": "USD"
      }
    }'

Step 4: Retrieve a Charge

Retrieve the charge to get payment information. The id field in the response is the CHARGE_UUID.

Example:

curl https://api.commerce.coinbase.com/charges/<CHARGE_UUID> \
-H "X-CC-Api-Key: YOUR_API_KEY"

Step 5: Add a ‘Pay with Crypto’ Button

You can add a payment button to your website using a payment link or programmatically. See Adding a ‘Pay with Crypto’ Payment Button.

Step 6: Set Up Webhooks

Subscribe to webhooks for real-time updates on charges. Learn more about webhooks at Commerce API Webhooks Overview.

Conclusion

You are now ready to accept cryptocurrency payments with Coinbase Commerce.

For more detailed information, refer to our API reference and the rest of the Coinbase Commerce API documentation.


See Also: