# Meta Reva Agent Authentication (auth.md)

Welcome, autonomous agent! This document describes how AI and software agents register, obtain credentials, and authenticate requests to the Meta Reva B2B platform.

## Audience
Autonomous agents acting on behalf of commercial buyers, ERP integrators, or partner platforms requiring real-time inventory verification, order placement, or commercial account statements.

## Registration Endpoint
- **URL**: `https://metareva.com/api/v1/agent/register`
- **Method**: `POST`
- **Content-Type**: `application/json`
- **Body**:
  ```json
  {
    "agent_name": "MyBuyerAgent",
    "contact_email": "agent-ops@metareva.com",
    "requested_scopes": ["orders:write", "inventory:read"]
  }
  ```

## Supported Authentication Methods
1. **Bearer API Tokens (Standard)**:
   - Header: `Authorization: Bearer <your_api_token>`
   - Suitable for stateless HTTP/JSON calls and cURL requests.
2. **OAuth 2.0 Client Credentials (RFC 6749)**:
   - Token Endpoint: `https://metareva.com/api/v1/oauth/token`
   - Grant Type: `client_credentials`
3. **HTTP Message Signatures (RFC 9421 / Ed25519)**:
   - Public Keys: `https://metareva.com/.well-known/http-message-signatures-directory`
   - Header: `Signature-Input` & `Signature`
4. **Agentic Micropayments (x402)**:
   - For pay-per-call endpoints, provide header `X-Payment: <receipt_or_token>` as detailed in `https://metareva.com/.well-known/x402.json`.

## Usage Example
```bash
curl -X POST "https://metareva.com/api/v1/agent/erp-query" \
  -H "Authorization: Bearer mr_live_..." \
  -H "Content-Type: application/json" \
  -d '{"sku": "PRD-1029", "operation": "stock"}'
```
