LinkedIn API Post Automation: Google Sheets Example
Learn how to automate your LinkedIn API post workflow using Google Sheets and Apps Script. Schedule posts to personal profiles and company pages with ease.
If you want to trigger a linkedin api post automatically without paying for expensive automation middleware, connecting a simple Google Sheet directly to Foxli is the easiest way. I built this workflow because copy-pasting post drafts from documents into social schedulers wastes hours every week. With Google Apps Script and Foxli, you can write your updates in a spreadsheet with your team, mark rows as ready, and let a small script schedule them to LinkedIn personal profiles or company pages.
Spreadsheets are where most teams draft their content. Marketing managers, founders, and ghostwriters already know how to review copy in rows and columns. By connecting Google Sheets to Foxli, your content pipeline runs on free built-in tools. You avoid paying monthly per-task fees to middleware tools, and you keep a clear audit log of every post right inside your spreadsheet.
Why Build Your Content Pipeline on Google Sheets?
Most marketing teams draft their LinkedIn posts in docs or spreadsheets anyway. Adding another software tool just to schedule those drafts introduces unnecessary friction.
Connecting your spreadsheet directly to the Foxli Developers Portal gives you several practical benefits:
- Zero recurring middleware costs: Platforms like Zapier or Make charge per operation. If you schedule twenty posts a month with retries and status checks, your monthly bill quickly jumps. Google Apps Script is free on any Google account.
- Support for personal profiles and company pages: The official LinkedIn Share API treats personal member profiles and organization company pages differently. Foxli gives both types clean channel IDs (
ch_li_...), so you can target either profile simply by changing a cell in your sheet. - Clean audit trails: When the script runs, it writes back the confirmed Foxli Post ID and status directly into your sheet. You can see at a glance what has been scheduled and what still needs review.
Sheet Architecture: Column Structure
To make your spreadsheet easy to parse with Apps Script, set up your columns in Row 1 like this:
| Column | Header | Description | Example Value |
|---|---|---|---|
| A | Row_ID | Unique key used for request idempotency | LI-2026-081 |
| B | Scheduled_Time_IST | Publication time in Indian Standard Time | 2026-11-20 10:30 |
| C | Content | Post copy (LinkedIn supports up to 3,000 chars) | 3 principles for building software in India... |
| D | Channel_ID | Your LinkedIn channel ID from Foxli | ch_li_corp_page_01 |
| E | Media_URL | Optional public URL of an image asset | https://cdn.example.com/charts/retention.png |
| F | Status | Processing trigger (READY to SCHEDULED) | READY |
| G | Post_ID | Populated by script upon successful dispatch | pst_9a81f3c |
You can find your LinkedIn channel ID (ch_li_...) in the Foxli dashboard under Channels, or by making a quick call to GET /v1/channels.
How to Execute a LinkedIn API Post From Google Sheets
Google Apps Script includes a native HTTP service called UrlFetchApp. By storing your API key securely and looping through rows marked READY, you can send posts to Foxli with full error handling.
Step 1: Secure Your API Key in Script Properties
Do not write your API key directly into spreadsheet cells where someone could accidentally share it. Use Apps Script script properties instead:
- In your Google Sheet, open Extensions → Apps Script.
- Click the gear icon on the left menu (Project Settings).
- Scroll down to Script Properties and click Edit script properties.
- Add two properties:
FOXLI_API_KEY: Your Bearer token (fx_live_...)FOXLI_WORKSPACE_ID: Your workspace identifier (ws_...)
- Click Save script properties.
Step 2: The Google Apps Script Code
Open Code.gs in the editor and paste the following script:
/**
* Automates LinkedIn post scheduling from Google Sheets using the Foxli REST API.
*/
function scheduleLinkedInPostsFromSheet() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues();
const properties = PropertiesService.getScriptProperties();
const apiKey = properties.getProperty('FOXLI_API_KEY');
const workspaceId = properties.getProperty('FOXLI_WORKSPACE_ID');
if (!apiKey || !workspaceId) {
SpreadsheetApp.getUi().alert('Error: FOXLI_API_KEY or FOXLI_WORKSPACE_ID is missing in Script Properties.');
return;
}
// Iterate through rows (skipping header in Row 0)
for (let i = 1; i < data.length; i++) {
const row = data[i];
const rowId = row[0];
const timeIST = row[1];
const content = row[2];
const channelId = row[3];
const mediaUrl = row[4];
const status = row[5];
// Only process rows marked READY
if (status === 'READY') {
try {
// Convert IST string into ISO-8601 UTC timestamp
const utcDateString = convertISTtoUTC(timeIST);
const payload = {
mode: 'schedule',
scheduled_at: utcDateString,
channel_ids: [channelId],
content: content,
media_urls: mediaUrl ? [mediaUrl] : []
};
const options = {
method: 'post',
contentType: 'application/json',
headers: {
'Authorization': 'Bearer ' + apiKey,
'Foxli-Workspace': workspaceId,
'Idempotency-Key': 'sheet-' + rowId
},
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
const response = UrlFetchApp.fetch('https://api.foxli.app/v1/posts', options);
const responseCode = response.getResponseCode();
const responseBody = JSON.parse(response.getContentText());
if (responseCode === 200 || responseCode === 201) {
sheet.getRange(i + 1, 6).setValue('SCHEDULED');
sheet.getRange(i + 1, 7).setValue(responseBody.id);
} else {
sheet.getRange(i + 1, 6).setValue('ERROR: ' + (responseBody.message || responseCode));
}
} catch (err) {
sheet.getRange(i + 1, 6).setValue('FAILED: ' + err.message);
}
}
}
}
/**
* Converts Indian Standard Time (IST) strings to ISO-8601 UTC strings.
*/
function convertISTtoUTC(istString) {
const istDate = new Date(istString);
// Subtract 5.5 hours (19,800,000 milliseconds) to convert IST to UTC
const utcDate = new Date(istDate.getTime() - (5.5 * 60 * 60 * 1000));
return utcDate.toISOString();
}
/**
* Adds a custom menu item to Google Sheets UI for easy one-click scheduling.
*/
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('Foxli Publishing')
.addItem('Schedule Ready LinkedIn Posts', 'scheduleLinkedInPostsFromSheet')
.addToUi();
}
Step 3: Triggering Posts With a Click or a Timer
Once you save the code and refresh your sheet, a menu titled Foxli Publishing appears in your Google Sheets toolbar. When your team finishes reviewing copy, click Schedule Ready LinkedIn Posts to send the updates to Foxli.
If you want the sheet to process itself automatically, you can set up a time trigger:
- In the Apps Script sidebar, click the clock icon (Triggers).
- Click Add Trigger.
- Select
scheduleLinkedInPostsFromSheetas the target function. - Set the event source to Time-driven and pick an hourly timer, such as every 2 hours.
The script will periodically check your sheet, schedule any row marked READY, and write the post ID back to column G.
Formatting Guidelines for LinkedIn Posts
When writing text for LinkedIn, keep these platform practices in mind:
Character limits: LinkedIn allows up to 3,000 characters per post. Readers usually see the first two to three lines before clicking "see more", so put your core point or hook right at the beginning.
Images and graphics: A 1.91:1 landscape image (1200x627) or a 1:1 square image (1080x1080) works best on both mobile and desktop screens. Make sure your graphics are legible on mobile devices.
Hashtags: Use 3 to 5 relevant hashtags at the bottom of the post. Avoid using dozens of generic tags, which can trigger spam filters and reduce reach.
Using the Foxli Publishing Queue
If you do not want to set exact posting times for every row, change "mode": "schedule" to "mode": "queue" in your script payload.
Foxli's LinkedIn scheduler queue assigns the post to your next configured time slot. You can paste ten approved drafts into your sheet at once, and Foxli will space them out across your weekly publishing slots automatically.
Google Sheets and Foxli Versus Traditional Middleware
Here is how using Google Sheets with Foxli compares to traditional automation tools:
| Feature | Middleware Services | Google Sheets with Foxli REST API |
|---|---|---|
| Monthly Cost for 100 Posts | Per-task fees that rise with volume | Flat ₹99 per channel (included in Foxli) |
| Multi-Network Support | Complex multi-step branching logic | Single payload for up to 7 networks |
| Token Management | Disconnections requiring regular re-auth | Automatic server-side token rotation |
| Rate Limits | Fails when monthly task quotas run out | 120 requests per minute with idempotency |
| Team Collaboration | Requires extra logins to automation tools | Native Google Sheets sharing and permissions |
For boutique marketing teams and agency partners, managing client calendars with solutions for teams and solutions for agencies keeps operations straightforward and predictable.
Handling Errors and Apps Script Limits
When running scripts in Google Sheets, keep these common situations in mind:
UrlFetchApp daily quotas: Free personal Google accounts get 20,000 fetch calls per day, and Google Workspace accounts get 100,000. Because our script makes only one call per ready row, you will not hit these limits under normal publishing volumes.
Duplicate content errors: LinkedIn rejects updates that have the exact same text as a post published within the previous 24 hours. Make sure each row in your sheet has unique content.
Token renewal notices: If an account owner changes their LinkedIn password, the access token is revoked. If your script reports a 401 Unauthorized status, visit your Foxli dashboard to reconnect the channel.
Execution timeouts: Google Apps Script has a 6-minute execution limit per run. If you have over 100 rows marked READY, process them in smaller batches or run the script on an hourly trigger with a row limit.
Indian B2B Workflows: IST Timings and Razorpay Invoicing
LinkedIn in India is the primary network for founders, agency owners, and tech leaders:
- Indian Standard Time (IST) posting slots: Peak engagement on LinkedIn India happens between 8:30 AM and 10:15 AM IST during morning commutes, and between 5:00 PM and 6:30 PM IST as the workday wraps up. Converting these times to UTC ensures your posts appear when decision-makers are scrolling.
- Managing multiple clients: Agencies handling executive branding can create separate workspaces for each client. You can pass the workspace ID in script properties or a sheet column to keep client accounts separated.
- Local payment options: Pay in INR at ₹99 per channel per month using UPI, NetBanking, and domestic corporate credit cards through Razorpay. You avoid international transaction fees and foreign currency hassles.
Transparent Pricing Without Hidden Usage Fees
Foxli pricing is simple and based on connected channels on the Foxli Pricing page:
- Free Plan: Up to 3 channels across 1 workspace at zero cost.
- Creator Plan: ₹99 per channel per month (or $0.99 USD), with full REST API access, 120 requests per minute, and unlimited scheduled posts.
- Team Plan: ₹119 per channel per month (or $1.19 USD), adding post approvals and team collaboration.
Using Google Sheets and Foxli gives you a flexible, low-cost way to schedule LinkedIn posts from your existing spreadsheets. Connect your accounts, add the script to your sheet, and start scheduling your updates today.




