Skip to main content

OAuth account API integration guide

This API allows third-party developers to programmatically connect Google and Microsoft OAuth accounts to Instantly workspaces without requiring browser automation through the frontend.

Flow summary

  1. Send an API request to get the OAuth URL.
    • Send this request with the API key of the workspace to which you want to connect the account.
  2. Open that URL in a new browser tab and connect the account.
    • The account will automatically connect behind the scenes.
    • There is no need for any Instantly login cookie, or to open the Instantly dashboard at all.
    • Optionally, you can check status using the session ID you receive from step 1.

Authentication

All API requests require authentication using your Instantly API key:
The API key must have the accounts:create scope for initializing OAuth and the accounts:read scope for checking status.

Provider-specific notes

The API endpoints and flow are identical — simply replace the provider name in the init endpoint: Google
  • Only Google Workspace (GSuite) accounts are supported.
  • Personal Gmail accounts (@gmail.com) will be rejected.
Microsoft
  • Supports both Microsoft 365 (business) and personal Microsoft accounts.
  • Uses Outlook / Office 365 for email access.
All code examples below use Google endpoints. To use Microsoft instead, replace google with microsoft in all URLs.

API endpoints

1. Initialize OAuth session

Creates a new OAuth session and returns the Google authorization URL. Endpoint: POST /api/v2/oauth/google/init
This endpoint has special rate limits to comply with upstream provider limits. See Rate limits for details.
Request:
Response:

2. Check OAuth status

Poll this endpoint to check the result of the OAuth flow. Endpoint: GET /api/v2/oauth/session/status/:sessionId Request:
Response (pending):
Response (success):
Response (error):
Response (expired):

Integration guide

Step 1: Initialize the OAuth session

Call the init endpoint to get a session ID and authorization URL.

Step 2: Open the authorization URL

Direct the user to the auth_url to complete Google authentication. You can do this by:
  • Option A: Opening in a new browser tab/window
  • Option B: Opening in a popup window
  • Option C: Redirecting the current page (requires handling the return)

Step 3: Poll for completion

Poll the status endpoint until the session completes or expires.

Complete examples

Node.js

Python

Error handling

Common errors

HTTP status codes

Security considerations

  1. Session binding: Sessions are tied to the workspace that created them. Only the same API key/workspace can poll for status.
  2. One-time use: Successful or error sessions are deleted after the first status retrieval.
  3. Short TTL: Sessions expire after 10 minutes if not completed.
  4. No token exposure: OAuth refresh tokens are never returned via the API — they are stored directly in the database.
  5. GSuite only: Only Google Workspace (GSuite) accounts are supported. Personal Gmail accounts will be rejected.

Rate limits

The OAuth init endpoints (/oauth/google/init and /oauth/microsoft/init) have stricter rate limits than the standard API rate limit. These exist to stay compliant with upstream provider (Google, Microsoft) rate limits on OAuth authorization requests.
  • Init endpoint (per workspace): 75 requests per minute. Exceeding returns 429.
  • Init endpoint (per IP): 150 requests per minute. Exceeding returns 429.
  • Escalating IP blocks: Persistent abuse from the same IP triggers progressively longer blocks (30 minutes → 2 hours → 24 hours).
When an IP is blocked, the 429 response includes a Retry-After header with the remaining block duration in seconds. Use this value to schedule your next retry.
  • Circuit breaker: If the upstream provider (Google/Microsoft) is temporarily rate-limiting Instantly, init requests return 503 Service Unavailable. This resolves automatically — retry after a short delay.
  • Provider isolation: Rate limits, IP blocks, and circuit breakers are tracked per provider. A Microsoft outage does not affect Google init requests, and vice versa.
  • Status endpoint: Standard API rate limits apply.
  • Recommended polling interval: 5 seconds.

Troubleshooting

User sees “Non GSuite accounts are not allowed”

The OAuth flow only supports Google Workspace (GSuite) accounts. Personal Gmail accounts (@gmail.com) are not supported.

Session expires before the user completes OAuth

Sessions have a 10-minute TTL. Ensure users complete the OAuth flow promptly. If needed, initialize a new session.

Status returns 404 “Session not found”

This can happen if:
  • The session ID is incorrect.
  • The session was created by a different workspace/API key.
  • The session has already been consumed (success/error status already retrieved).

Account shows as connected but status returns “error”

Check the error and error_description fields. Common issues:
  • Account already exists in another workspace.
  • Account was blocked by admin.
  • Account contains prohibited content.