---
# @generated by sylphx-gen. Do not edit.
title: "Create a goal"
description: "`agents.goals.create` (POST /v1/{parent}/goals): Creates an optional objective owned by this Session, without an external Task."
type: reference
product: agents
summary: "Creates an optional objective owned by this Session, without an external Task."
updated: 2026-09-28
nav: false
---

Creates an optional objective owned by this Session, without an external Task. The operation_id keeps the original receipt beyond request replay expiry.

- **Path** `POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/agent_sessions/agent-session/goals`
- **Scope** `agents:sessions`
- **Effect** `write` — a successful call changes state.
- **Collection** [goals](/docs/api/goals)
- **Query** `operation_id`

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `parent` | `string` | The existing Session that owns this Goal. Required. |
| `agent_session_goal` | `AgentSessionGoal` | Only objective and optional token_budget are caller supplied. Required. |
| `operation_id` | `string` | Caller-stable mutation identity, nonempty and at most 128 bytes. Required. |

### AgentSessionGoal

| Field | Type | What it is |
| --- | --- | --- |
| `name` | `string` | The exact Session-owned Goal name. |
| `objective` | `string` | The objective, nonempty and at most 4,000 characters. Required. |
| `token_budget` | `int64` | Omit unless the caller explicitly requests a positive token budget. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `name` | `string` | The exact Session-owned Goal name. |
| `uid` | `string` | The platform Resource UID; the conserved Goal UUID is its name's final id. Output only. |
| `meta` | `ResourceMeta` | Standard resource metadata. Output only. |
| `objective` | `string` | The objective, nonempty and at most 4,000 characters. Required. |
| `token_budget` | `int64` | Omit unless the caller explicitly requests a positive token budget. |
| `state` | `GoalState` | Lifecycle; an execution hold is represented separately. Output only. One of `working`, `waiting`, `completed`, `failed`. |
| `version` | `int32` | Optimistic acceptance-contract version, starting at one. Output only. |
| `tokens_used` | `int64` | Observed tokens charged exactly once per runtime step. Output only. |
| `usage_unavailable` | `bool` | Unknown usage holds execution when a token budget is enforced. Output only. |
| `owner_paused` | `bool` | Explicit owner pause; an unfinished Goal stays unfinished. Output only. |
| `impasse` | `bool` | Execution held after the required repeated observation of an impasse. Output only. |
| `receipt` | `SessionGoalReceipt` | The terminal observation, retained after another Goal becomes active. Output only. |
| `create_time` | `timestamp` | When this Goal was created. Output only. |
| `update_time` | `timestamp` | When this Goal last changed. Output only. |

### ResourceMeta

| Field | Type | What it is |
| --- | --- | --- |
| `generation` | `int64` | Increases by one on every change to `spec`. Output only. |
| `etag` | `string` | Strong ETag (AIP-154): changes on any change to spec, status, or metadata. Send it back as `If-Match` or `etag` to make Update and Delete conditional; a mismatch fails with ABORTED / 409 `ETAG_MISMATCH`. Output only. |
| `create_time` | `timestamp` | When the Resource was created. Output only. |
| `update_time` | `timestamp` | When the Resource last changed. Output only. |
| `delete_time` | `timestamp` | Set while the Resource is being deleted. Output only. |
| `labels` | `map<string, string>` | Caller-writable, indexed labels (AIP-122 label rules). |
| `annotations` | `map<string, string>` | Caller-writable, unindexed annotations. |
| `display_name` | `string` | Caller-writable human-readable name. |
| `creator` | `string` | The principal that created the Resource. Output only. |

### SessionGoalReceipt

| Field | Type | What it is |
| --- | --- | --- |
| `stage` | `string` | The observed delivery stage. Required. |
| `target` | `string` | The concrete surface or artifact observed. Required. |
| `evidence` | `struct` | Nonempty structured evidence from that surface. Required. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`RESOURCE_NOT_FOUND`](/docs/api/errors/RESOURCE_NOT_FOUND) — The named Resource does not exist or is not visible.
- [`INVALID_FIELD`](/docs/api/errors/INVALID_FIELD) — A field failed validation.
- [`INVALID_STATE`](/docs/api/errors/INVALID_STATE) — The Resource is in a state that forbids the call.
- [`IDEMPOTENCY_KEY_REUSED`](/docs/api/errors/IDEMPOTENCY_KEY_REUSED) — An Idempotency-Key was reused with another body.
- [`IDEMPOTENCY_IN_PROGRESS`](/docs/api/errors/IDEMPOTENCY_IN_PROGRESS) — The first call with this Idempotency-Key is still running.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/agent_sessions/agent-session/goals" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"objective":"…"}'
```

**TypeScript**

```ts
const response = await sylphx.agents.goals.create({ agentSessionGoal: { objective: '…' }, parent: 'orgs/acme/projects/shop/envs/production/agent_sessions/agent-session' })
```

**Rust**

```rust
let mut req = sylphx::agents::CreateAgentSessionGoalRequest::default();
req.agent_session_goal = Some(sylphx::agents::AgentSessionGoal {
    objective: "…".to_string(),
    ..Default::default()
});
req.parent = "orgs/acme/projects/shop/envs/production/agent_sessions/agent-session".to_string();
let response = sx.agents().goals().create(req).await?;
```

**CLI**

```bash
sylphx agents goals create --parent orgs/acme/projects/shop/envs/production/agent_sessions/agent-session --objective …
```

**MCP**

```json
{ "method_id": "agents.goals.create", "args": {"agent_session_goal":{"objective":"…"},"parent":"orgs/acme/projects/shop/envs/production/agent_sessions/agent-session"} }
```
