Jules API Skill
Interact with the Google Jules AI coding agent via its REST API. Jules can autonomously execute coding tasks on your GitHub repositories — writing code, fixing bugs, adding tests, and creating pull requests.
Base URL: https://jules.googleapis.com/v1alpha
Auth: Pass your API key via the x-goog-api-key header. Get one at jules.google.com/settings.
List Sources (Connected Repositories)
Discover which GitHub repos are connected to your Jules account:
CODEBLOCK0
With pagination:
CODEBLOCK1
Filter specific sources:
CODEBLOCK2
Get a Source
Get details and branches for a specific repo:
CODEBLOCK3
Example: sources/github-myorg-myrepo — replace with your actual source ID from List Sources.
Create a Session (Start a Coding Task)
Create a new Jules session to execute a coding task on a repo:
CODEBLOCK4
Parameters
| Parameter | Required | Description |
|---|
| INLINECODE3 | Yes | The task description for Jules to execute |
| INLINECODE4 |
No | Optional title (auto-generated if omitted) |
|
sourceContext.source | Yes | Source resource name (e.g.
sources/github-owner-repo) |
|
sourceContext.githubRepoContext.startingBranch | Yes | Branch to start from (e.g.
main,
develop) |
|
requirePlanApproval | No | If
true, plans need explicit approval before execution |
|
automationMode | No | Set to
AUTO_CREATE_PR to auto-create PRs when done |
Auto-approve + Auto-PR example
CODEBLOCK5
List Sessions
List all your Jules sessions:
CODEBLOCK6
Paginate with pageToken:
CODEBLOCK7
Get a Session
Retrieve a single session by ID (includes outputs like PRs if completed):
CODEBLOCK8
Session States
| State | Meaning |
|---|
| INLINECODE15 | Waiting to be processed |
| INLINECODE16 |
Jules is analyzing and creating a plan |
|
AWAITING_PLAN_APPROVAL | Plan ready, waiting for user approval |
|
AWAITING_USER_FEEDBACK | Jules needs additional input |
|
IN_PROGRESS | Jules is actively working |
|
PAUSED | Session is paused |
|
COMPLETED | Task completed successfully |
|
FAILED | Task failed to complete |
Approve a Plan
When a session is in AWAITING_PLAN_APPROVAL state, approve the plan:
CODEBLOCK9
Send a Message
Send feedback, answer questions, or give additional instructions to an active session:
CODEBLOCK10
Use this when session state is AWAITING_USER_FEEDBACK or to provide additional guidance during IN_PROGRESS.
List Activities (Monitor Progress)
Get all events/progress for a session:
CODEBLOCK11
Get activities after a specific timestamp (for polling):
CODEBLOCK12
Activity Types
Activities will contain exactly one of these event fields:
| Event | Description |
|---|
| INLINECODE26 | Jules created a plan (contains plan.steps[]) |
| INLINECODE28 |
A plan was approved |
|
userMessaged | User sent a message |
|
agentMessaged | Jules sent a message |
|
progressUpdated | Status update during execution |
|
sessionCompleted | Session finished successfully |
|
sessionFailed | Session encountered an error (contains
reason) |
Artifacts
Activities may include artifacts:
- - ChangeSet: Code changes with
gitPatch (unified diff, base commit, suggested commit message) - BashOutput: Command output with
command, output, INLINECODE38 - Media: Binary output with
mimeType and base64 INLINECODE40
Get a Single Activity
CODEBLOCK13
Delete a Session
CODEBLOCK14
Typical Workflow
- 1. List sources to find the repo resource name
- Create a session with a prompt describing the task
- Poll the session (Get Session) to track state changes
- List activities to monitor progress and read Jules' messages
- If
requirePlanApproval was set, approve the plan when state is INLINECODE42 - If state is
AWAITING_USER_FEEDBACK, send a message with your response - When
COMPLETED, get the session to find the output PR URL
Error Handling
Bad request (invalid parameters) |
| 401 | Unauthorized (invalid/missing API key) |
| 403 | Forbidden (insufficient permissions) |
| 404 | Not found |
| 429 | Rate limited |
| 500 | Server error |
Error responses return:
CODEBLOCK15
Notes
- - Get your API key from jules.google.com/settings
- Store it as the
JULES_API_KEY environment variable - Sources (repos) are connected via the Jules web UI at jules.google — the API is read-only for sources
- Session resource names follow the pattern INLINECODE46
- Activity resource names follow INLINECODE47
- All list endpoints support
pageSize (1-100) and pageToken for pagination
Jules API 技能
通过 REST API 与 Google Jules AI 编码代理进行交互。Jules 可以自主在你的 GitHub 仓库上执行编码任务——编写代码、修复错误、添加测试以及创建拉取请求。
基础 URL: https://jules.googleapis.com/v1alpha
认证: 通过 x-goog-api-key 请求头传递你的 API 密钥。在 jules.google.com/settings 获取密钥。
列出源(已连接的仓库)
发现哪些 GitHub 仓库已连接到你的 Jules 账户:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sources?pageSize=30
带分页:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sources?pageSize=10&pageToken=PAGE_TOKEN
过滤特定源:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sources?filter=name%3Dsources%2Fgithub-owner-repo
获取单个源
获取特定仓库的详细信息和分支:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sources/SOURCE_ID
示例:sources/github-myorg-myrepo——替换为从列出源获取的实际源 ID。
创建会话(开始编码任务)
创建一个新的 Jules 会话以在仓库上执行编码任务:
bash
curl -s -X POST \
-H x-goog-api-key: $JULESAPIKEY \
-H Content-Type: application/json \
-d {
prompt: TASK_DESCRIPTION,
title: OPTIONAL_TITLE,
sourceContext: {
source: sources/github-OWNER-REPO,
githubRepoContext: {
startingBranch: main
}
},
requirePlanApproval: true
} \
https://jules.googleapis.com/v1alpha/sessions
参数
| 参数 | 必需 | 描述 |
|---|
| prompt | 是 | 要 Jules 执行的任务描述 |
| title |
否 | 可选标题(省略时自动生成) |
| sourceContext.source | 是 | 源资源名称(例如 sources/github-owner-repo) |
| sourceContext.githubRepoContext.startingBranch | 是 | 起始分支(例如 main、develop) |
| requirePlanApproval | 否 | 如果为 true,计划在执行前需要明确批准 |
| automationMode | 否 | 设置为 AUTO
CREATEPR 以在完成后自动创建 PR |
自动批准 + 自动 PR 示例
bash
curl -s -X POST \
-H x-goog-api-key: $JULESAPIKEY \
-H Content-Type: application/json \
-d {
prompt: 为认证模块添加全面的单元测试,
sourceContext: {
source: sources/github-myorg-myrepo,
githubRepoContext: { startingBranch: main }
},
automationMode: AUTOCREATEPR
} \
https://jules.googleapis.com/v1alpha/sessions
列出会话
列出你所有的 Jules 会话:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions?pageSize=10
使用 pageToken 进行分页:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions?pageSize=10&pageToken=NEXTPAGETOKEN
获取单个会话
通过 ID 检索单个会话(如果已完成,包含 PR 等输出):
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions/SESSION_ID
会话状态
Jules 正在分析并创建计划 |
| AWAITING
PLANAPPROVAL | 计划已就绪,等待用户批准 |
| AWAITING
USERFEEDBACK | Jules 需要额外输入 |
| IN_PROGRESS | Jules 正在积极工作 |
| PAUSED | 会话已暂停 |
| COMPLETED | 任务成功完成 |
| FAILED | 任务未能完成 |
批准计划
当会话处于 AWAITINGPLANAPPROVAL 状态时,批准计划:
bash
curl -s -X POST \
-H x-goog-api-key: $JULESAPIKEY \
-H Content-Type: application/json \
-d {} \
https://jules.googleapis.com/v1alpha/sessions/SESSION_ID:approvePlan
发送消息
向活动会话发送反馈、回答问题或提供额外指示:
bash
curl -s -X POST \
-H x-goog-api-key: $JULESAPIKEY \
-H Content-Type: application/json \
-d {
prompt: YOURMESSAGEHERE
} \
https://jules.googleapis.com/v1alpha/sessions/SESSION_ID:sendMessage
当会话状态为 AWAITINGUSERFEEDBACK 时使用此功能,或在 IN_PROGRESS 期间提供额外指导。
列出活动(监控进度)
获取会话的所有事件/进度:
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions/SESSION_ID/activities?pageSize=50
获取特定时间戳之后的活动(用于轮询):
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions/SESSION_ID/activities?createTime=2026-01-17T00:03:53Z
活动类型
活动将恰好包含以下事件字段之一:
| 事件 | 描述 |
|---|
| planGenerated | Jules 创建了计划(包含 plan.steps[]) |
| planApproved |
计划已被批准 |
| userMessaged | 用户发送了消息 |
| agentMessaged | Jules 发送了消息 |
| progressUpdated | 执行期间的状态更新 |
| sessionCompleted | 会话成功完成 |
| sessionFailed | 会话遇到错误(包含 reason) |
产物
活动可能包含产物:
- - ChangeSet:带有 gitPatch 的代码更改(统一差异、基础提交、建议的提交消息)
- BashOutput:带有 command、output、exitCode 的命令输出
- Media:带有 mimeType 和 base64 data 的二进制输出
获取单个活动
bash
curl -s -H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions/SESSIONID/activities/ACTIVITYID
删除会话
bash
curl -s -X DELETE \
-H x-goog-api-key: $JULESAPIKEY \
https://jules.googleapis.com/v1alpha/sessions/SESSION_ID
典型工作流程
- 1. 列出源 以查找仓库资源名称
- 创建会话,使用描述任务的提示词
- 轮询会话(获取会话)以跟踪状态变化
- 列出活动 以监控进度并阅读 Jules 的消息
- 如果设置了 requirePlanApproval,当状态为 AWAITINGPLANAPPROVAL 时批准计划
- 如果状态为 AWAITINGUSERFEEDBACK,发送消息并附上你的回复
- 当状态为 COMPLETED 时,获取会话以找到输出的 PR URL
错误处理
错误请求(无效参数) |
| 401 | 未授权(无效/缺少 API 密钥) |
| 403 |