# Connect to the Asana API from Google Sheets: a script that pages and retries

Connect to the Asana API in Google Sheets with Apps Script: a personal access token, a paged read of one project, a 429 retry, and when to skip the code.

## Key takeaways

- You can read Asana from Google Sheets with about 40 lines of Apps Script, a personal access token and the project's ID.
- Always send limit=100 and follow next_page, or a project over about 1,000 tasks can come back cut short.
- A 429 reply carries a Retry-After header in seconds, and the script should sleep exactly that long.
- The script reads Asana into the sheet only, once per run, and it needs a trigger and an owner to keep going.
- A project of 2,000 tasks needs at least 20 requests at 100 a page, before any subtask or field lookups.

You want your Asana tasks in a Google Sheets™ tab, and you'd rather call the API yourself than export a CSV every Monday. That's a fair call. The Asana API is clean, and Apps Script runs inside the sheet, so there's nothing to host.

Below is a script for a real project: it reads every task, follows the pages, and waits when Asana says to wait. I also mark where a script like this stops being worth your time. The API details come from Asana's pagination and rate limits pages, read on 30 November 2026.

## The short answer

To connect to the Asana API from Google Sheets, create a personal access token in the Asana developer console, store it in Apps Script's script properties, and call `https://app.asana.com/api/1.0/projects/<project ID>/tasks` with `UrlFetchApp`. Send the token as `Authorization: Bearer <token>`, ask for 100 tasks a page, and follow `next_page` until it's empty. Write the rows with `setValues` in one call.

## Before the first line of code

1. **A personal access token.** Open the [Asana developer console](https://app.asana.com/0/my-apps), create a token and copy it once. Treat it like a password: it acts as you, with your access.
2. **The project's ID.** Open the project in Asana. The long number after `/project/` in the address bar is the ID.
3. **A sheet to write into.** In it, open Extensions, then Apps Script.

In Apps Script, open Project Settings and add 2 script properties: `ASANA_TOKEN` and `PROJECT_GID`. Don't paste the token into the code. Anyone you share the script with sees its code and can't see the properties.

## The script

Paste this into the Apps Script editor and run `importAsanaProject`. Google asks you to approve access to the spreadsheet and to external requests the first time.

```js
const BASE = "https://app.asana.com/api/1.0";
const FIELDS = "name,completed,due_on,assignee.name,memberships.section.name";

function importAsanaProject() {
  const props = PropertiesService.getScriptProperties();
  const token = props.getProperty("ASANA_TOKEN");
  const projectGid = props.getProperty("PROJECT_GID");

  const rows = [["Task", "Done", "Due", "Assignee", "Section"]];
  let url = `${BASE}/projects/${projectGid}/tasks?limit=100&opt_fields=${encodeURIComponent(FIELDS)}`;

  while (url) {
    const body = fetchWithRetry(url, token);
    body.data.forEach((t) => {
      rows.push([
        t.name,
        t.completed,
        t.due_on || "",
        t.assignee ? t.assignee.name : "",
        t.memberships && t.memberships[0] && t.memberships[0].section
          ? t.memberships[0].section.name
          : "",
      ]);
    });
    url = body.next_page ? body.next_page.uri : null;
  }

  const sheet = SpreadsheetApp.getActiveSheet();
  sheet.clearContents();
  sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows);
}

function fetchWithRetry(url, token) {
  for (let attempt = 0; attempt < 5; attempt++) {
    const res = UrlFetchApp.fetch(url, {
      headers: { Authorization: `Bearer ${token}` },
      muteHttpExceptions: true,
    });
    const code = res.getResponseCode();
    if (code === 200) return JSON.parse(res.getContentText());
    if (code === 429) {
      const headers = res.getHeaders();
      const wait = Number(headers["Retry-After"] || headers["retry-after"] || 30);
      Utilities.sleep(wait * 1000);
      continue;
    }
    throw new Error(`Asana returned ${code}: ${res.getContentText()}`);
  }
  throw new Error("Still rate limited after 5 tries");
}
```

I ran the paging and retry logic against a stub of `UrlFetchApp`: a 429 with `Retry-After: 7` made it sleep 7 seconds, then it followed `next_page` to a second page and wrote both tasks. That checks the loop. It doesn't replace one run against your own project.

![Screenshot of a Google Sheet of synced Asana tasks with the Asana to Sheets sidebar open beside it, listing a Website Relaunch project sync scheduled for 07:54 AM](/blog/images/asana-sheet-with-sidebar.png)

## Paging, fields and the retry

`limit=100` is on every call. Asana returns at most 100 objects a page. Without `limit`, some older endpoints return everything in one go. They can time out or truncate a big project. With it, you get a `next_page` object holding the `uri` of the next call, or `null` when you're done. Follow the `uri` as it comes. Offsets expire, so don't store one for tomorrow.

`opt_fields` picks the columns. Asana's default reply is thin: an ID, a type and a name. You have to request anything else, such as the due date or the assignee's name. Dotted names reach into nested objects, so `assignee.name` works. Request only what the sheet shows, since bigger replies cost more of the budget.

The retry reads `Retry-After`. When you go over a limit, Asana answers `429 Too Many Requests` with a `Retry-After` header in seconds. Rejected requests still count against your quota, so waiting less than that makes the next window worse. The script sleeps exactly that long. Our post on [Asana API limits](/blog/asana-rate-limits) covers the 5 limits behind that reply, and which one you've probably hit.

A single `setValues` for the whole table is far faster than setting cells one at a time. Speed matters here because a single Apps Script run stops after 6 minutes.

## Gaps in this script

The first version is short because it skips the parts that cost time. Before you rely on it, know the gaps.

- **Subtasks.** `GET /projects/<ID>/tasks` returns top-level tasks only. Subtasks need one more call per parent task, which is where a free workspace's 150 requests a minute runs out. See [Asana subtasks in Google Sheets](/blog/asana-subtasks-in-google-sheets).
- **Custom fields.** Each one arrives as an object with a type, and a number, a select and a date all look different. Our post on [exporting Asana custom fields](/blog/asana-custom-fields-google-sheets) shows what each type needs.
- **Dates.** `due_on` is a plain date, and `due_at` is a time in UTC. Mixing them can shift a date by a day. See [Asana dates wrong in Google Sheets](/blog/asana-dates-wrong-in-google-sheets).
- **Running it again.** Nothing calls this on a schedule until you add a time-driven trigger. It runs as you, so if you leave the company, the token and the trigger go with you.
- **Writing back.** The script reads. Pushing a sheet edit into Asana is a separate job with its own rules.

## Script, no-code connector or add-on

| Option | You maintain | Handles paging and 429 | Subtasks and custom fields | Writes back to Asana |
| --- | --- | --- | --- | --- |
| Apps Script (this post) | The code, the token and the trigger | Yes, as written above | Only what you add | No |
| Automation platform, such as Zapier or Make | The scenario and its step count | Platform dependent | Per step, each billed | Yes, per step |
| Asana to Sheets add-on | Nothing | Yes | Yes, typed columns | Yes, on the Business plan |

If the sheet is a one-off, or you enjoy the code, the script is the cheapest route. If it has to run every week without you, the add-on is the same job with the 5 gaps above already handled. It pages through your project, waits when Asana asks and keeps subtasks and custom fields as columns. Our guide to [syncing Asana to Google Sheets](/blog/how-to-sync-asana-to-google-sheets) walks through setup.

## Frequently asked questions

### How do I connect Google Sheets to the Asana API?

Make a personal access token in the Asana developer console, store it as a script property in Apps Script, and call the API with `UrlFetchApp` and an `Authorization: Bearer` header. Then write the reply to the sheet with `setValues`.

### Do I need OAuth to read Asana from Google Sheets?

No. A personal access token is enough for a script that only you run. OAuth is for an app that acts for other people, as a published add-on does.

### Where do I find my Asana project ID?

Open the project in Asana and read the address bar. The long number after `/project/` is the ID.

### Why does my script only return part of a big project?

Usually the call has no `limit`, or it ignores `next_page`. Send `limit=100` and keep calling the `uri` in `next_page` until it's `null`.

### What does the Asana API return when I'm rate limited?

A `429 Too Many Requests` reply with a `Retry-After` header holding the seconds to wait. Sleep that long, then retry.

### Can an Apps Script keep my sheet up to date?

Yes, with a time-driven trigger on `importAsanaProject`. The trigger runs under your account, so the script stops working if your access or the token goes away.

### How many Asana requests does a project need?

At 100 tasks a page, a 2,000-task project needs at least 20 requests for the list alone. Subtasks, sections and custom fields add more, and a free workspace allows about 150 requests a minute.

## Next step

Want it without the maintenance? [Install Asana to Sheets](https://workspace.google.com/marketplace/app/asana_to_sheets/320852305872) from the Google Workspace Marketplace and sync your first project in a few minutes. The trial lasts 7 days, with up to 3 syncs and no card.

_Asana is a trademark of Asana, Inc. Google Sheets and Google Workspace are trademarks of Google LLC. Asana to Sheets has no affiliation with either, and neither endorses it._
