{
  "openapi": "3.0.3",
  "info": {
    "title": "Trip Topology agent registration",
    "version": "1.0.0",
    "description": "Public, browserless registration for a Free Trip Topology account."
  },
  "servers": [
    {
      "url": "https://triptopology.com"
    }
  ],
  "paths": {
    "/agent-registration/challenge": {
      "get": {
        "operationId": "getAgentChallenge",
        "summary": "Get a five-minute registration challenge",
        "responses": {
          "200": {
            "description": "Solve this challenge and submit it from the same client network. Do not cache it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentChallenge"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/agent-registration": {
      "post": {
        "operationId": "registerAgent",
        "summary": "Create an account and issue one Free API key",
        "description": "A challenge can be used only once. If the response is lost, its secrets cannot be recovered.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentProof"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The API key and one-time claim secret. This is the only time they are shown.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentRegistration"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "description": "Too many new accounts in the last 24 hours.",
            "headers": {
              "Retry-After": {
                "description": "Seconds before a new attempt may succeed. Get a fresh challenge before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Problem": {
        "description": "RFC 9457 problem details",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "AgentChallenge": {
        "type": "object",
        "required": [
          "challenge",
          "difficulty",
          "expires_at"
        ],
        "properties": {
          "challenge": {
            "type": "string",
            "description": "Opaque challenge. Use its exact ASCII text in the proof of work."
          },
          "difficulty": {
            "type": "integer",
            "description": "Required number of leading zero bits in SHA-256 of the ASCII text challenge + ':' + nonce."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AgentProof": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "challenge",
          "nonce"
        ],
        "properties": {
          "challenge": {
            "type": "string"
          },
          "nonce": {
            "type": "string",
            "pattern": "^[0-9a-f]{16}$",
            "description": "Sixteen lowercase hexadecimal digits, padded with zeros if needed."
          }
        }
      },
      "AgentRegistration": {
        "type": "object",
        "required": [
          "account_id",
          "api_key",
          "claim_secret",
          "plan"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "format": "uuid"
          },
          "api_key": {
            "type": "string",
            "description": "Bearer key for REST and MCP. Never send it to the claim form."
          },
          "claim_secret": {
            "type": "string",
            "description": "One-time secret used by a verified WorkOS user to claim ownership of the agent account."
          },
          "plan": {
            "type": "string",
            "enum": [
              "free"
            ]
          }
        }
      }
    }
  }
}
