Adding tree planting to your application used to mean manual processes, spreadsheets, and a sustainability manager making bulk purchases once a quarter. Today, a sustainability API for developers makes it possible to trigger real-world environmental action — planting trees, removing ocean plastic, and generating verified impact certificates — through a simple HTTP request. In this guide, we’ll walk through exactly how to do it.
Why Developers Are Adding Sustainability to Their Stack
The business case for embedding sustainability into your product has never been stronger. According to a 2024 PwC survey, consumers are willing to pay a 9.7% premium for sustainably sourced goods. Among Gen Z shoppers, 73% actively prefer brands that take environmental action. And the U.S. eco-friendly retail market is growing 71% faster than conventional retail.
But beyond consumer sentiment, there is a technical angle: companies are under growing ESG reporting pressure. When sustainability actions are triggered programmatically and logged through an API, the data trail is automatic. You get clean, auditable records without manual entry.
For developers, this creates an interesting opportunity. You can turn a purchase, a signup, a milestone, or any custom event into a moment of verified environmental impact. And you can do it with a few lines of code.
What a Tree Planting API Actually Does
At a basic level, a tree planting API accepts a trigger from your system and responds by initiating a real tree planting (or plastic removal, or carbon offset) through a vetted reforestation partner. The key word there is “vetted.” Any responsible sustainability API should connect to certified projects — ones that track planting locations, species, survival rates, and local community outcomes.
Here is what a typical request/response cycle looks like:
- A customer completes a purchase in your store
- Your backend fires a POST request to the sustainability API
- The API records the action, queues the planting with a partner organization, and returns a confirmation
- Your system logs the confirmation ID for impact reporting
- At the end of the month, you receive a consolidated report with geo-tagged proof of impact
The whole flow is asynchronous — planting happens on the ground over days and weeks — but the tracking record is created instantly.
Getting Started With GoodAPI
GoodAPI offers a developer-first sustainability API that lets you integrate tree planting and plastic removal into any application. Here is how to get up and running.
Step 1: Get Your API Keys
GoodAPI uses a beta key to bootstrap your account. Reach out to the GoodAPI team to request your beta key, then use it to call the signup endpoint and generate your own keys. Send a POST request to https://app.thegoodapi.com/signup with the beta key as a header, along with your contact name, email, and organization name:
curl -X POST https://app.thegoodapi.com/signup \
-H "beta_token: YOUR_BETA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"contact_name": "Jane Developer",
"email": "jane@yourcompany.com",
"name": "Your Company Name"
}'
The response returns two API keys tied to your account:
api_key_prod— your live key that triggers real plantings and monthly billingapi_key_test— a sandbox key for development that does not incur charges
This separation is important. Always use api_key_test during development and testing so you are not billed for every test run.
Step 2: Authenticate Your Requests
Authentication is header-based. Include your key in every request:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Step 3: Define Your Trigger Events
Before writing any code, decide what user actions should trigger a planting. Common patterns used by GoodAPI merchants include:
- Per purchase: Plant one tree for every order placed
- Per dollar amount: Plant one tree for every $50 spent
- Per signup: Plant one tree when a user creates an account
- Per review: Plant one tree when a customer leaves a product review
- Per subscription renewal: Plant one tree for each recurring billing cycle
- Per employee: Plant trees on a monthly cadence for workforce programs
Each of these is just a different event in your application. The API call looks the same regardless.
Step 4: Make Your First API Call
Here is a minimal example in Python:
import requests
def plant_tree_for_order(order_id, customer_email):
url = "https://app.thegoodapi.com/plant"
headers = {
"Authorization": "Bearer YOUR_API_KEY_TEST",
"Content-Type": "application/json"
}
payload = {
"event_type": "purchase",
"reference_id": order_id,
"customer_email": customer_email,
"quantity": 1
}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
return response.json()
And the same in JavaScript (Node.js):
async function plantTreeForOrder(orderId, customerEmail) {
const response = await fetch("https://app.thegoodapi.com/plant", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY_TEST",
"Content-Type": "application/json"
},
body: JSON.stringify({
event_type: "purchase",
reference_id: orderId,
customer_email: customerEmail,
quantity: 1
})
});
if (!response.ok) {
throw new Error(`GoodAPI error: ${response.status}`);
}
return response.json();
}
The response will include a confirmation ID that you can store in your database for impact reporting and customer-facing displays.
Handling Errors and Edge Cases
A few things worth accounting for in your integration:
Network failures: Wrap API calls in a try/catch and log failures. Consider a retry queue (using something like Bull in Node.js or Celery in Python) for failed requests so no impact events are permanently lost.
Duplicate prevention: If your order processing has retry logic, you may fire the same event twice. Use an idempotency key based on order ID to prevent duplicate plantings. Pass it as a header: Idempotency-Key: order_123.
Webhook verification: If GoodAPI sends webhooks to notify you of planting confirmations, verify the signature on incoming requests before processing them.
Graceful degradation: Your sustainability integration should never block your core checkout flow. Make the API call asynchronously, and if it fails, log it for retry later. The customer should never see an error because of a planting failure.
Switching to Production
Once your integration is tested and working in sandbox mode, swap your api_key_test for api_key_prod and you are live. A few final checks before you flip:
- Confirm your error logging and retry logic is in place
- Set up a monitoring alert for sustained error rates from the GoodAPI endpoint
- Review your impact data model — decide where you will store confirmation IDs and how you will surface impact metrics to users or internal dashboards
Surfacing Impact to Your Users
This is where the real business value shows up. Customers who can see their environmental impact are more likely to return and recommend your brand. A few patterns that work well:
Post-purchase confirmation: Show a message on the order confirmation page: “We just planted a tree on your behalf. You have now contributed to planting [X] trees through your purchases.”
Account impact dashboard: Track cumulative impact per customer. Display it in their account area: “Your purchases have planted 12 trees and removed 3 kg of ocean plastic.”
Email confirmation: Include a planting confirmation in your transactional emails with a link to geo-tagged proof from the partner project.
Shareable impact badge: Give customers a shareable badge or certificate they can post on social media. This is organic marketing with a sustainability angle.
All of this data comes from the API. You are not maintaining any of it manually.
Beyond Tree Planting: Plastic Removal and More
GoodAPI supports more than tree planting. You can also trigger ocean-bound plastic removal through the same API, making it possible to offer a dual impact program. For example: plant one tree and remove 1 kg of plastic for every purchase above $100. This kind of layered program is easy to configure with API parameters and creates a compelling story for sustainability-focused customers.
Plastic removal is a particularly powerful differentiator because it is less commoditized than carbon offsets. Competitors like EcoCart focus heavily on the carbon-neutral-shipping angle. By adding plastic removal to your integration, you are offering something distinct that plays well with ocean-conscious consumer segments.
Why This Matters Beyond Marketing
There is a tendency to view sustainability integrations as a marketing checkbox. And yes, they help conversion and retention. But the underlying infrastructure you are building also sets your organization up for future ESG reporting requirements.
In many markets, particularly for larger companies operating in the EU, sustainability reporting is becoming mandatory. When your impact data flows through a verified API from the start, you have auditable, structured records rather than spreadsheet estimates. That is genuinely useful as regulatory expectations increase.
For smaller businesses and startups, building this in now is much cheaper than retrofitting it later.
Getting Started
If you are building on Shopify, Squarespace, BigCommerce, or any custom stack, GoodAPI has integration options for all of them. The API itself is platform-agnostic — if you can make an HTTP request, you can plant trees.
The team at GoodAPI is developer-friendly and handles onboarding directly. You can have your first test integration running in under an hour. With 3.3 million trees already planted through 2,000+ merchants, the infrastructure is proven at scale.
Sustainability does not have to be a separate workflow. Build it into your core product and it becomes part of who you are as a company — not just something you report on once a year.
Ready to add real environmental impact to your application? Get started with GoodAPI today.