今日已更新 412 条资讯 | 累计 19972 条内容
关于我们

Agent Accounts Quickstart in Python

Qasim Muhammad 2026年06月16日 02:56 4 次阅读 来源:Dev.to

A connected Gmail grant starts with an OAuth consent screen and ends with a refresh token you have to babysit; a Nylas Agent Account starts and ends with one POST request. Same API surface afterward — same messages endpoints, same webhooks, same calendar — but the provisioning story couldn't be more different, and that difference is what makes these hosted mailboxes such a natural fit for Python automation, agents, and test harnesses. Agent Accounts are in beta, and the official quickstart gets you from nothing to a sending-and-receiving mailbox in under 5 minutes using curl. Here's the whole flow as a Python script. Step 0: prerequisites You need an API key (run nylas init with the CLI, or use the Dashboard) and a domain. The fast path for testing: register a *.nylas.email trial subdomain from the Dashboard — no DNS records, instantly usable. Custom domains need MX and TXT records published at your DNS provider, with automatic verification once they propagate; save that for production. import os import requests BASE = " https://api.us.nylas.com " HEADERS = { " Authorization " : f " Bearer { os . environ [ ' NYLAS_API_KEY ' ] } " , " Content-Type " : " application/json " , } Step 1: provision the account POST /v3/connect/custom with "provider": "nylas" . No refresh token — just an email address on a registered domain: resp = requests . post ( f " { BASE } /v3/connect/custom " , headers = HEADERS , json = { " provider " : " nylas " , " settings " : { " email " : " test@your-application.nylas.email " }, }, ) resp . raise_for_status () grant_id = resp . json ()[ " data " ][ " id " ] print ( f " Agent Account live: { grant_id } " ) Save that grant_id — per the docs, you'll use it in every subsequent call. The mailbox works with every existing endpoint from this moment on. If you want policies or mail rules applied, add a top-level workspace_id to the same request body; the account inherits the workspace's limits, spam settings, and rules. Omit it and the account lands i

本文内容来源于互联网,版权归原作者所有
查看原文