Skip to main content
POST
/
action
/
fetch_relevant_gmail_threads
Analyze Contact Email History & Insights
curl --request POST \
  --url https://api-lr.agent.ai/v1/action/fetch_relevant_gmail_threads \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "email_provider": "gmail",
  "date_range_days": "90",
  "max_results": "10",
  "analysis_type": "none",
  "output_variable_name": "topic_relevant_gmail_threads",
  "contact_email": "<string>",
  "meeting_topic": "<string>"
}
'
{
  "status": 123,
  "response": {}
}

Authorizations

Authorization
string
header
required

Bearer token from your account (https://agent.ai/user/integrations#api)

Body

application/json
email_provider
enum<string>
default:gmail
required

Email service to search. Supports Gmail and Outlook Mail.

Available options:
gmail,
outlook
date_range_days
enum<string>
default:90
required

How far back to search for emails.

Available options:
1,
7,
30,
90
max_results
string
default:10
required

Maximum number of email threads to retrieve (e.g., 10, 50, 100).

Pattern: ^[0-9]+$
analysis_type
enum<string>
default:none
required

Optional AI analysis to run on the fetched emails.

Available options:
none,
timeline,
insights
output_variable_name
string
default:topic_relevant_gmail_threads
required

Provide a variable name to store the Gmail threads, like 'topic_relevant_gmail_threads' or 'contact_emails'.

Pattern: ^[a-zA-Z][a-zA-Z0-9_]*$
contact_email
string

The email address to search for (e.g., [email protected]). Will search in from, to, and cc fields.

meeting_topic
string

Topic or keywords to search for in emails (e.g., 'Q4 pricing proposal'). AI will extract relevant keywords.

Response

Successful response

status
integer<int32>

HTTP status code of the action response

response
object

Response data from the action