Skip to main content
The Zapier SDK and MCP code actions let users send their own requests to your app’s API, outside a Zap. Zapier authenticates each request with the user’s app connection and your integration’s authentication settings. Your trigger, search, and action code does not run.

What authentication outside Zaps is

In these requests, the user or their code writes the method, URL, query parameters, and body. Your integration contributes only one thing: how credentials are injected into a request.

How Zapier builds the request

Zapier first checks that the request uses an allowed host. It then applies your Request Template (requestTemplate) and beforeRequest middleware before it sends the request.

How Zapier uses authentication.test

Zapier inspects authentication.test to learn how credentials are applied to requests, and runs the test during a credential refresh.

Inspect the test to find credentials

Zapier reads authentication.test to find where your integration puts credentials. Zapier does not send the test request during inspection.
  • If authentication.test is a request object, Zapier reads its URL, headers, and parameters.
  • If authentication.test is a function, Zapier calls the function with network access blocked. Each request returns an empty response. Zapier keeps only the first request that the function makes.
If your connection test exchanges a key for a token first, Zapier captures the exchange request. It does not capture the later request that uses the token. Do the exchange in session authentication (sessionConfig.perform) or in the OAuth v2 getAccessToken and refreshAccessToken methods. The session or OAuth flow stores the token in bundle.authData. Your requestTemplate or beforeRequest can then add the token to every request.

Run the test during a credential refresh

When your API returns a 401, Zapier runs your connection test for real, with the user’s credentials. The test sends its request to your API. The order depends on the authentication type: If the test fails, Zapier returns an error to the caller and does not retry the user’s request. If the failure shows that the connection has expired, Zapier marks the app connection as expired and emails its owner.

What this means for your integration

Add credentials to requests in requestTemplate or beforeRequest

Reference the connection’s authentication fields in requestTemplate or beforeRequest. Zapier fills in each user’s values at request time. Never hardcode a secret value into either one. For example, to send an OAuth v2 access token in a header:
In the Platform UI, add authentication fields to the Request Template. Requests from these non-Zap features are sent with missing or wrong credentials when your integration does any of the following:
  • Adds credentials inside a trigger, search, or action.
  • Adds credentials through a helper that each action calls, such as a legacy scripting pre method on each action.
  • Applies part of the credential in authentication and the rest in action code.
  • Exchanges a key for a token in authentication.test before the authenticated call.
To check that Zapier can authenticate requests outside a Zap, send a request to your API with the Zapier SDK CLI:

Use credentials that reach only one customer’s account

If your integration uses a credential that works across customer accounts, contact Zapier through the Developer Platform contact form before you publish.

Check that Zapier allows your hosts

Zapier sends credentials only to hosts it allows for your integration. You cannot change the allowed hosts yourself. A connection field can identify the API host, such as through a region or customer subdomain. Build the URL from that field. Zapier then checks each request against the host in that user’s connection. For example, to build the URL from a subdomain field:
Validate the field so that it holds only a subdomain. Read Validate domain and subdomain input fields. To check a host, send a request to it with the Zapier SDK CLI and an app connection to your integration:
A request to a host that Zapier does not allow returns an error from Zapier, not a response from your API. To ask Zapier to allow a host, use the Developer Platform contact form. Include your integration ID, the version, and the host.

What this page does not cover

  • How to inspect the request that Zapier builds from your integration locally. Read Testing and debugging.

Validate domain and subdomain input fields

Making HTTP requests

Add authentication fields to Request Template

Session authentication

Last modified on November 25, 2026