> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myego.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Request approvals

> Have an app ask the owner to decide, resolve it in ego, and read the result back.

This guide submits an approval from an app, resolves it in ego, and reads the resolution from the API.

<Note>
  Approvals work in the app today. The API steps that submit and read approvals are
  in preview.
</Note>

## Prerequisites

* An ego account with the app running. See the [project README](https://github.com/yasyf/ego) to run it locally.
* A token that carries the `approvals:write` and `approvals:read` scopes. Grant them on the consent screen.

## Submit the approval

The app submits an approval with `approvals:write`. Give it a question and the options the owner can choose from.

```bash theme={null}
curl https://api.myego.dev/api/approvals \
  -H "Authorization: Bearer $EGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "Ship the 2.0 release?",
    "options": [
      { "id": "ship", "label": "Ship it" },
      { "id": "hold", "label": "Hold for review" }
    ],
    "backgroundContext": "All tests pass. Two reviewers signed off.",
    "recommendation": "ship"
  }'
```

The call returns the approval's `id`:

```json theme={null}
{ "id": "k1722abcd" }
```

## Resolve it in ego

Open the app and go to **Approvals**. The pending approval shows the question, the background context, and the options. Select one to resolve it. ego records the choice and marks the approval `resolved`.

## Read the result

The app reads the resolution with `approvals:read`. Fetch the approval by `id`:

```bash theme={null}
curl https://api.myego.dev/api/approvals/k1722abcd \
  -H "Authorization: Bearer $EGO_API_KEY"
```

Once the owner decides, the approval carries its `resolution`. `resolvedBy` is the role that resolved it — `owner` here:

```json theme={null}
{
  "_id": "k1722abcd",
  "question": "Ship the 2.0 release?",
  "status": "resolved",
  "resolution": {
    "kind": "option",
    "optionId": "ship",
    "resolvedBy": "owner",
    "resolvedAt": 1735000000000
  }
}
```

## Resolve from the app

The app can also resolve its own approval with `approvals:resolve`, choosing an option or supplying free-text:

```bash theme={null}
curl https://api.myego.dev/api/approvals/k1722abcd/resolve \
  -H "Authorization: Bearer $EGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "kind": "option", "optionId": "ship" }'
```

A resolved approval returns `{ "ok": true }`. Resolving one that is already resolved returns `409`.

## Next steps

<CardGroup cols={2}>
  <Card title="Push notifications" icon="bell" href="/guides/notifications">
    Send the owner an event from an app.
  </Card>

  <Card title="API reference" icon="code" href="/api-reference/introduction">
    The endpoints behind approvals.
  </Card>
</CardGroup>
