Start connecting a mailbox
const url = 'https://api.clearance.rest/emails/gmail/oauth/start?return_url=https%3A%2F%2Fapp.example.com%2Fsettings%2Fmailboxes&client_state=user-42';const options = {method: 'GET', headers: {'X-API-Key': '<X-API-Key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.clearance.rest/emails/gmail/oauth/start?return_url=https%3A%2F%2Fapp.example.com%2Fsettings%2Fmailboxes&client_state=user-42' \ --header 'X-API-Key: <X-API-Key>'Call this from your backend, not the browser. It returns an authorize_url; redirect the user’s browser there. After the user consents, the provider redirects to the service, which redirects the browser to your return_url with result_token and client_state query parameters. Read the outcome server-to-server with GET /{provider}/oauth/result.
return_url must be an absolute http(s) URL. If your project restricts allowed return origins, only those origins are accepted.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Mail provider.
Query Parameters
Section titled “Query Parameters”Where the browser is sent after the provider redirect.
Opaque value of your choosing, echoed back unchanged at the end of the flow.
Responses
Section titled “Responses”The URL to send the user to.
object
Example
{ "success": true, "authorize_url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=example&state=6f1c1a4e"}return_url is not an absolute http(s) URL, or its origin is not allowed.
Error envelope returned with a non-2xx status.
object
Human-readable error message.
Example
{ "success": false, "error": "geçersiz veya izin verilmeyen return_url"}The X-API-Key header is missing or invalid.
Error envelope returned with a non-2xx status.
object
Human-readable error message.
Example
{ "success": false, "error": "geçersiz API anahtarı"}