Make an OpenAI agent run a task every morning with one API request
Want an agent to send you a status summary every morning, or follow up on something later, without n8n or an external scheduler? The OpenAI Agents API now has scheduled automations: you create one with a single request and OpenAI starts the agent session for you. It is in public beta, added on Oct 23 per the changelog.
  1. Create an agent with the instructions and tools the task needs, and note its agent_id.
  2. Pick a target. new_session starts fresh and needs agent_id, environment and your message in target.input. existing_session keeps earlier context and needs session_id plus reminder text in target.instructions.
  3. Pick a schedule. periodic takes a cron expression (a five-field pattern for when to run) plus a time zone, for example "0 10 * * *" with "America/New_York" means every day at 10 AM. once takes run_at, a Unix timestamp in seconds, set in the future.
  4. Send POST /v1/agents/automations with the header OpenAI-Beta: agents=v1 (the SDKs add it for you). The doc's daily example body:
  5. {"type":"periodic","name":"Daily session","expression":"0 10 * * *","timezone":"America/New_York","target":{"type":"new_session","agent_id":"agt_123","environment":{"type":"openai_hosted"},"input":[{"role":"user","content":[{"type":"input_text","text":"Summarize the current status and next steps."}]}]}}
  6. Test it. The automation is saved as active but does not run right away, so trigger a manual run with POST /v1/agents/automations/{id}/invocations (no body). Check history with GET on the same path. Pause, resume and delete have their own endpoints.
Gotchas: a run with status completed only means the session accepted the task, not that the agent finished. Recurring runs get a small random delay, and if the session is busy the task waits. A scheduled run also does not supply a missing approval, so check the approvals page: https://developers.openai.com/api/docs/guides/agents-api/sessions/approvals
What would you have your agent do at 9 AM every day?
I'm building an AI agency, https://ethiaagency.com, and sharing here what has been most useful to me.
3
2 comments
Theo Ethia
6
Make an OpenAI agent run a task every morning with one API request
AI Automation Society
skool.com/ai-automation-society
Learn to get paid for AI solutions, regardless of your background.
Leaderboard (30-day)
Powered by