curl --request POST \
--url https://api.casparser.in/v4/inbox/connect \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"redirect_uri": "https://yourapp.com/oauth-callback",
"state": "abc123",
"provider": "outlook"
}
'import requests
url = "https://api.casparser.in/v4/inbox/connect"
payload = {
"redirect_uri": "https://yourapp.com/oauth-callback",
"state": "abc123",
"provider": "outlook"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
redirect_uri: 'https://yourapp.com/oauth-callback',
state: 'abc123',
provider: 'outlook'
})
};
fetch('https://api.casparser.in/v4/inbox/connect', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.casparser.in/v4/inbox/connect",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'redirect_uri' => 'https://yourapp.com/oauth-callback',
'state' => 'abc123',
'provider' => 'outlook'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.casparser.in/v4/inbox/connect"
payload := strings.NewReader("{\n \"redirect_uri\": \"https://yourapp.com/oauth-callback\",\n \"state\": \"abc123\",\n \"provider\": \"outlook\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.casparser.in/v4/inbox/connect")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"redirect_uri\": \"https://yourapp.com/oauth-callback\",\n \"state\": \"abc123\",\n \"provider\": \"outlook\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.casparser.in/v4/inbox/connect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"redirect_uri\": \"https://yourapp.com/oauth-callback\",\n \"state\": \"abc123\",\n \"provider\": \"outlook\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"oauth_url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...",
"provider": "outlook",
"expires_in": 600
}{
"status": "failed",
"msg": "Authentication failed: API key is missing. Please provide a valid API key in the x-api-key header."
}Connect Email Provider (Initiate OAuth)
Initiate OAuth flow to connect user’s email inbox.
Returns an oauth_url that you should redirect the user to. After authorization,
they are redirected back to your redirect_uri with the following query parameters:
On success:
inbox_token- Encrypted token to store client-sideemail- Email address of the connected accountstate- Your original state parameter (for CSRF verification)
On error:
error- Error code (e.g.,access_denied,token_exchange_failed)state- Your original state parameter
Store the inbox_token client-side and use it for all subsequent inbox API calls.
The token is long-lived (it stores an encrypted refresh token), so a single OAuth
connect gives ongoing access to both historical and future CAS statements in the
user’s inbox. Reuse the same token until the user revokes access via
/v4/inbox/disconnect or their provider’s account settings.
curl --request POST \
--url https://api.casparser.in/v4/inbox/connect \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"redirect_uri": "https://yourapp.com/oauth-callback",
"state": "abc123",
"provider": "outlook"
}
'import requests
url = "https://api.casparser.in/v4/inbox/connect"
payload = {
"redirect_uri": "https://yourapp.com/oauth-callback",
"state": "abc123",
"provider": "outlook"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
redirect_uri: 'https://yourapp.com/oauth-callback',
state: 'abc123',
provider: 'outlook'
})
};
fetch('https://api.casparser.in/v4/inbox/connect', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.casparser.in/v4/inbox/connect",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'redirect_uri' => 'https://yourapp.com/oauth-callback',
'state' => 'abc123',
'provider' => 'outlook'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.casparser.in/v4/inbox/connect"
payload := strings.NewReader("{\n \"redirect_uri\": \"https://yourapp.com/oauth-callback\",\n \"state\": \"abc123\",\n \"provider\": \"outlook\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.casparser.in/v4/inbox/connect")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"redirect_uri\": \"https://yourapp.com/oauth-callback\",\n \"state\": \"abc123\",\n \"provider\": \"outlook\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.casparser.in/v4/inbox/connect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"redirect_uri\": \"https://yourapp.com/oauth-callback\",\n \"state\": \"abc123\",\n \"provider\": \"outlook\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"oauth_url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...",
"provider": "outlook",
"expires_in": 600
}{
"status": "failed",
"msg": "Authentication failed: API key is missing. Please provide a valid API key in the x-api-key header."
}Authorizations
Body
Mail provider to connect. Defaults to gmail.
gmail- Google accounts:@gmail.comand Google Workspace domains.outlook- personal Microsoft accounts:@outlook.com,@hotmail.com,@live.com,@msn.comand localised variants (@hotmail.co.uk,@live.in,@hotmail.fr). Any other address registered as a personal Microsoft account also works, including custom domains.zoho- Zoho Mail accounts, including custom domains hosted on Zoho.
Any unrecognised value is treated as gmail. The resolved
provider is returned in the response.
gmail, outlook, zoho "outlook"
Response
OAuth URL generated successfully
Was this page helpful?

