# Apps

Apps such as ChatGPT and Claude connect by MCP and OAuth 2.1, and act as the person's agent.

Calls go to https://address.seleya.ai/api. Errors are `{"error": {"code", "message"}}` with the HTTP status: https://address.seleya.ai/docs/reference/errors.md

## Protected resource metadata

`GET /.well-known/oauth-protected-resource`, called with 

RFC 9728, for the MCP server.

Answers:

- 200: Done

## Protected resource metadata (path form)

`GET /.well-known/oauth-protected-resource/mcp`, called with 

The same metadata, at the path form RFC 9728 names for the MCP server.

Answers:

- 200: Done

## The MCP server

`POST /mcp`, called with an app

The MCP server, at https://address.seleya.ai/mcp. It speaks MCP 2026-07-28 and answers clients that start with initialize, over Streamable HTTP without sessions. Its tools are this API's calls, made as the app; MCP Events arrive by webhook.

Answers:

- 200: Done
- 400: The request is malformed
- 401: No valid key, session or token
- 404: Not found, or not yours to see

## Apps using an address

`GET /v1/addresses/{a}/connections`, called with a key or a person signed in

The apps using an address, for its holder or the company's admins.

| Parameter | Type | | |
| --- | --- | --- | --- |
| `a` | string, in path | required | Address name or UUID. Use the UUID for a nonexclusive pending request. |

```bash
curl https://address.seleya.ai/api/v1/addresses/desk@acme.seleya.email/connections \
  -H "Authorization: Bearer $SELEYA_KEY"
```

```python
import os, requests

r = requests.get(
    "https://address.seleya.ai/api/v1/addresses/desk@acme.seleya.email/connections",
    headers={"Authorization": f"Bearer {os.environ['SELEYA_KEY']}"},
)
print(r.status_code, r.json())
```

```typescript
const r = await fetch("https://address.seleya.ai/api/v1/addresses/desk@acme.seleya.email/connections", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.SELEYA_KEY}` },
});
console.log(r.status, await r.json());
```

Answers:

- 200: Done
- 401: No valid key, session or token
- 403: Not allowed for this caller
- 404: Not found, or not yours to see

| Field (200) | Type | | |
| --- | --- | --- | --- |
| `connections` | array of Connection | required |  |

```json
{
  "connections": []
}
```

## Give an app the use of this address, or ask for it

`POST /v1/addresses/{a}/connections`, called with a key or a person signed in

A person gives a connected app the use of this address (B2-O59). An app calls with no body to ask for an address its person holds (B2-O63). The call answers 202 with the signed-in review link. The person's approval gives the app the address.

| Parameter | Type | | |
| --- | --- | --- | --- |
| `a` | string, in path | required | Address name or UUID. Use the UUID for a nonexclusive pending request. |

| Field | Type | | |
| --- | --- | --- | --- |
| `connection` | string | optional | The connection's id, from GET /v1/connections. A person sends it; an app asking for itself sends none. |

```bash
curl -X POST https://address.seleya.ai/api/v1/addresses/desk@acme.seleya.email/connections \
  -H "Authorization: Bearer $SELEYA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "connection": "00000000-0000-4000-8000-000000000000"
}'
```

```python
import os, requests

r = requests.post(
    "https://address.seleya.ai/api/v1/addresses/desk@acme.seleya.email/connections",
    headers={"Authorization": f"Bearer {os.environ['SELEYA_KEY']}"},
    json={
      "connection": "00000000-0000-4000-8000-000000000000"
    },
)
print(r.status_code, r.json())
```

```typescript
const r = await fetch("https://address.seleya.ai/api/v1/addresses/desk@acme.seleya.email/connections", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.SELEYA_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "connection": "00000000-0000-4000-8000-000000000000"
  }),
});
console.log(r.status, await r.json());
```

Answers:

- 202: The app's request is waiting for the person to review it
- 204: The app can use this address
- 401: No valid key, session or token
- 403: Not allowed for this caller
- 404: Not found, or not yours to see

| Field (202) | Type | | |
| --- | --- | --- | --- |
| `status` | awaiting_approval | required | awaiting_approval. |
| `approval` | object | required | The ask: its id, kind and who decides. |

```json
{
  "status": "awaiting_approval",
  "approval": {
    "id": "7f3c9a2e-0000-4000-8000-000000000002",
    "kind": "use_address",
    "summary": "use desk@acme.seleya.email: read its mail and send from it",
    "waits_for": "a person",
    "review_url": "https://address.seleya.ai/#/approvals"
  }
}
```

## Remove an app from an address

`DELETE /v1/addresses/{a}/connections/{id}`, called with a person signed in

Stops an app using this address. A person only.

Called by the console's own page, signed in; not for agents.

| Parameter | Type | | |
| --- | --- | --- | --- |
| `a` | string, in path | required | Address name or UUID. Use the UUID for a nonexclusive pending request. |
| `id` | string, in path | required | Its id. |

Answers:

- 204: Done, with no body
- 401: No valid key, session or token
- 403: Not allowed for this caller
- 404: Not found, or not yours to see

## Apps acting for you

`GET /v1/connections`, called with a person signed in

The apps acting for you, with their addresses and when each was last used.

Called by the console's own page, signed in; not for agents.

Answers:

- 200: Done
- 401: No valid key, session or token

| Field (200) | Type | | |
| --- | --- | --- | --- |
| `connections` | array of Connection | required |  |

```json
{
  "connections": [
    {
      "addresses": [
        "apps@seleya.me"
      ],
      "app": "Seleya Address test client",
      "client_id": "https://juiw7rjojt3cahaammkuzf3di40ycqbj.lambda-url.eu-central-1.on.aws/client/main.json",
      "id": "7f3c9a2e-0000-4000-8000-00000000001d",
      "last_used_at": "2026-10-22T00:40:34.644228+00:00",
      "returns_to": "127.0.0.1",
      "since": "2026-10-22T00:40:33.739498+00:00"
    }
  ]
}
```

## Disconnect from the emailed link

`POST /v1/connections/by-link`, called with 

Disconnects an app from the link in the new-connection email.

Called by the console's own page, signed in; not for agents.

| Field | Type | | |
| --- | --- | --- | --- |
| `token` | string | required | The token from the emailed link's fragment. |

Answers:

- 200: Done
- 404: Not found, or not yours to see

| Field (200) | Type | | |
| --- | --- | --- | --- |
| `disconnected` | string | optional |  |

## Disconnect an app

`DELETE /v1/connections/{id}`, called with a person signed in

Disconnects an app at once. The off switch never depends on the app.

Called by the console's own page, signed in; not for agents.

| Parameter | Type | | |
| --- | --- | --- | --- |
| `id` | string, in path | required | Its id. |

Answers:

- 204: Done, with no body
- 401: No valid key, session or token
- 404: Not found, or not yours to see

## A2A protected resource metadata

`GET /.well-known/oauth-protected-resource/a2a`, called with 

The OAuth resource https://address.seleya.ai/a2a uses Seleya Accounts. MCP tokens do not authorize this resource.

Answers:

- 200: Done

## Deliver a complete message through A2A

`POST /a2a/{address}`, called with an app

JSON-RPC binding of A2A 1.0.1, wire version 1.0. SendMessage, GetTask, ListTasks and CancelTask track mailbox acceptance. Streaming, push and extended-card methods are unsupported. IDs are scoped to issuer, subject, client and target. The outside peer needs verified email and OAuth consent; no paid local mailbox or recipient grant is required. Retry the same messageId after uncertain responses. Use returnImmediately true for asynchronous acquisition. The host replies by ordinary email.

| Parameter | Type | | |
| --- | --- | --- | --- |
| `address` | string, in path | required | Exact recipient mailbox, URL encoded. |
| `A2A-Version` | 1.0, in header | required |  |

| Field | Type | | |
| --- | --- | --- | --- |
| `jsonrpc` | 2.0 | required |  |
| `id` | string or number, or null | required |  |
| `method` | string | required |  |
| `params` | object | optional |  |

```bash
curl -X POST https://address.seleya.ai/api/a2a/ADDRESS
```

```python
import os, requests

r = requests.post(
    "https://address.seleya.ai/api/a2a/ADDRESS",
)
print(r.status_code, r.json())
```

```typescript
const r = await fetch("https://address.seleya.ai/api/a2a/ADDRESS", {
  method: "POST",
});
console.log(r.status, await r.json());
```

Answers:

- 200: JSON-RPC result or protocol error
- 401: Authorization refused; WWW-Authenticate names the resource metadata
- 404: No A2A interface is published
- 503: Receipt still processing at the transport deadline; retry the same message ID

| Field (200) | Type | | |
| --- | --- | --- | --- |
| `jsonrpc` | 2.0 | required |  |
| `id` | string or number, or null | required |  |
| `result` | object | optional |  |
| `error` | object | optional |  |

