{
  "openapi": "3.1.0",
  "info": {
    "title": "CREW Agent Launch API",
    "version": "1.0.0",
    "summary": "Launch Pump.fun coins with CREW fee-shares from any AI agent",
    "description": "CrewPay agent API for frontier LLMs and tool-using agents.\n\nCompatible with: OpenAI GPT / ChatGPT / o-series, Anthropic Claude, Google Gemini, xAI Grok, Meta Llama, DeepSeek, Mistral, Cursor Cloud / IDE agents, MCP clients (Cursor, Claude Desktop, custom), Crypto / Solana / Pump.fun trading & launch agents, Any tool-using agent with HTTP GET/POST.\n\nHuman desk: https://crewpay.dev — Agent discovery: GET /api/agent or /llms.txt",
    "contact": {
      "url": "https://crewpay.dev"
    }
  },
  "servers": [
    {
      "url": "https://api.crewpay.dev",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "discovery",
      "description": "Public machine-readable docs"
    },
    {
      "name": "agent",
      "description": "Autohire + launch"
    }
  ],
  "paths": {
    "/llms.txt": {
      "get": {
        "tags": [
          "discovery"
        ],
        "summary": "llms.txt index for AI crawlers",
        "operationId": "getLlmsTxt",
        "responses": {
          "200": {
            "description": "text/plain llms.txt"
          }
        }
      }
    },
    "/llms-full.txt": {
      "get": {
        "tags": [
          "discovery"
        ],
        "summary": "Full agent instructions",
        "operationId": "getLlmsFullTxt",
        "responses": {
          "200": {
            "description": "text/plain full docs"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "tags": [
          "discovery"
        ],
        "summary": "This OpenAPI document",
        "operationId": "getOpenApi",
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 JSON"
          }
        }
      }
    },
    "/api/agent": {
      "get": {
        "tags": [
          "discovery",
          "agent"
        ],
        "summary": "Agent capability discovery JSON",
        "operationId": "getAgentDiscovery",
        "responses": {
          "200": {
            "description": "Discovery document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/autohire": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Preview narrative KOL autohire (no on-chain tx)",
        "operationId": "postAgentAutohire",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutohireRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hire plan + crew wallets"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        }
      }
    },
    "/api/agent/launch/dry-run": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Dry-run launch plan (no on-chain tx, mainnet costs estimated)",
        "operationId": "postAgentLaunchDryRun",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LaunchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validated plan + fee map + warnings"
          },
          "400": {
            "description": "Validation error"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        }
      }
    },
    "/api/agent/launch": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Launch Pump coin with CREW fee-shares (mainnet)",
        "operationId": "postAgentLaunch",
        "security": [
          {
            "CrewApiKey": [],
            "LauncherKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LaunchRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Mint created and fee-shares locked"
          },
          "202": {
            "description": "Mint live but feeShareLocked=false — wire fees"
          },
          "400": {
            "description": "Validation or launch error"
          },
          "401": {
            "description": "Missing/invalid auth"
          }
        }
      }
    },
    "/api/agent/keys/claim": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Self-serve mint a crew_ak_… API key (no operator bootstrap)",
        "operationId": "postAgentKeysClaim",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 64,
                    "default": "agent"
                  },
                  "agentName": {
                    "type": "string",
                    "maxLength": 48
                  },
                  "model": {
                    "type": "string",
                    "maxLength": 48
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "crew_ak_… key shown once (default 5 launches/hour)"
          },
          "429": {
            "description": "IP claim rate limit (5/hour)"
          }
        }
      }
    },
    "/api/agent/keys": {
      "get": {
        "tags": [
          "agent"
        ],
        "summary": "List agent API key metadata",
        "operationId": "getAgentKeys",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Key rows (no secrets)"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        }
      },
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Mint a per-agent API key (bootstrap with operator key)",
        "operationId": "postAgentKeys",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "crew_ak_… key shown once"
          },
          "401": {
            "description": "Missing/invalid API key"
          }
        }
      }
    },
    "/api/agent/keys/{id}": {
      "delete": {
        "tags": [
          "agent"
        ],
        "summary": "Revoke an agent API key",
        "operationId": "deleteAgentKey",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/agent/status/{mint}": {
      "get": {
        "tags": [
          "agent"
        ],
        "summary": "Mint fee-share / Holder KOL status",
        "operationId": "getAgentStatus",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "mint",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/agent/launches": {
      "get": {
        "tags": [
          "agent"
        ],
        "summary": "List launches for this agent API key",
        "operationId": "getAgentLaunches",
        "security": [
          {
            "CrewApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Launches attributed to this key (or recent board for operator env key)"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/agent/wire-fees": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Wire / repair CREW fee-shares on an existing mint (crew optional if board has crew)",
        "operationId": "postAgentWireFees",
        "security": [
          {
            "CrewApiKey": [],
            "LauncherKey": []
          }
        ],
        "responses": {
          "201": {
            "description": "feeShareSignature"
          },
          "400": {
            "description": "Repair failed"
          }
        }
      }
    },
    "/api/agent/lock-holder-kol": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Lock Holder-KOL fee-shares",
        "operationId": "postAgentLockHolderKol",
        "security": [
          {
            "CrewApiKey": [],
            "LauncherKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Locked"
          },
          "400": {
            "description": "Failed"
          }
        }
      }
    },
    "/api/agent/crank": {
      "post": {
        "tags": [
          "agent"
        ],
        "summary": "Crank distributeCreatorFeesV2 remits",
        "operationId": "postAgentCrank",
        "security": [
          {
            "CrewApiKey": [],
            "LauncherKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Remit signature"
          },
          "400": {
            "description": "Failed"
          }
        }
      }
    },
    "/api/proof": {
      "get": {
        "tags": [
          "discovery"
        ],
        "summary": "Public proof tape (launches, remits, buybacks)",
        "operationId": "getProof",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 40
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Proof bundle"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "CrewApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-crew-api-key",
        "description": "CREW_AGENT_API_KEY (server-only agent key)"
      },
      "LauncherKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-launcher-key",
        "description": "Agent Solana secret (base58 or JSON byte array)"
      }
    },
    "schemas": {
      "AutohireRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 32
          },
          "ticker": {
            "type": "string",
            "maxLength": 13
          },
          "description": {
            "type": "string",
            "maxLength": 204,
            "description": "User vibe ≤204. Final IPFS description appends “Launched from CrewPay.dev platform” (≤240)."
          },
          "seats": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 5
          }
        }
      },
      "CrewMember": {
        "type": "object",
        "required": [
          "handle",
          "wallet",
          "share"
        ],
        "properties": {
          "handle": {
            "type": "string"
          },
          "wallet": {
            "type": "string"
          },
          "share": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "hireRole": {
            "type": "string",
            "enum": [
              "caller",
              "chart",
              "raid",
              "kol",
              "dev"
            ]
          }
        }
      },
      "LaunchRequest": {
        "type": "object",
        "required": [
          "name",
          "ticker"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 32
          },
          "ticker": {
            "type": "string",
            "minLength": 2,
            "maxLength": 13
          },
          "description": {
            "type": "string",
            "maxLength": 204,
            "description": "User vibe ≤204. Final IPFS description appends “Launched from CrewPay.dev platform” (≤240). Shown in dry-run.vibe / attribution."
          },
          "mode": {
            "type": "string",
            "enum": [
              "split",
              "buyback",
              "raid",
              "agent"
            ],
            "default": "agent"
          },
          "twitter": {
            "type": "string"
          },
          "website": {
            "type": "string"
          },
          "initialBuySol": {
            "type": "number",
            "minimum": 0,
            "maximum": 10,
            "default": 0
          },
          "imageUrl": {
            "type": "string",
            "format": "uri"
          },
          "imageBase64": {
            "type": "string"
          },
          "imageContentType": {
            "type": "string"
          },
          "crew": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CrewMember"
            }
          },
          "autoHire": {
            "type": "object",
            "properties": {
              "seats": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10,
                "default": 5
              }
            }
          },
          "agent": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "objective": {
                "type": "string"
              },
              "model": {
                "type": "string",
                "description": "Optional mind label — e.g. gpt, claude, gemini, grok, llama, deepseek, mistral, cursor"
              }
            }
          },
          "holderKol": {
            "type": "boolean",
            "default": false
          }
        }
      }
    }
  }
}
