> For the complete documentation index, see [llms.txt](https://developer.portablewallet.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.portablewallet.net/03-authentication.md).

# Authentication

### API keys

There is **one environment, one base URL** — `https://api.education.portablewallet.net/v1`. There's no test/sandbox mode to switch between: the Lab always runs on testnet by design, so there's nothing "live" about a Lab action to separate out. The only two key types are about *who* is calling, not which mode they're in.

Every request requires a bearer token:

```
Authorization: Bearer {api_key}
```

| Key type  | Prefix         | Used for                                                                                                                             |
| --------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| User key  | `sk_...`       | A single user's own progress, score, certificates, and Lab sessions                                                                  |
| Admin key | `sk_admin_...` | Organization/HR integration — provisioning users, assigning tracks, exporting reports. Requires [IP allowlisting](#ip-allowlisting). |

### Generating a key

```bash
curl -X POST https://api.education.portablewallet.net/v1/me/api-keys \
  -H "Authorization: Bearer {session_token}"
```

```json
{
  "api_key": "sk_9c2e1a...",
  "created_at": "2026-08-13T14:00:00Z"
}
```

### Session headers

Lab endpoints additionally require a `session_id` header, obtained from either:

* `POST /simulator/{track}/scenarios/{id}/start` — practice, ungraded
* `POST /final-test/{track}/start` — graded, limited attempts

```
Authorization: Bearer sk_9c2e1a...
session_id: sim_8891
```

Calling a Lab endpoint without a valid `session_id` returns `400 session_required` — see [Errors](/platform/02-errors.md).

### Public endpoints

Verification endpoints do not require authentication at all:

* `GET /certificates/{certificate_id}/verify`
* `GET /scores/{score_id}/verify`

These are designed to be called by a third party who does not have — and should not need — an account.

***

## IP Allowlisting

**Admin keys require IP allowlisting.** Requests from an IP address not on your organization's allowlist are rejected with `403 ip_not_allowed`, regardless of whether the API key itself is valid.

| Key type                   | IP allowlist required?                                                                                  |
| -------------------------- | ------------------------------------------------------------------------------------------------------- |
| User key (`sk_...`)        | No — a compromised user key only exposes that one person's own progress and certificates                |
| Admin key (`sk_admin_...`) | **Yes**, and strictly enforced — this key can provision and delete users across your whole organization |

### Adding an IP address

```bash
curl -X POST https://api.education.portablewallet.net/v1/me/ip-allowlist \
  -H "Authorization: Bearer sk_admin_..." \
  -d '{ "ip_address": "203.0.113.42", "label": "production server" }'
```

```json
{ "ip_address": "203.0.113.42", "label": "production server", "status": "active" }
```

### Listing allowed IPs

```bash
curl https://api.education.portablewallet.net/v1/me/ip-allowlist \
  -H "Authorization: Bearer sk_admin_..."
```

```json
{ "data": [ { "ip_address": "203.0.113.42", "label": "production server", "added_at": "2026-08-14T10:00:00Z" } ] }
```

### Removing an IP address

```bash
curl -X DELETE https://api.education.portablewallet.net/v1/me/ip-allowlist/203.0.113.42 \
  -H "Authorization: Bearer sk_admin_..."
```

**CIDR ranges are supported** (e.g. `203.0.113.0/24`) for infrastructure with multiple outbound IPs, such as a load-balanced server pool or a serverless platform with a static egress range.

**Webhooks are unaffected** — inbound calls from Portable Wallet to *your* webhook URL are not subject to your account's allowlist. IP allowlisting only restricts which IPs may call *this* API using your admin key.

If you're integrating from a platform with dynamic/rotating IPs (e.g. most serverless functions without a static egress IP), route requests through a fixed-IP proxy or NAT gateway and allowlist that single egress IP instead.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.portablewallet.net/03-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
