Skip to content

Start connecting a Gmail or Outlook mailbox

GET
/emails/{email_provider}/oauth/start
curl --request GET \
--url 'https://api.clearance.rest/emails/gmail/oauth/start?return_url=example' \
--header 'X-API-Key: <X-API-Key>'

Call this from your backend and redirect the user’s browser to authorize_url. After the consent screen the browser returns to return_url with result_token (and client_state); read the outcome once with the result endpoint. When the project has mark_as_read enabled the mailbox is asked for the permission to mark emails as read.

email_provider
required
string
Allowed values: gmail outlook

Email provider that can be connected with OAuth.

return_url
required
string
>= 1 characters <= 2048 characters

Where the browser returns after the provider’s consent screen; its origin must be in the project’s allowed return origins.

client_state
string
<= 255 characters

Opaque value echoed back to return_url and in the result.

Default Response

Media typeapplication/json
object
success
required
boolean
authorize_url
required

Redirect the user’s browser here.

string
Example
{
"success": true
}

Default Response

Media typeapplication/json

Error envelope returned by every JSON endpoint.

object
success
required
boolean
error
required
object
code
required

Machine-readable error code (snake_case).

string
message
required

Human-readable message.

string
details

Extra context for the error.

object
key
additional properties
Example
{
"success": false
}

Default Response

Media typeapplication/json

Error envelope returned by every JSON endpoint.

object
success
required
boolean
error
required
object
code
required

Machine-readable error code (snake_case).

string
message
required

Human-readable message.

string
details

Extra context for the error.

object
key
additional properties
Example
{
"success": false
}

Default Response

Media typeapplication/json

Error envelope returned by every JSON endpoint.

object
success
required
boolean
error
required
object
code
required

Machine-readable error code (snake_case).

string
message
required

Human-readable message.

string
details

Extra context for the error.

object
key
additional properties
Example
{
"success": false
}

Default Response

Media typeapplication/json

Error envelope returned by every JSON endpoint.

object
success
required
boolean
error
required
object
code
required

Machine-readable error code (snake_case).

string
message
required

Human-readable message.

string
details

Extra context for the error.

object
key
additional properties
Example
{
"success": false
}