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 inspectsauthentication.test to learn how credentials are applied to requests, and runs the test during a credential refresh.
Inspect the test to find credentials
Zapier readsauthentication.test to find where your integration puts credentials. Zapier does not send the test request during inspection.
- If
authentication.testis a request object, Zapier reads its URL, headers, and parameters. - If
authentication.testis 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.
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 inrequestTemplate 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:
- Adds credentials inside a trigger, search, or action.
- Adds credentials through a helper that each action calls, such as a legacy scripting
premethod on each action. - Applies part of the credential in authentication and the rest in action code.
- Exchanges a key for a token in
authentication.testbefore the authenticated call.
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 asubdomain field:
What this page does not cover
- How to inspect the request that Zapier builds from your integration locally. Read Testing and debugging.