> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://mpp.dev/api/mcp` to find what you need.

# Core Types \[Challenge, Credential, and Receipt primitives]

The SDK provides three core types that map directly to HTTP headers: `Challenge`, `Credential`, and `Receipt`.

```python
from mpp import Challenge, Credential, Receipt
```

## Parse a Challenge

```python
challenge = Challenge.from_www_authenticate(
    'Payment id="...", realm="...", method="tempo", intent="charge", request="eyJ..."'
)
```

On the wire, `request` and optional `opaque` are base64url-encoded JSON strings in the `WWW-Authenticate` header. `Challenge.from_www_authenticate(...)` decodes them for application code.

## Create and serialize a Credential

```python
credential = Credential(
    id="challenge-id",
    payload={"type": "transaction", "signature": "0x..."},
    source="did:pkh:eip155:42431:0xa726a1...",
)

header = credential.to_authorization()
```

When a Credential echoes a Challenge, `challenge.request` and `challenge.opaque` stay in their base64url string form inside the serialized `Authorization` payload.

## Parse and serialize a Receipt

```python
receipt = Receipt.from_payment_receipt(header_value)
header = receipt.to_payment_receipt()
```
