Skip to content
Tutorials Center
My learning

Topics

Lesson 22 of 36 ยท Webhooks and APIs

API Authentication, Pagination and Rate Limits

Read an API's documentation and translate it into Zapier steps: API keys, bearer tokens, OAuth, paging through results, rate limits and idempotency.

Calling an API from a no-code tool is mostly reading documentation carefully. Three topics decide whether your automation works on day one and keeps working: how you prove who you are (authentication), how you get more than the first page of results (pagination), and how fast you may call (rate limits). This lesson turns each into concrete settings and checks.

The examples are JavaScript stand-ins: they run on this page without a network and mimic the logic you would set up with Webhooks by Zapier, Make or n8n steps. They are not part of any of those products.

Authentication: proving who you are

Most APIs use one of four schemes. The API documentation names the one you must use, usually in a section called "Authentication".

Scheme What you send Where it goes in a Zapier webhook step
API key in a header X-Api-Key: abc123 Headers field
Bearer token Authorization: Bearer <token> Headers field
HTTP Basic username and password (or key and blank) Basic Auth field (username, a pipe character, then password)
API key in the URL ?api_key=abc123 Query string params (least safe: URLs get logged)
OAuth 2 a short-lived access token obtained after a user consents Use the built-in app connection; a raw webhook cannot refresh tokens for you

OAuth deserves a closer look. In OAuth the user logs in at the provider and approves access. You receive an access token that expires (often after an hour) and a refresh token used to get a new one. Zapier's built-in apps do this for you. If you call an OAuth-only API with a raw webhook, you must store the token yourself and renew it, which is fragile. Options: use the app's built-in integration, use a long-lived personal access token if the provider offers one, or make a small refresh step that calls the token endpoint first.

Pasting a key straight into a step makes it visible to everyone who can edit the Zap. Prefer a connection or a shared secret store where your plan has one, and rotate keys when people leave. More in Security and Access Control.

The stand-in below checks that a prepared request has what the API requires, the sort of review you should do before pressing Test.

JS Stand-in: a pre-flight check for API auth

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Pagination: getting all the results

An API that lists records will not return a million rows in one answer. It returns a page and tells you how to get the next. Three styles are common:

  1. Page number: ?page=1, ?page=2, until a page comes back empty.
  2. Offset and limit: ?offset=0&limit=100, then offset=100.
  3. Cursor (or "next token"): each response contains next_cursor; you pass it in the next call, and the last page has no cursor. Cursors are more reliable when data changes during the loop.

In Zapier a webhook step makes one call. To read more than one page you have three practical choices: use a built-in integration (which already pages through results), keep the page small and process only new records each time (the polling approach: ask for created_after=<last time> or sort by newest and stop at the first id you have seen), or use a Code step that loops through pages within its time limit. In Make you would use a repeater or an iterator; in n8n the HTTP Request node has a built-in pagination option. The stand-in below shows the cursor loop that all of them implement.

JS Stand-in: follow a cursor to read every page

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice the safety limit. A loop without a maximum can run forever if the API misbehaves, and every call may cost a task.

Rate limits and the 429 answer

Providers limit how many requests you may make, for example 10 per second or 1,000 per day, and answer 429 Too Many Requests when you exceed it. Often a Retry-After header says how many seconds to wait. Ways to stay inside the limit in an automation:

  • Do not call per row when one batch endpoint exists.
  • Add a Delay step, or in Make a sleep module, between loop passes.
  • Spread work out: a Digest collects events and sends them once.
  • Retry with growing waits (1 s, 2 s, 4 s...), called exponential backoff, and add a little random jitter so many runs do not retry together.
JS Stand-in: exponential backoff schedule

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Idempotency: making a retry safe

If a call times out you cannot know whether it was processed. Retrying a plain POST can create a duplicate (two invoices, two welcome emails). Many APIs accept an idempotency key: a unique value (say the order id) sent in a header; the server returns the original result if it sees the same key again. If the API has none, make the operation safe yourself: look the record up first, or keep an "already processed" list in a Table (Tables Lookup and Dedupe).

Reading API documentation, step by step

  1. Find Authentication and note the scheme and where credentials are created.
  2. Find the endpoint for your action; note the method, URL, required fields and example body.
  3. Find the response example; note the id field you will need later.
  4. Find errors and rate limits.
  5. Test the call in a neutral API client first. Once it works there, copy exactly that request into the automation step.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is a raw webhook step a poor fit for an OAuth-only API?

    Access tokens expire. Built-in app connections refresh them for you; a raw call does not.
  2. 2. What is the main advantage of cursor pagination over page numbers?

    A cursor marks a position in the data, so inserted or deleted rows do not shift your pages.
  3. 3. Which technique makes a retried POST safe?

    An idempotency key or a pre-check lets the second attempt do nothing if the first one worked.
  4. 4. Why keep a maximum page count in a paging loop?

    A misbehaving API could return a next page forever. A limit protects your plan.

Summary

  • Match the scheme in the documentation: key header, bearer token, Basic or OAuth; always use HTTPS.
  • OAuth needs refreshing, so prefer built-in app connections.
  • Page by number, offset or cursor, with a hard maximum, or process only new records.
  • Respect 429: batch, delay, back off exponentially.
  • Make retries safe with idempotency keys or lookups.

Next: Zapier Tables Basics