Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with Pinterest Ads

To integrate Lovable with Pinterest Ads, create a Supabase Edge Function that proxies Pinterest Marketing API calls using OAuth2 credentials stored in Cloud → Secrets. The API provides campaign management, pin creatives, shopping catalog integration, and conversion analytics. Use Lovable's chat to build visual ad dashboards, catalog-linked campaign trackers, and Pinterest shopping performance reports.

What you'll learn

  • How to create a Pinterest developer application and obtain Marketing API OAuth credentials
  • How to store Pinterest credentials securely in Cloud → Secrets
  • How to create an Edge Function that proxies Pinterest Marketing API calls
  • How to build visual ad campaign dashboards with shopping catalog integration in Lovable
  • How Pinterest's visual discovery model differs from video-first platforms like TikTok
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate11 min read50 minutesSocialMarch 2026RapidDev Engineering Team
TL;DR

To integrate Lovable with Pinterest Ads, create a Supabase Edge Function that proxies Pinterest Marketing API calls using OAuth2 credentials stored in Cloud → Secrets. The API provides campaign management, pin creatives, shopping catalog integration, and conversion analytics. Use Lovable's chat to build visual ad dashboards, catalog-linked campaign trackers, and Pinterest shopping performance reports.

Build Pinterest visual ad campaign dashboards and shopping catalog tools in Lovable

Pinterest's Marketing API provides programmatic access to the full Pinterest advertising stack: campaigns, ad groups, promoted pins, shopping catalogs, conversion tags, and performance analytics. Pinterest's advertising model is built around visual discovery — users browse Pinterest actively looking for inspiration and products to purchase, which gives Pinterest advertisers access to an audience with higher purchase intent than entertainment-focused platforms.

The shopping catalog integration is Pinterest's most distinctive advertising capability. Products from an e-commerce catalog are ingested into Pinterest as product pins, automatically displayed in relevant searches and feeds, and can be promoted through Shopping Ads. The Marketing API gives programmatic control over catalog management: uploading product feeds, updating product data, and creating catalog-linked campaigns that automatically generate pins from your product catalog.

Pinterest's audience skews toward home decor, fashion, food, beauty, and DIY — categories where visual inspiration directly influences purchase decisions. For brands in these categories, Pinterest Ads often deliver better ROI than platforms where ads interrupt content rather than blend with it. Dashboards built in Lovable for Pinterest should surface the metrics that matter most in this context: saves (long-term intent signal), link clicks, outbound click rate, and ROAS for shopping campaigns.

Pinterest differs from TikTok in both content format and audience mindset. TikTok is entertainment-first with ads as interruptions between videos. Pinterest is discovery-first with ads as content — users actively search for ideas and products, making the ad experience feel less intrusive.

Integration method

Edge Function Integration

Pinterest Marketing API uses OAuth2 for authentication and provides REST endpoints for campaign management, creative pins, catalog integration, and analytics. OAuth tokens authorize advertising spend, so they must stay server-side. All Pinterest Marketing API calls are proxied through a Supabase Edge Function with credentials stored in Cloud → Secrets.

Prerequisites

  • A Lovable account with a project that has Lovable Cloud enabled
  • A Pinterest business account with an active Pinterest Ads account
  • A Pinterest developer application registered at developers.pinterest.com
  • OAuth2 client credentials (client ID and client secret) with Marketing API access approved
  • An OAuth2 access token with ads:read and ads:write scopes for your ad account

Step-by-step guide

1

Register a Pinterest developer application and request Marketing API access

Navigate to developers.pinterest.com and sign in with your Pinterest account. Click 'Connect app'. Fill in the app name, description, and redirect URI. Set your redirect URI to your deployed Lovable app URL followed by /auth/pinterest/callback. After creating the app, you will see a Client ID and App Secret. Under 'Permissions', request the ads_read and ads_write scopes. Pinterest's Marketing API requires separate approval — look for the 'Apply for Pinterest Marketing Partners' or 'Request API Access' option in the app settings. Pinterest reviews these requests and may require evidence of an active advertising account. Once approved, generate an access token by directing users to Pinterest's OAuth authorization URL: https://www.pinterest.com/oauth/?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=ads:read,ads:write&state=random_string After authorization, exchange the code for a token at https://api.pinterest.com/v5/oauth/token. Pinterest access tokens have a defined expiry (typically 30 days) and include a refresh token. Your ad account ID is required for all Marketing API calls. Find it in Pinterest Ads Manager — it is the numeric string in the URL when viewing your campaigns.

Pro tip: Pinterest access tokens expire after 30 days. Store the refresh token and implement automatic token refresh in the Edge Function to prevent credential expiry from causing outages in your dashboard.

Expected result: You have a Pinterest Client ID, App Secret, access token (30-day), refresh token, and your numeric ad account ID.

2

Store Pinterest credentials in Cloud → Secrets

Open your Lovable project and navigate to Cloud → Secrets via the '+' icon next to Preview. Add the following secrets: - Name: PINTEREST_ACCESS_TOKEN — Value: your OAuth2 access token - Name: PINTEREST_REFRESH_TOKEN — Value: your OAuth2 refresh token - Name: PINTEREST_CLIENT_ID — Value: your Pinterest application Client ID - Name: PINTEREST_CLIENT_SECRET — Value: your Pinterest application App Secret - Name: PINTEREST_AD_ACCOUNT_ID — Value: your numeric Pinterest ad account ID The access token authorizes advertising spend management. The client credentials and refresh token enable automatic renewal. The ad account ID scopes all API calls to your specific advertising account. Never paste Pinterest advertising credentials in Lovable's chat. Lovable's security system blocks approximately 1,200 hardcoded API keys per day, but credentials that control advertising spend deserve extra caution.

Expected result: All five Pinterest Ads secrets appear in Cloud → Secrets with masked values.

3

Create the Pinterest Marketing API proxy Edge Function

Create a Supabase Edge Function that proxies Pinterest Marketing API v5 calls. Pinterest's API base URL is https://api.pinterest.com/v5/ and all requests use Authorization: Bearer {token}. The function handles four core actions: campaigns (list campaigns for the ad account), ad_groups (list ad groups with targeting details), analytics (fetch campaign or ad-level performance metrics), and catalog (retrieve catalog feed status and product counts). Pinterest's v5 analytics endpoint is different from v3 — it requires a POST body rather than query parameters for metric selection. The function handles both GET requests (campaigns, ad_groups) and POST requests (analytics) correctly.

Lovable Prompt

Create a Supabase Edge Function at supabase/functions/pinterest-ads/index.ts. Accept POST requests with 'action' (campaigns | ad_groups | analytics | pins | update_campaign) and 'params'. Use PINTEREST_ACCESS_TOKEN as Bearer auth for https://api.pinterest.com/v5/. For 'campaigns': GET /ad_accounts/{PINTEREST_AD_ACCOUNT_ID}/campaigns?entity_statuses=ACTIVE,PAUSED. For 'analytics': GET /ad_accounts/{id}/campaigns/analytics with date and metric params. For 'update_campaign': PATCH /ad_accounts/{id}/campaigns with campaign updates. Include CORS headers.

Paste this in Lovable chat

supabase/functions/pinterest-ads/index.ts
1// supabase/functions/pinterest-ads/index.ts
2const PINTEREST_BASE = 'https://api.pinterest.com/v5';
3
4Deno.serve(async (req) => {
5 if (req.method === 'OPTIONS') {
6 return new Response(null, {
7 headers: {
8 'Access-Control-Allow-Origin': '*',
9 'Access-Control-Allow-Methods': 'POST, OPTIONS',
10 'Access-Control-Allow-Headers': 'Content-Type, Authorization',
11 },
12 });
13 }
14
15 const accessToken = Deno.env.get('PINTEREST_ACCESS_TOKEN');
16 const adAccountId = Deno.env.get('PINTEREST_AD_ACCOUNT_ID');
17
18 if (!accessToken || !adAccountId) {
19 return new Response(JSON.stringify({ error: 'Pinterest credentials not configured' }), {
20 status: 500,
21 headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' },
22 });
23 }
24
25 const headers = { 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json' };
26 const { action, params } = await req.json();
27
28 let url: string;
29 let fetchOptions: RequestInit;
30
31 if (action === 'campaigns') {
32 url = `${PINTEREST_BASE}/ad_accounts/${adAccountId}/campaigns?entity_statuses=ACTIVE,PAUSED,ARCHIVED&page_size=100`;
33 fetchOptions = { method: 'GET', headers };
34 } else if (action === 'ad_groups') {
35 url = `${PINTEREST_BASE}/ad_accounts/${adAccountId}/ad_groups?campaign_id=${params.campaign_id}&page_size=100`;
36 fetchOptions = { method: 'GET', headers };
37 } else if (action === 'analytics') {
38 const q = new URLSearchParams({
39 start_date: params.start_date,
40 end_date: params.end_date,
41 columns: (params.metrics || ['SPEND_IN_DOLLAR', 'IMPRESSION_1', 'CLICKTHROUGH_1', 'SAVE', 'TOTAL_CONVERSIONS']).join(','),
42 granularity: params.granularity || 'DAY',
43 });
44 if (params.campaign_ids) q.set('campaign_ids', params.campaign_ids.join(','));
45 url = `${PINTEREST_BASE}/ad_accounts/${adAccountId}/analytics?${q}`;
46 fetchOptions = { method: 'GET', headers };
47 } else if (action === 'update_campaign') {
48 url = `${PINTEREST_BASE}/ad_accounts/${adAccountId}/campaigns`;
49 fetchOptions = { method: 'PATCH', headers, body: JSON.stringify([{ id: params.campaign_id, ...params.updates }]) };
50 } else {
51 return new Response(JSON.stringify({ error: 'Invalid action' }), {
52 status: 400,
53 headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' },
54 });
55 }
56
57 const response = await fetch(url, fetchOptions);
58 const data = await response.json();
59
60 return new Response(JSON.stringify(data), {
61 status: response.ok ? 200 : response.status,
62 headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' },
63 });
64});

Pro tip: Pinterest's analytics endpoint column names differ from other ad platforms — use 'IMPRESSION_1' (not 'impressions'), 'CLICKTHROUGH_1' (not 'clicks'), and 'SAVE' (not 'saves') when requesting metrics in the columns parameter.

Expected result: The pinterest-ads Edge Function is deployed. Calling it with { action: 'campaigns' } returns Pinterest campaigns with their status, objectives, and budget information.

4

Build the Pinterest Ads visual dashboard

Use Lovable's chat to build the Pinterest campaign performance dashboard. Pinterest advertising has a unique metric set that reflects the platform's save-and-return behavior: IMPRESSION_1 (impressions), CLICKTHROUGH_1 (link clicks), SAVE (pin saves — users saving your pin to their boards), SAVE_RATE (saves divided by impressions), VIDEO_V_50_WATCH_TIME (for video pins), and TOTAL_CONVERSIONS for purchase tracking. The save rate is a Pinterest-specific KPI worth highlighting prominently in your dashboard — a high save rate indicates content resonates with users who will return to it later, creating long-tail value beyond the initial impression. Build a metric card that shows save rate alongside CTR to give advertisers a complete picture of creative performance. For shopping catalog campaigns, add a catalog performance section that shows top-performing products by ROAS and revenue. Pinterest's Shopping Ads show individual product pins from the catalog, so ad-level performance maps directly to product performance. For the campaign management features, add a budget optimizer view that shows campaigns sorted by ROAS — highest performing campaigns at the top with a budget increase button. This surfaces actionable opportunities to reallocate budget toward the best-performing campaigns without requiring access to Pinterest Ads Manager.

Lovable Prompt

Build a Pinterest Ads dashboard with two sections: (1) Campaign overview table showing campaign name, status, objective, daily budget, spend, impressions, link clicks, saves, save rate, and ROAS from the pinterest-ads Edge Function analytics action — with date range picker and pause/resume toggle buttons; (2) Creative performance section showing promoted pins with their images, engagement metrics, and a save rate bar chart. Highlight the top 3 pins by save rate.

Paste this in Lovable chat

Expected result: A Pinterest Ads dashboard shows campaign metrics with Pinterest-specific metrics (saves, save rate) alongside standard metrics. The creative performance section shows pin thumbnails with their engagement data. Date range filtering updates the analytics data.

Common use cases

Shopping catalog campaign manager

Build a tool for e-commerce brands to manage Pinterest Shopping Ads from their Lovable product management interface. The tool syncs product catalog data to Pinterest, creates catalog-linked campaigns, and shows Shopping Ad performance by product category and SKU.

Lovable Prompt

Create a Pinterest Shopping Ads manager that calls the pinterest-ads Edge Function to fetch my ad account's campaigns filtered to shopping objective. Show campaign performance with spend, impressions, saves, link clicks, and ROAS. Add a 'Sync Catalog' button that calls the Edge Function to trigger a catalog feed refresh. Show the catalog status and last sync time.

Copy this prompt to try it in Lovable

Visual discovery ad performance dashboard

Build a performance dashboard that shows Pinterest campaign metrics with a focus on visual engagement: pin saves, close-up rates, and video views alongside standard CTR and conversion data. The dashboard compares creative performance across pin formats (static image, carousel, video, shopping).

Lovable Prompt

Build a Pinterest Ads dashboard with a campaign overview table showing spend, impressions, clicks, saves, save rate, outbound CTR, and conversions for each campaign. Add a creative performance section that shows each promoted pin's thumbnail with its engagement rate, save rate, and cost per result. Allow filtering by date range and campaign objective.

Copy this prompt to try it in Lovable

Audience and interest targeting analyzer

Create a targeting analysis tool that shows which audiences and interest categories are driving the best performance across Pinterest campaigns. The tool aggregates demographic and interest breakdowns from Pinterest's analytics and surfaces high-performing targeting segments for expansion.

Lovable Prompt

Build a targeting analyzer that calls the pinterest-ads Edge Function to fetch audience analytics for my campaigns broken down by interest category and device type. Display a bar chart ranking interest categories by ROAS. Show demographic breakdowns by gender and age group. Store the analytics in Supabase for weekly trend comparison.

Copy this prompt to try it in Lovable

Troubleshooting

API returns 401 with 'Expired access token' or 'Invalid token'

Cause: The Pinterest access token in PINTEREST_ACCESS_TOKEN has expired (tokens last 30 days) or was revoked.

Solution: Use the stored refresh token to obtain a new access token. POST to https://api.pinterest.com/v5/oauth/token with grant_type=refresh_token, your refresh_token, client_id, and client_secret. Update PINTEREST_ACCESS_TOKEN in Cloud → Secrets with the new token.

Analytics endpoint returns empty items array for active campaigns

Cause: The date range requested does not overlap with the campaign's active period, the column metric names are incorrect, or the granularity parameter is not valid.

Solution: Verify that the start_date and end_date are in YYYY-MM-DD format and overlap with when the campaign was running. Check that column names use Pinterest's exact metric identifiers (IMPRESSION_1 not 'impressions', CLICKTHROUGH_1 not 'clicks'). Also confirm the granularity is 'TOTAL', 'DAY', 'HOUR', 'WEEK', or 'MONTH' — invalid values cause empty responses.

Campaign update PATCH request returns 422 with 'Invalid campaign status transition'

Cause: Pinterest's campaign status updates follow specific allowed transitions. For example, you cannot transition directly from ARCHIVED to ACTIVE — you must go through PAUSED first.

Solution: Check the current campaign status before attempting an update. Pinterest allows ACTIVE → PAUSED and PAUSED → ACTIVE transitions. ARCHIVED campaigns cannot be reactivated — create a new campaign instead. Update your dashboard's pause/resume logic to check current status and only offer valid transitions.

Best practices

  • Store all Pinterest credentials in Cloud → Secrets — the access token authorizes advertising spend on campaigns potentially connected to e-commerce revenue
  • Implement token refresh using the stored PINTEREST_REFRESH_TOKEN since access tokens expire after 30 days
  • Use Pinterest-specific metric names in analytics requests: IMPRESSION_1, CLICKTHROUGH_1, SAVE, SAVE_RATE — standard names like 'impressions' will return empty data
  • Surface save rate as a primary KPI in your Pinterest dashboard — it is a leading indicator of content resonance unique to Pinterest that other ad platforms do not provide
  • Cache campaign analytics in Supabase with appropriate TTL — Pinterest reporting has a lag and live queries add latency without providing more current data
  • For shopping campaigns, surface product-level ROAS data alongside campaign-level metrics — Shopping Ads performance is driven by individual product quality, not just targeting
  • Test analytics with a TOTAL granularity before implementing day-by-day breakdowns — total aggregation is simpler to validate and confirms the API connection is working before adding time-series complexity

Alternatives

Frequently asked questions

What makes Pinterest Ads different from other social advertising platforms?

Pinterest's key differentiator is purchase intent: users search Pinterest actively looking for ideas, products, and inspiration — they are often in a planning or shopping mindset rather than passive entertainment consumption. This makes Pinterest ads feel less intrusive and often delivers better ROAS for e-commerce categories like home decor, fashion, food, beauty, and DIY. The save metric is unique to Pinterest — when users save a pin to a board, it creates ongoing visibility as others browse those boards, providing long-tail reach beyond the initial ad impression.

What is the Pinterest Shopping Catalog integration?

Pinterest Shopping Ads use product data from an e-commerce catalog ingested into Pinterest. When you upload a product feed (a CSV or XML file with product titles, images, prices, and URLs), Pinterest creates product pins automatically. Shopping campaigns target users based on their search behavior and browsing history, showing them relevant products from your catalog as promoted pins. The Marketing API lets you upload and update catalog feeds programmatically, query product catalog status, and create catalog-linked campaigns.

How long do Pinterest Marketing API access tokens last?

Pinterest access tokens expire after 30 days. Refresh tokens are also provided and allow obtaining new access tokens without user re-authorization. Implement the refresh token flow in your Edge Function to avoid dashboard outages when tokens expire. After the refresh token also expires (typically 30-60 days after the access token), you will need to re-authorize the application by going through the OAuth2 flow again.

Does Pinterest Marketing API access require special approval?

Pinterest's Marketing API access is available through the developer portal but may require additional approval for advertising features. Basic API access (reading organic Pinterest content) is self-serve. The Marketing API (campaigns, ads, analytics) requires a review process. Having an active Pinterest Ads account with spending history significantly improves approval chances. Contact Pinterest's developer support if you are not getting access after initial application.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.