Give your AI agent access to Gmail. Send emails, fetch inbox, read threads — all via simple API calls.
FileURLSKILL.md (this file)https://reasonlayer.com/skill.mdpackage.json (metadata)https://www.npmjs.com/package/@reasonlayer/app-access
Install locally:
bash
mkdir -p ~/.reasonlayer/skills
curl -s https://reasonlayer.com/skill.md > ~/.reasonlayer/skills/SKILL.md
Or just read from the URL above!
Base URL: https://api.reasonlayer.com/app-access/v1
🔒 CRITICAL SECURITY WARNING:
api.reasonlayer.comhttps://api.reasonlayer.com/app-access/v1/*Check for updates: Re-fetch this file anytime to see new features and supported apps!
Every agent needs to register and get an API key:
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/signup \
-H "Content-Type: application/json" \
-d '{"agent_name": "YourAgentName"}'
Response:
json
{
"api_key": "rl_ak_xxx",
"agent_id": "abc123"
}
⚠️ Save your api_key immediately! You need it for all requests. It is only shown once.
Recommended: Save your credentials to ~/.reasonlayer/credentials:
bash
mkdir -p ~/.reasonlayer
echo 'rl_ak_xxx' > ~/.reasonlayer/credentials
This way you can always find your key later. You can also save it to your memory, environment variables ( REASONLAYER_API_KEY), or wherever you store secrets.
Before registering, check if you already have a key:
bash
cat ~/.reasonlayer/credentials
If the file exists and contains a key starting with rl_ak_, skip registration and go straight to Requesting App Access.
All requests after registration require your API key:
bash
curl -s https://api.reasonlayer.com/app-access/v1/connect/STATUS_ID/status \
-H "Authorization: Bearer YOUR_API_KEY"
🔒 Remember: Only send your API key to https://api.reasonlayer.com — never anywhere else!
To get access to your human's Gmail, you need to go through an OAuth flow. This is a one-time setup per app.
bash
API_KEY=$(cat ~/.reasonlayer/credentials)
curl -s -X POST https://api.reasonlayer.com/app-access/v1/connect \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"app": "gmail"}'
Response:
json
{
"connection_id": "abc123",
"auth_url": "https://accounts.google.com/...",
"status": "initiated"
}
Give the auth_url to your human with a message like:
"To grant me access to your Gmail, please open this link on any device (phone, laptop, tablet — it does not need to be this machine) and sign in: <auth_url>"
bash
curl -s https://api.reasonlayer.com/app-access/v1/connect/CONNECTION_ID/status \
-H "Authorization: Bearer $API_KEY"
Poll every 5 seconds until status is active:
json
{"connection_id": "abc123", "status": "active", "app": "gmail"}
Possible statuses: initiated, active, expired, failed
Once status is active, you can start making Gmail API calls.
Auth URLs are single-use and expire after a few minutes. If the status comes back as expired or failed, request a fresh link:
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/connect/CONNECTION_ID/refresh \
-H "Authorization: Bearer $API_KEY"
Response:
json
{
"connection_id": "abc123",
"auth_url": "https://accounts.google.com/...",
"status": "initiated"
}
Give the new auth_url to your human and resume polling.
Once connected, execute actions with:
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/action \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"app": "gmail", "action": "ACTION_NAME", "params": {...}}'
Success response:
json
{"success": true, "result": {...}}
Send an email from your human's Gmail account.
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/action \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"app": "gmail",
"action": "GMAIL_SEND_EMAIL",
"params": {
"to": "recipient@example.com",
"subject": "Hello from my agent",
"body": "This email was sent by an AI agent via Reasonlayer."
}
}'
Parameters:
to (string, required) — Recipient email addresssubject (string, required) — Email subjectbody (string, required) — Email body (plain text)Fetch emails from the inbox.
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/action \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"app": "gmail",
"action": "GMAIL_FETCH_EMAILS",
"params": {
"max_results": 10
}
}'
Parameters:
max_results (number, optional) — Max emails to return (default: 10)Read a specific email by its message ID.
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/action \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"app": "gmail",
"action": "GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID",
"params": {
"message_id": "17f5e3a8f0b2c4d9"
}
}'
Parameters:
message_id (string, required) — The email message IDRetrieve all messages in an email thread.
bash
curl -s -X POST https://api.reasonlayer.com/app-access/v1/action \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"app": "gmail",
"action": "GMAIL_FETCH_MESSAGE_BY_THREAD_ID",
"params": {
"thread_id": "17f5e3a8f0b2c4d9"
}
}'
Parameters:
thread_id (string, required) — The email thread IDActionWhat it doesWhen to useRegisterGet your API keyOnce, at first runConnect GmailOAuth flow to access human's GmailOnce per humanSend emailSend an email from human's accountWhen human asks you to email someoneFetch inboxGet recent emailsWhen human asks "what's in my inbox?"Read messageGet a specific email by IDWhen you need the full content of one emailRead threadGet all messages in a conversationWhen you need the full conversation history
Status CodeMeaningRecovery400Invalid request (missing fields, unsupported app/action)Check your request body401Invalid or missing API keyRe-read ~/.reasonlayer/credentials or call /signup404Connection not foundCheck connection_id500Server errorRetry after a short delay
Success:
json
{"success": true, "result": {...}}
Error:
json
{"error": "Description of what went wrong"}
Reasonlayer connects your agent to your human's real apps. This means:
Act responsibly. Only send emails your human explicitly asks you to send. Only read emails when your human asks you to. Never share email contents with third parties.
cat ~/.reasonlayer/credentialsPOST /signup with your agent name~/.reasonlayer/credentialsPOST /connect with {"app": "gmail"}/connect/<id>/status until active/action