{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentOnboard Identity API",
    "version": "1.0.0",
    "description": "Public HTTP endpoints for minting 5-minute domain-scoped RS256 agent tokens, inspecting API key ownership, and fetching public JWKS signing keys."
  },
  "servers": [
    {
      "url": "https://agentonboard.xyz",
      "description": "Production Identity Engine"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your AgentOnboard API key (`aon_live_...`), created on https://agentonboard.xyz/dashboard."
      }
    }
  },
  "paths": {
    "/api/v1/token/exchange": {
      "post": {
        "summary": "Exchange API Key for 5-Minute JWT",
        "description": "Validates your `aon_live_...` API key and mints a 5-minute (`300s`), domain-scoped RS256 JWT bound to the requested `audience` hostname.",
        "operationId": "exchangeToken",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["audience"],
                "properties": {
                  "audience": {
                    "type": "string",
                    "description": "Target service hostname or URL (normalized to a bare lowercase hostname such as `notes.com`).",
                    "example": "notes.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed 5-minute RS256 JWT.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["token", "token_type", "expires_in", "expires_at", "audience", "user"],
                  "properties": {
                    "token": {
                      "type": "string",
                      "description": "Raw signed RS256 JWT string.",
                      "example": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImFvbl8yMDI2X3YxIn0..."
                    },
                    "token_type": {
                      "type": "string",
                      "enum": ["Bearer"],
                      "example": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer",
                      "description": "Token lifetime in seconds (always 300).",
                      "example": 300
                    },
                    "expires_at": {
                      "type": "integer",
                      "description": "Unix epoch timestamp (seconds) when the token expires.",
                      "example": 1740000300
                    },
                    "audience": {
                      "type": "string",
                      "description": "Normalized target hostname encoded in the `aud` claim.",
                      "example": "notes.com"
                    },
                    "user": {
                      "type": "object",
                      "required": ["email"],
                      "properties": {
                        "email": {
                          "type": "string",
                          "example": "ada@example.com"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid `audience` parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "missing_audience"
                    },
                    "message": {
                      "type": "string",
                      "example": "Field 'audience' (or 'domain') is required in request body"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "invalid_api_key"
                    },
                    "message": {
                      "type": "string",
                      "example": "Invalid or nonexistent API key"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error."
          }
        }
      }
    },
    "/api/v1/whoami": {
      "get": {
        "summary": "Inspect API Key Identity",
        "description": "Returns the verified human email, display name, and key prefix associated with the provided `aon_live_...` API key without minting a domain token.",
        "operationId": "getWhoami",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authenticated account details.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["ok", "email", "keyPrefix"],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "email": {
                      "type": "string",
                      "example": "ada@example.com"
                    },
                    "name": {
                      "type": ["string", "null"],
                      "example": "Ada Lovelace"
                    },
                    "keyPrefix": {
                      "type": "string",
                      "example": "aon_live_abcd"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string",
                      "example": "invalid_api_key"
                    },
                    "message": {
                      "type": "string",
                      "example": "Invalid or nonexistent API key"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/jwks.json": {
      "get": {
        "summary": "Fetch Public JWKS Keys",
        "description": "Returns the RFC 7517 JSON Web Key Set (JWKS) containing AgentOnboard's public RSA-2048 signing keys. Relying Party backends and `@agentonboard/sdk` fetch and cache this endpoint to verify Agent Identity Tokens locally.",
        "operationId": "getJwks",
        "responses": {
          "200": {
            "description": "Public JSON Web Key Set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["keys"],
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": ["kty", "kid", "alg", "use", "n", "e"],
                        "properties": {
                          "kty": {
                            "type": "string",
                            "example": "RSA"
                          },
                          "kid": {
                            "type": "string",
                            "example": "aon_2026_v1"
                          },
                          "alg": {
                            "type": "string",
                            "example": "RS256"
                          },
                          "use": {
                            "type": "string",
                            "example": "sig"
                          },
                          "n": {
                            "type": "string",
                            "description": "RSA public modulus (base64url-encoded)."
                          },
                          "e": {
                            "type": "string",
                            "example": "AQAB"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
